34 #define XMODEM_NAK 0x15 38 #define XMODEM_CRC 'C' 41 #define XMODEM_SOH 0x01 44 #define XMODEM_STX 0x02 47 #define XMODEM_ACK 0x06 50 #define XMODEM_CAN 0x18 53 #define XMODEM_EOT 0x04 // end of transmission 121 #define XBEE_XMODEM_FLAG_NONE 0x0000 123 #define XBEE_XMODEM_FLAG_CHECKSUM 0x0001 125 #define XBEE_XMODEM_FLAG_CRC 0x0002 127 #define XBEE_XMODEM_FLAG_FORCE_CRC 0x0008 129 #define XBEE_XMODEM_MASK_BLOCKSIZE 0x0300 131 #define XBEE_XMODEM_FLAG_128 0x0000 133 #define XBEE_XMODEM_FLAG_64 0x0100 135 #define XBEE_XMODEM_FLAG_1K 0x0200 137 #define XBEE_XMODEM_FLAG_1024 XBEE_XMODEM_FLAG_1K 139 #ifdef XBEE_XMODEM_TESTING 142 #define XBEE_XMODEM_FLAG_DROP_ACK 0x1000 143 #define XBEE_XMODEM_FLAG_DROP_FRAME 0x2000 145 #define XBEE_XMODEM_FLAG_BAD_CRC 0x4000 147 #define XBEE_XMODEM_FLAG_RESTORE_CRC 0x8000 152 #define XBEE_XMODEM_FLAG_USER \ 153 (XBEE_XMODEM_MASK_BLOCKSIZE | XBEE_XMODEM_FLAG_FORCE_CRC) transfer failed
Definition: xmodem.h:108
Structure used to track the state of an Xmodem send.
Definition: xmodem.h:114
int xbee_xmodem_set_stream(xbee_xmodem_state_t *xbxm, xbee_xmodem_read_fn read, xbee_xmodem_write_fn write, const void FAR *context)
Configure the stream used to communicate with the target.
Definition: xbee_xmodem.c:79
int(* xbee_xmodem_write_fn)(void FAR *context, const void FAR *buffer, int16_t bytes)
Function to assign to stream.write member of an xbee_xmodem_state_t object.
Definition: xmodem.h:92
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
Definition: platform_config.h:71
completed transfer was successful
Definition: xmodem.h:107
int(* xbee_xmodem_read_fn)(void FAR *context, void FAR *buffer, int16_t bytes)
Function to assign to file.read or stream.read member of an xbee_xmodem_state_t object.
Definition: xmodem.h:74
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
uint_fast8_t tries
of tries left before giving up
Definition: xmodem.h:163
xbee_xmodem_state
Values for state member of xbee_xmodem_state_t.
Definition: xmodem.h:98
int offset
offset into packet being sent
Definition: xmodem.h:164
enum xbee_xmodem_state state
current state of transfer
Definition: xmodem.h:162
struct xbee_xmodem_state_t::@12 stream
functions and context to communicate with target device
int xbee_xmodem_set_source(xbee_xmodem_state_t *xbxm, void FAR *buffer, xbee_xmodem_read_fn read, const void FAR *context)
Configure the data source for the Xmodem send.
Definition: xbee_xmodem.c:106
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
int xbee_xmodem_use_serport(xbee_xmodem_state_t *xbxm, xbee_serial_t *serport)
Used for xmodem transfers over a simple serial port.
Definition: xbee_xmodem.c:69
uint16_t flags
flags for tracking state of transfer
Definition: xmodem.h:117
void FAR * context
context for file.read()
Definition: xmodem.h:168
sending bytes of packet
Definition: xmodem.h:103
reached end of file, close connection
Definition: xmodem.h:105
start of another packet
Definition: xmodem.h:101
waiting for final ACK from receiver
Definition: xmodem.h:106
uint16_t packet_num
current packet number; starts at 1 and low byte used in block headers
Definition: xmodem.h:157
int xbee_xmodem_tx_tick(xbee_xmodem_state_t *xbxm)
Function to drive the Xmodem send state machine.
Definition: xbee_xmodem.c:296
short int16_t
16-bit signed integer
Definition: platform_config.h:40
char FAR * buffer
buffer we can use
Definition: xmodem.h:165
uint16_t timer
timer value used to hold low word of xbee_millisecond_timer()
Definition: xmodem.h:160
waiting for ACK of current packet
Definition: xmodem.h:104
xbee_xmodem_write_fn write
send blocks to target
Definition: xmodem.h:172
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
flush receive buffer and wait
Definition: xmodem.h:99
struct xbee_xmodem_state_t::@11 file
function and context to read source of sent data
int xbee_xmodem_tx_init(xbee_xmodem_state_t *xbxm, uint16_t flags)
Initialize state structure for use with xbee_xmodem_tx_tick() to send a file via Xmodem.
Definition: xbee_xmodem.c:188
xbee_xmodem_read_fn read
source of bytes to send
Definition: xmodem.h:167
resend last packet
Definition: xmodem.h:102
waiting for NAK or CRC char
Definition: xmodem.h:100