Go to the documentation of this file.
20 #ifndef FEETECH_READER_H
21 #define FEETECH_READER_H
33 #define FEETECH_ACK_SIZE (6)
34 #define FEETECH_RESPONSE_SIZE(len) (6 + len)
76 return 5 < reader->
size;
91 reader->
buffer[0] == FEETECH_START &&
92 reader->
buffer[1] == FEETECH_START;
105 return reader->
size == (size_t)(reader->
buffer[3] + 4);
164 return &reader->
buffer[5];
176 return reader->
buffer[3] - 2;
188 return &reader->
buffer[6];
200 return reader->
buffer[3] - 3;
static bool feetech_reader_check_start(const feetech_reader_t *reader)
Check if the packet begins with 2 FEETECH_START bits.
static uint8_t feetech_reader_sync_write_get_reg(const feetech_reader_t *reader)
Get the packet's target register address (SYNC_WRITE)
static size_t feetech_reader_response_get_payload_size(const feetech_reader_t *reader)
Get the packet's payload size (response)
static uint8_t feetech_reader_write_get_reg(const feetech_reader_t *reader)
Get the packet's target register address (WRITE)
static void feetech_reader_init(feetech_reader_t *reader, const uint8_t *buffer, size_t size)
Initialize the Feetech packet reader.
static size_t feetech_reader_sync_write_get_payload_size(const feetech_reader_t *reader)
Get the packet items' payload size (SYNC_WRITE)
static uint8_t feetech_reader_get_instr(const feetech_reader_t *reader)
Get the packet's instruction code.
static uint8_t feetech_reader_get_id(const feetech_reader_t *reader)
Get the packet's device id.
size_t size
data buffer's size
Feetech protocol definitions.
static bool feetech_reader_check_minsize(const feetech_reader_t *reader)
Check if the packet has the minimum required size.
static size_t feetech_reader_write_get_payload_size(const feetech_reader_t *reader)
Get the packet's payload size (WRITE)
uint8_t feetech_reader_compute_sum(const feetech_reader_t *reader)
Compute the packet's sum.
static const uint8_t * feetech_reader_response_get_payload(const feetech_reader_t *reader)
Get the packet's payload (response)
size_t feetech_reader_sync_write_get_items_count(const feetech_reader_t *reader)
Get the packet items' count (SYNC_WRITE)
static size_t feetech_reader_read_get_size(const feetech_reader_t *reader)
Get the packet's READ size.
Feetech packet reader struct.
uint8_t feetech_reader_sync_write_item_get_id(const feetech_reader_t *reader, uint8_t index)
Get the packet item's device id (SYNC_WRITE)
static bool feetech_reader_check_sum(const feetech_reader_t *reader)
Check if the computed sum and the sum of the packet are equal.
static const uint8_t * feetech_reader_write_get_payload(const feetech_reader_t *reader)
Get the packet's payload (WRITE)
bool feetech_reader_is_valid(const feetech_reader_t *reader)
Check if the packet is valid.
static uint8_t feetech_reader_read_get_reg(const feetech_reader_t *reader)
Get the packet's target register address (READ)
const uint8_t * buffer
data buffer
static bool feetech_reader_check_size(const feetech_reader_t *reader)
Check if the packet's size is the same as the buffer's size.
const uint8_t * feetech_reader_sync_write_item_get_payload(const feetech_reader_t *reader, uint8_t index)
Get the packet item's payload (SYNC_WRITE)