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;
90 reader->
buffer[0] == FEETECH_START &&
91 reader->
buffer[1] == FEETECH_START;
104 return reader->
size == (size_t)(reader->
buffer[3] + 4);
163 return &reader->
buffer[5];
175 return reader->
buffer[3] - 2;
187 return &reader->
buffer[6];
199 return reader->
buffer[3] - 3;
Feetech protocol definitions.
static uint8_t feetech_reader_write_get_reg(const feetech_reader_t *reader)
Get the packet's target register address (WRITE)
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 const uint8_t * feetech_reader_write_get_payload(const feetech_reader_t *reader)
Get the packet's payload (WRITE)
size_t feetech_reader_sync_write_get_items_count(const feetech_reader_t *reader)
Get the packet items' count (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 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_id(const feetech_reader_t *reader)
Get the packet's device id.
static bool feetech_reader_check_start(const feetech_reader_t *reader)
Check if the packet begins with 2 FEETECH_START bits.
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)
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_read_get_size(const feetech_reader_t *reader)
Get the packet's READ size.
static void feetech_reader_init(feetech_reader_t *reader, const uint8_t *buffer, size_t size)
Initialize the Feetech packet reader.
static const uint8_t * feetech_reader_response_get_payload(const feetech_reader_t *reader)
Get the packet's payload (response)
static uint8_t feetech_reader_get_instr(const feetech_reader_t *reader)
Get the packet's instruction code.
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.
static size_t feetech_reader_response_get_payload_size(const feetech_reader_t *reader)
Get the packet's payload size (response)
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.
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)
Feetech packet reader struct.
const uint8_t * buffer
data buffer
size_t size
data buffer's size