Loading...
Searching...
No Matches
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.
 
uint8_t feetech_reader_compute_sum (const feetech_reader_t *reader)
 Compute the packet's sum.
 
static bool feetech_reader_check_minsize (const feetech_reader_t *reader)
 Check if the packet has the minimum required size.
 
static bool feetech_reader_check_start (const feetech_reader_t *reader)
 Check if the packet begins with 2 FEETECH_START bits.
 
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 bool feetech_reader_check_sum (const feetech_reader_t *reader)
 Check if the computed sum and the sum of the packet are equal.
 
bool feetech_reader_is_valid (const feetech_reader_t *reader)
 Check if the packet is valid.
 
static uint8_t feetech_reader_get_id (const feetech_reader_t *reader)
 Get the packet's device id.
 
static uint8_t feetech_reader_get_instr (const feetech_reader_t *reader)
 Get the packet's instruction code.
 
static const uint8_t * feetech_reader_response_get_payload (const feetech_reader_t *reader)
 Get the packet's payload (response)
 
static size_t feetech_reader_response_get_payload_size (const feetech_reader_t *reader)
 Get the packet's payload size (response)
 
static const uint8_t * feetech_reader_write_get_payload (const feetech_reader_t *reader)
 Get the packet's payload (WRITE)
 
static size_t feetech_reader_write_get_payload_size (const feetech_reader_t *reader)
 Get the packet's payload size (WRITE)
 
static uint8_t feetech_reader_write_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (WRITE)
 
static size_t feetech_reader_read_get_size (const feetech_reader_t *reader)
 Get the packet's READ size.
 
static uint8_t feetech_reader_read_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (READ)
 
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_sync_write_get_reg (const feetech_reader_t *reader)
 Get the packet's target register address (SYNC_WRITE)
 
size_t feetech_reader_sync_write_get_items_count (const feetech_reader_t *reader)
 Get the packet items' count (SYNC_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)
 
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)
 

Macro Definition Documentation

◆ FEETECH_ACK_SIZE

#define FEETECH_ACK_SIZE   (6)

Definition at line 33 of file feetech_reader.h.

◆ FEETECH_RESPONSE_SIZE

#define FEETECH_RESPONSE_SIZE (   len)    (6 + len)

Definition at line 34 of file feetech_reader.h.

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 102 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 87 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 115 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 137 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 149 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 233 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 221 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 161 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 173 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 245 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 257 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 185 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 197 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 209 of file feetech_reader.h.