feetech_reader.h

Interface definition for Feetech packet reader.

FEETECH_ACK_SIZE
1
(6)
FEETECH_RESPONSE_SIZE( len)
1
(6 + len)
void feetech_reader_init(feetech_reader_t * reader, const uint8_t * buffer, msp430_types.h::size_t size)

Initialize the Feetech packet reader.

Parameters

reader:the packet reader
buffer:the buffer used to store data
size:the size of the buffer

uint8_t feetech_reader_compute_sum(const feetech_reader_t * reader)

Compute the packet’s sum.

Parameters

reader:the packet reader

Return values

  • the sum of the packet
bool feetech_reader_check_minsize(const feetech_reader_t * reader)

Check if the packet has the minimum required size.

Parameters

reader:the packet reader

Return values

  • true if the packet has the minimum required size
  • false otherwise
bool feetech_reader_check_start(const feetech_reader_t * reader)

Check if the packet begins with 2 FEETECH_START bits.

Parameters

reader:the packet reader

Return values

  • true if the packet begins with 2 FEETECH_START bits
  • false otherwise
bool feetech_reader_check_size(const feetech_reader_t * reader)

Check if the packet’s size is the same as the buffer’s size.

Parameters

reader:the packet reader

Return values

  • true if the packet’s size is the same as the buffer’s size
  • false otherwise
bool feetech_reader_check_sum(const feetech_reader_t * reader)

Check if the computed sum and the sum of the packet are equal.

Parameters

reader:the packet reader

Return values

  • true if the computed sum and the sum of the packet are equal
  • false otherwise
bool feetech_reader_is_valid(const feetech_reader_t * reader)

Check if the packet is valid.

Parameters

reader:the packet reader

Return values

  • true if the packet is valid
  • false otherwise
uint8_t feetech_reader_get_id(const feetech_reader_t * reader)

Get the packet’s device id.

Parameters

reader:the packet reader

Return values

  • the packet’s device id
uint8_t feetech_reader_get_instr(const feetech_reader_t * reader)

Get the packet’s instruction code.

Parameters

reader:the packet reader

Return values

  • the packet’s instruction code
const uint8_t * feetech_reader_response_get_payload(const feetech_reader_t * reader)

Get the packet’s payload (response)

Parameters

reader:the packet reader

Return values

  • the addess of the begining of the payload
msp430_types.h::size_t feetech_reader_response_get_payload_size(const feetech_reader_t * reader)

Get the packet’s payload size (response)

Parameters

reader:the packet reader

Return values

  • the size of the payload
const uint8_t * feetech_reader_write_get_payload(const feetech_reader_t * reader)

Get the packet’s payload (WRITE)

Parameters

reader:the packet reader

Return values

  • the begining addess of the payload
msp430_types.h::size_t feetech_reader_write_get_payload_size(const feetech_reader_t * reader)

Get the packet’s payload size (WRITE)

Parameters

reader:the packet reader

Return values

  • the size of the payload
uint8_t feetech_reader_write_get_reg(const feetech_reader_t * reader)

Get the packet’s target register address (WRITE)

Parameters

reader:the packet reader

Return values

  • the register address
msp430_types.h::size_t feetech_reader_read_get_size(const feetech_reader_t * reader)

Get the packet’s READ size.

Parameters

reader:the packet reader

Return values

  • the READ size
uint8_t feetech_reader_read_get_reg(const feetech_reader_t * reader)

Get the packet’s target register address (READ)

Parameters

reader:the packet reader

Return values

  • the register address
msp430_types.h::size_t feetech_reader_sync_write_get_payload_size(const feetech_reader_t * reader)

Get the packet items’ payload size (SYNC_WRITE)

Parameters

reader:the packet reader

Return values

  • the size of the items’ payload
uint8_t feetech_reader_sync_write_get_reg(const feetech_reader_t * reader)

Get the packet’s target register address (SYNC_WRITE)

Parameters

reader:the packet reader

Return values

  • the register address
msp430_types.h::size_t feetech_reader_sync_write_get_items_count(const feetech_reader_t * reader)

Get the packet items’ count (SYNC_WRITE)

Parameters

reader:the packet reader

Return values

  • the number of items in the packet
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)

Parameters

reader:the packet reader
index:the item index

Return values

  • the item’s device id
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)

Parameters

reader:the packet reader
index:the item index

Return values

  • the begining addess of the payload
struct feetech_reader_t

Feetech packet reader struct.

const uint8_t * buffer

data buffer

msp430_types.h::size_t size

data buffer’s size