feetech_reader.h File Reference

Interface definition for Feetech packet reader. More...

Detailed Description

#include "feetech_protocol.h"
#include <stdint.h>
#include <stdbool.h>
#include <stdlib.h>
+ Include dependency graph for feetech_reader.h:

Go to the source code of this file.

Data Structures

struct  feetech_reader_t
 Feetech packet reader struct. More...
 
#define FEETECH_ACK_SIZE   (6)
 
#define FEETECH_RESPONSE_SIZE(len)   (6 + len)
 
static void feetech_reader_init (feetech_reader_t *reader, const uint8_t *buffer, size_t size)
 Initialize the Feetech packet reader. More...
 
uint8_t feetech_reader_compute_sum (const feetech_reader_t *reader)
 Compute the packet's sum. More...
 
static bool feetech_reader_check_minsize (const feetech_reader_t *reader)
 Check if the packet has the minimum required size. More...
 
static bool feetech_reader_check_start (const feetech_reader_t *reader)
 Check if the packet begins with 2 FEETECH_START bits. More...
 
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. More...
 
static bool feetech_reader_check_sum (const feetech_reader_t *reader)
 Check if the computed sum and the sum of the packet are equal. More...
 
bool feetech_reader_is_valid (const feetech_reader_t *reader)
 Check if the packet is valid. More...
 
static uint8_t feetech_reader_get_id (const feetech_reader_t *reader)
 Get the packet's device id. More...
 
static uint8_t feetech_reader_get_instr (const feetech_reader_t *reader)
 Get the packet's instruction code. More...
 
static const uint8_t * feetech_reader_response_get_payload (const feetech_reader_t *reader)
 Get the packet's payload (response) More...
 
static size_t feetech_reader_response_get_payload_size (const feetech_reader_t *reader)
 Get the packet's payload size (response) More...
 
static const uint8_t * feetech_reader_write_get_payload (const feetech_reader_t *reader)
 Get the packet's payload (WRITE) More...
 
static size_t feetech_reader_write_get_payload_size (const feetech_reader_t *reader)
 Get the packet's payload size (WRITE) More...
 
static uint8_t feetech_reader_write_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (WRITE) More...
 
static size_t feetech_reader_read_get_size (const feetech_reader_t *reader)
 Get the packet's READ size. More...
 
static uint8_t feetech_reader_read_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (READ) More...
 
static size_t feetech_reader_sync_write_get_payload_size (const feetech_reader_t *reader)
 Get the packet items' payload size (SYNC_WRITE) More...
 
static uint8_t feetech_reader_sync_write_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (SYNC_WRITE) More...
 
size_t feetech_reader_sync_write_get_items_count (const feetech_reader_t *reader)
 Get the packet items' count (SYNC_WRITE) More...
 
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) More...
 
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) More...
 

Function Documentation

static bool feetech_reader_check_minsize ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
true if the packet has the minimum required size
false otherwise

Definition at line 74 of file feetech_reader.h.

static bool feetech_reader_check_size ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
true if the packet's size is the same as the buffer's size
false otherwise

Definition at line 103 of file feetech_reader.h.

static bool feetech_reader_check_start ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
true if the packet begins with 2 FEETECH_START bits
false otherwise

Definition at line 88 of file feetech_reader.h.

static bool feetech_reader_check_sum ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
true if the computed sum and the sum of the packet are equal
false otherwise

Definition at line 116 of file feetech_reader.h.

uint8_t feetech_reader_compute_sum ( const feetech_reader_t reader)
Parameters
[in]readerthe packet reader
Returns
the sum of the packet
static uint8_t feetech_reader_get_id ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the packet's device id

Definition at line 138 of file feetech_reader.h.

static uint8_t feetech_reader_get_instr ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the packet's instruction code

Definition at line 150 of file feetech_reader.h.

static void feetech_reader_init ( feetech_reader_t reader,
const uint8_t *  buffer,
size_t  size 
)
inlinestatic
Parameters
[out]readerthe packet reader
[in]bufferthe buffer used to store data
[in]sizethe size of the buffer

Definition at line 51 of file feetech_reader.h.

bool feetech_reader_is_valid ( const feetech_reader_t reader)
Parameters
[in]readerthe packet reader
Returns
true if the packet is valid
false otherwise
static uint8_t feetech_reader_read_get_reg ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 234 of file feetech_reader.h.

static size_t feetech_reader_read_get_size ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the READ size

Definition at line 222 of file feetech_reader.h.

static const uint8_t* feetech_reader_response_get_payload ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the addess of the begining of the payload

Definition at line 162 of file feetech_reader.h.

static size_t feetech_reader_response_get_payload_size ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the size of the payload

Definition at line 174 of file feetech_reader.h.

size_t feetech_reader_sync_write_get_items_count ( const feetech_reader_t reader)
Parameters
[in]readerthe packet reader
Returns
the number of items in the packet
static size_t feetech_reader_sync_write_get_payload_size ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the size of the items' payload

Definition at line 246 of file feetech_reader.h.

static uint8_t feetech_reader_sync_write_get_reg ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 258 of file feetech_reader.h.

uint8_t feetech_reader_sync_write_item_get_id ( const feetech_reader_t reader,
uint8_t  index 
)
Parameters
[in]readerthe packet reader
[in]indexthe item index
Returns
the item's device id
const uint8_t* feetech_reader_sync_write_item_get_payload ( const feetech_reader_t reader,
uint8_t  index 
)
Parameters
[in]readerthe packet reader
[in]indexthe item index
Returns
the begining addess of the payload
static const uint8_t* feetech_reader_write_get_payload ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the begining addess of the payload

Definition at line 186 of file feetech_reader.h.

static size_t feetech_reader_write_get_payload_size ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the size of the payload

Definition at line 198 of file feetech_reader.h.

static uint8_t feetech_reader_write_get_reg ( const feetech_reader_t reader)
inlinestatic
Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 210 of file feetech_reader.h.