feetech_reader.h File Reference

Interface definition for Feetech packet reader. More...

Detailed Description

Interface definition for Feetech packet reader.

Author
Loïc Dauphin loic..nosp@m.daup.nosp@m.hin@i.nosp@m.nria.nosp@m..fr

Definition in file feetech_reader.h.

#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

◆ feetech_reader_check_minsize()

static bool feetech_reader_check_minsize ( const feetech_reader_t reader)
inlinestatic

Check if the packet has the minimum required size.

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.

◆ feetech_reader_check_size()

static bool feetech_reader_check_size ( const feetech_reader_t reader)
inlinestatic

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

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.

◆ feetech_reader_check_start()

static bool feetech_reader_check_start ( const feetech_reader_t reader)
inlinestatic

Check if the packet begins with 2 FEETECH_START bits.

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.

◆ feetech_reader_check_sum()

static bool feetech_reader_check_sum ( const feetech_reader_t reader)
inlinestatic

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

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.

◆ feetech_reader_compute_sum()

uint8_t feetech_reader_compute_sum ( const feetech_reader_t reader)

Compute the packet's sum.

Parameters
[in]readerthe packet reader
Returns
the sum of the packet

◆ feetech_reader_get_id()

static uint8_t feetech_reader_get_id ( const feetech_reader_t reader)
inlinestatic

Get the packet's device id.

Parameters
[in]readerthe packet reader
Returns
the packet's device id

Definition at line 138 of file feetech_reader.h.

◆ feetech_reader_get_instr()

static uint8_t feetech_reader_get_instr ( const feetech_reader_t reader)
inlinestatic

Get the packet's instruction code.

Parameters
[in]readerthe packet reader
Returns
the packet's instruction code

Definition at line 150 of file feetech_reader.h.

◆ feetech_reader_init()

static void feetech_reader_init ( feetech_reader_t reader,
const uint8_t *  buffer,
size_t  size 
)
inlinestatic

Initialize the Feetech packet reader.

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.

◆ feetech_reader_is_valid()

bool feetech_reader_is_valid ( const feetech_reader_t reader)

Check if the packet is valid.

Parameters
[in]readerthe packet reader
Returns
true if the packet is valid
false otherwise

◆ feetech_reader_read_get_reg()

static uint8_t feetech_reader_read_get_reg ( const feetech_reader_t reader)
inlinestatic

Get the packet's target register address (READ)

Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 234 of file feetech_reader.h.

◆ feetech_reader_read_get_size()

static size_t feetech_reader_read_get_size ( const feetech_reader_t reader)
inlinestatic

Get the packet's READ size.

Parameters
[in]readerthe packet reader
Returns
the READ size

Definition at line 222 of file feetech_reader.h.

◆ feetech_reader_response_get_payload()

static const uint8_t* feetech_reader_response_get_payload ( const feetech_reader_t reader)
inlinestatic

Get the packet's payload (response)

Parameters
[in]readerthe packet reader
Returns
the address of the beginning of the payload

Definition at line 162 of file feetech_reader.h.

◆ feetech_reader_response_get_payload_size()

static size_t feetech_reader_response_get_payload_size ( const feetech_reader_t reader)
inlinestatic

Get the packet's payload size (response)

Parameters
[in]readerthe packet reader
Returns
the size of the payload

Definition at line 174 of file feetech_reader.h.

◆ feetech_reader_sync_write_get_items_count()

size_t feetech_reader_sync_write_get_items_count ( const feetech_reader_t reader)

Get the packet items' count (SYNC_WRITE)

Parameters
[in]readerthe packet reader
Returns
the number of items in the packet

◆ feetech_reader_sync_write_get_payload_size()

static size_t feetech_reader_sync_write_get_payload_size ( const feetech_reader_t reader)
inlinestatic

Get the packet items' payload size (SYNC_WRITE)

Parameters
[in]readerthe packet reader
Returns
the size of the items' payload

Definition at line 246 of file feetech_reader.h.

◆ feetech_reader_sync_write_get_reg()

static uint8_t feetech_reader_sync_write_get_reg ( const feetech_reader_t reader)
inlinestatic

Get the packet's target register address (SYNC_WRITE)

Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 258 of file feetech_reader.h.

◆ feetech_reader_sync_write_item_get_id()

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
[in]readerthe packet reader
[in]indexthe item index
Returns
the item's device id

◆ feetech_reader_sync_write_item_get_payload()

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
[in]readerthe packet reader
[in]indexthe item index
Returns
the beginning address of the payload

◆ feetech_reader_write_get_payload()

static const uint8_t* feetech_reader_write_get_payload ( const feetech_reader_t reader)
inlinestatic

Get the packet's payload (WRITE)

Parameters
[in]readerthe packet reader
Returns
the beginning address of the payload

Definition at line 186 of file feetech_reader.h.

◆ feetech_reader_write_get_payload_size()

static size_t feetech_reader_write_get_payload_size ( const feetech_reader_t reader)
inlinestatic

Get the packet's payload size (WRITE)

Parameters
[in]readerthe packet reader
Returns
the size of the payload

Definition at line 198 of file feetech_reader.h.

◆ feetech_reader_write_get_reg()

static uint8_t feetech_reader_write_get_reg ( const feetech_reader_t reader)
inlinestatic

Get the packet's target register address (WRITE)

Parameters
[in]readerthe packet reader
Returns
the register address

Definition at line 210 of file feetech_reader.h.