|
XBee Firmware Library
1.6.0
|
Files | |
| file | xbee_xmodem.c |
| file | xmodem.h |
| file | xmodem_crc16.c |
| file | xmodem_crc16.h |
Data Structures | |
| struct | xbee_xmodem_state_t |
Typedefs | |
| typedef 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. More... | |
| typedef struct xbee_xmodem_state_t | xbee_xmodem_state_t |
| typedef 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. More... | |
Functions | |
| _xmodem_debug int | _assemble_packet (xbee_xmodem_state_t *xbxm, uint16_t block_size) |
| _xmodem_debug uint16_t | _block_size (xbee_xmodem_state_t *xbxm) |
| int | _xbee_xmodem_getchar (xbee_xmodem_state_t *xbxm) |
| int | _xbee_xmodem_putchar (xbee_xmodem_state_t *xbxm, uint8_t ch) |
| int | _xbee_xmodem_ser_read (void FAR *context, void FAR *buffer, int16_t bytes) |
| int | _xbee_xmodem_ser_write (void FAR *context, const void FAR *buffer, int16_t bytes) |
| XBEE_BEGIN_DECLS uint16_t | crc16_calc (const void FAR *data, uint16_t length, uint16_t current) |
| Calculate CRC-16 of a data buffer using polynomial (0x1021) without reflection. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| int | xbee_xmodem_tx_tick (xbee_xmodem_state_t *xbxm) |
| Function to drive the Xmodem send state machine. Call until it returns a non-zero result. More... | |
| int | xbee_xmodem_use_serport (xbee_xmodem_state_t *xbxm, xbee_serial_t *serport) |
| Used for xmodem transfers over a simple serial port. More... | |
Variables | |
| char FAR * | buffer |
| buffer we can use More... | |
| void FAR * context | |
| context for file.read() More... | |
| void FAR * context | |
| context for stream.read & .write More... | |
| const FAR uint16_t | crc16_table [256] |
| struct { | |
| void FAR * context | |
| context for file.read() More... | |
| xbee_xmodem_read_fn read | |
| source of bytes to send More... | |
| } | file |
| function and context to read source of sent data More... | |
| uint16_t | flags |
| flags for tracking state of transfer More... | |
| int | offset |
| offset into packet being sent More... | |
| uint16_t | packet_num |
| current packet number; starts at 1 and low byte used in block headers More... | |
| xbee_xmodem_read_fn read | |
| source of bytes to send More... | |
| xbee_xmodem_read_fn read | |
| read response bytes from target More... | |
| enum xbee_xmodem_state | state |
| current state of transfer More... | |
| struct { | |
| void FAR * context | |
| context for stream.read & .write More... | |
| xbee_xmodem_read_fn read | |
| read response bytes from target More... | |
| xbee_xmodem_write_fn write | |
| send blocks to target More... | |
| } | stream |
| functions and context to communicate with target device More... | |
| uint16_t | timer |
| timer value used to hold low word of xbee_millisecond_timer() More... | |
| uint_fast8_t | tries |
of tries left before giving upMore... | |
| xbee_xmodem_write_fn write | |
| send blocks to target More... | |
| typedef 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.
Used to read data from the Xmodem receiver (ACK/NAK bytes) or the firmware source (e.g., file or embedded array).
| [in] | context | either file.context or stream.context from the xbee_xmodem_state_t object |
| [in,out] | buffer | buffer to store read data |
| [in] | bytes | maximum number of bytes to write to buffer |
| >0 | number of bytes read |
| -ENODATA | no more bytes to read |
| -EINVAL | NULL pointer or negative byte count passed to function |
| 0 | no more bytes to read |
| typedef struct xbee_xmodem_state_t xbee_xmodem_state_t |
Structure used to track the state of an Xmodem send.
| typedef 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.
Used to write data to the Xmodem receiver (blocks of data).
| [in] | context | stream.context |
| [in] | buffer | bytes to send to the receiver |
| [in] | bytes | number of bytes to send |
| >=0 | number of bytes sent |
| -EINVAL | NULL pointer or negative byte count passed to function |
| <0 | irrecoverable error |
| enum xbee_xmodem_state |
Values for state member of xbee_xmodem_state_t
| _xmodem_debug int _assemble_packet | ( | xbee_xmodem_state_t * | xbxm, |
| uint16_t | block_size | ||
| ) |
| _xmodem_debug uint16_t _block_size | ( | xbee_xmodem_state_t * | xbxm | ) |
| _xmodem_debug int _xbee_xmodem_getchar | ( | xbee_xmodem_state_t * | xbxm | ) |
| _xmodem_debug int _xbee_xmodem_putchar | ( | xbee_xmodem_state_t * | xbxm, |
| uint8_t | ch | ||
| ) |
| _xmodem_debug int _xbee_xmodem_ser_read | ( | void FAR * | context, |
| void FAR * | buffer, | ||
| int16_t | bytes | ||
| ) |
| _xmodem_debug int _xbee_xmodem_ser_write | ( | void FAR * | context, |
| const void FAR * | buffer, | ||
| int16_t | bytes | ||
| ) |
Calculate CRC-16 of a data buffer using polynomial (0x1021) without reflection.
| [in] | data | pointer to data to CRC |
| [in] | length | number of bytes to CRC |
| [in] | current | When calculating a CRC-16 over a stream or a large range of bytes, it is necessary to call crc16_calc multiple times. |
| _xmodem_debug 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.
| [out] | xbxm | state structure to configure |
| [in] | buffer | buffer for use by xbee_xmodem_tx_tick – must be at least 5 bytes larger than the block size passed to xbee_xmodem_tx_init() |
| [in] | read | function used to read bytes to send to the target |
| [in] | context | context passed to read function |
| 0 | successfully configured data source |
| -EINVAL | invalid parameter passed in |
| _xmodem_debug 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.
Associates function pointers and a context that are used to send data to and receive data from the target (device receiving data via Xmodem).
| [out] | xbxm | state structure to configure |
| [in] | read | function used to read bytes from the target |
| [in] | write | function used to send bytes to the target |
| [in] | context | context passed to read and write functions |
| 0 | successfully configured communication path to target |
| -EINVAL | invalid parameter passed in |
| _xmodem_debug 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.
| [out] | xbxm | state structure to initialize |
| [in] | flags | one of the following macros, indicating the block size to use for the transfer
|
| -EINVAL | invalid parameter passed in |
| 0 | initialized state, can pass it to xbee_xmodem_tx_tick |
| _xmodem_debug int xbee_xmodem_tx_tick | ( | xbee_xmodem_state_t * | xbxm | ) |
Function to drive the Xmodem send state machine. Call until it returns a non-zero result.
| -EINVAL | invalid parameter passed in |
| -ETIMEDOUT | connection timed out waiting for data from target |
| <0 | error on send, transfer aborted |
| 0 | transfer in progress, call function again |
| 1 | transfer completed successfully |
| _xmodem_debug int xbee_xmodem_use_serport | ( | xbee_xmodem_state_t * | xbxm, |
| xbee_serial_t * | serport | ||
| ) |
Used for xmodem transfers over a simple serial port.
Associates the serial port with the xbee_xmodem_state_t and sets stream.read and stream.write function pointers to helper functions that read/write a serial port.
Must be called before xbee_xmodem_tx_tick() and either before or after xbee_xmodem_tx_init().
| [in,out] | xbxm | state object to configure for serial read/write |
| [in] | serport | port to use for transfer |
| 0 | successfully associated serport with xbxm |
| -EINVAL | NULL parameter passed in |
| <0 | error assigning serport to xbxm |
| char FAR* buffer |
buffer we can use
| void FAR* context |
context for file.read()
context for stream.read & .write
| void FAR* context |
context for file.read()
| void FAR* context |
context for stream.read & .write
| const FAR uint16_t crc16_table[256] |
Table for XMODEM and "False CCITT" CRC, calculated with standard 0x1021 polynomial.
| struct { ... } file |
function and context to read source of sent data
| uint16_t flags |
flags for tracking state of transfer
| int offset |
offset into packet being sent
| uint16_t packet_num |
current packet number; starts at 1 and low byte used in block headers
| xbee_xmodem_read_fn read |
source of bytes to send
read response bytes from target
| xbee_xmodem_read_fn read |
source of bytes to send
| xbee_xmodem_read_fn read |
read response bytes from target
| enum xbee_xmodem_state state |
current state of transfer
| struct { ... } stream |
functions and context to communicate with target device
| uint16_t timer |
timer value used to hold low word of xbee_millisecond_timer()
| uint_fast8_t tries |
| xbee_xmodem_write_fn write |
send blocks to target
| xbee_xmodem_write_fn write |
send blocks to target
1.8.10