feetech_writer.h File Reference

Interface definition for Feetech packet writer. More...

Detailed Description

Interface definition for Feetech packet writer.

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

Definition in file feetech_writer.h.

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

Go to the source code of this file.

Data Structures

struct  feetech_writer_t
 Feetech packet writer struct. More...
 
void feetech_writer_init (feetech_writer_t *writer, uint8_t *buffer, size_t buffer_max_size)
 Initialize the Feetech packet writer. More...
 
const uint8_t * feetech_writer_get_data (const feetech_writer_t *writer)
 Get the data buffer to send. More...
 
size_t feetech_writer_get_size (const feetech_writer_t *writer)
 Get the data buffer's size to send. More...
 
void feetech_writer_response_make (feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size)
 Build a response packet. More...
 
void feetech_writer_ack_make (feetech_writer_t *writer, uint8_t id)
 Build an ack packet. More...
 
void feetech_writer_ping_make (feetech_writer_t *writer, uint8_t id)
 Build a PING packet. More...
 
void feetech_writer_write_make (feetech_writer_t *writer, uint8_t id, uint8_t reg, const uint8_t *buffer, size_t size)
 Build a WRITE packet. More...
 
void feetech_writer_write8_make (feetech_writer_t *writer, uint8_t id, uint8_t reg, uint8_t value)
 Build a WRITE packet (8 bits) More...
 
void feetech_writer_write16_make (feetech_writer_t *writer, uint8_t id, uint8_t reg, uint16_t value)
 Build a WRITE packet (16 bits) More...
 
void feetech_writer_read_make (feetech_writer_t *writer, uint8_t id, uint8_t reg, size_t size)
 Build a READ packet. More...
 
void feetech_writer_sync_write_begin (feetech_writer_t *writer, uint8_t reg, size_t size)
 Begin to build a SYNC_WRITE packet. More...
 
void feetech_writer_sync_write_end (feetech_writer_t *writer)
 End the building of a SYNC_WRITE packet. More...
 
void feetech_writer_sync_write_add (feetech_writer_t *writer, uint8_t id, const uint8_t *buffer, size_t size)
 Add an item to a SYNC_WRITE packet. More...
 
void feetech_writer_sync_write_add_8bits (feetech_writer_t *writer, uint8_t id, uint8_t value)
 Add an item to a SYNC_WRITE packet (8 bits) More...
 
void feetech_writer_sync_write_add_16bits (feetech_writer_t *writer, uint8_t id, uint16_t value)
 Add an item to a SYNC_WRITE packet (16 bits) More...
 

Function Documentation

◆ feetech_writer_ack_make()

void feetech_writer_ack_make ( feetech_writer_t writer,
uint8_t  id 
)

Build an ack packet.

Parameters
[out]writerthe packet writer
[in]idthe responder's id

◆ feetech_writer_get_data()

const uint8_t* feetech_writer_get_data ( const feetech_writer_t writer)

Get the data buffer to send.

Parameters
[out]writerthe packet writer
Returns
the beginning address of the buffer

◆ feetech_writer_get_size()

size_t feetech_writer_get_size ( const feetech_writer_t writer)

Get the data buffer's size to send.

Parameters
[out]writerthe packet writer
Returns
the buffer's size

◆ feetech_writer_init()

void feetech_writer_init ( feetech_writer_t writer,
uint8_t *  buffer,
size_t  buffer_max_size 
)

Initialize the Feetech packet writer.

Parameters
[out]writerthe packet writer
[in]bufferthe buffer used to store data
[in]buffer_max_sizethe size of the buffer (= maximum packet size)

◆ feetech_writer_ping_make()

void feetech_writer_ping_make ( feetech_writer_t writer,
uint8_t  id 
)

Build a PING packet.

Parameters
[out]writerthe packet writer
[in]idthe destination's id

◆ feetech_writer_read_make()

void feetech_writer_read_make ( feetech_writer_t writer,
uint8_t  id,
uint8_t  reg,
size_t  size 
)

Build a READ packet.

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]regthe register to read
[in]sizethe size to read

◆ feetech_writer_response_make()

void feetech_writer_response_make ( feetech_writer_t writer,
uint8_t  id,
const uint8_t *  buffer,
size_t  size 
)

Build a response packet.

Parameters
[out]writerthe packet writer
[in]idthe responder's id
[in]bufferthe response data
[in]sizethe response size

◆ feetech_writer_sync_write_add()

void feetech_writer_sync_write_add ( feetech_writer_t writer,
uint8_t  id,
const uint8_t *  buffer,
size_t  size 
)

Add an item to a SYNC_WRITE packet.

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]bufferthe data buffer to write
[in]sizethe data buffer's size

◆ feetech_writer_sync_write_add_16bits()

void feetech_writer_sync_write_add_16bits ( feetech_writer_t writer,
uint8_t  id,
uint16_t  value 
)

Add an item to a SYNC_WRITE packet (16 bits)

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]valuethe value to write

◆ feetech_writer_sync_write_add_8bits()

void feetech_writer_sync_write_add_8bits ( feetech_writer_t writer,
uint8_t  id,
uint8_t  value 
)

Add an item to a SYNC_WRITE packet (8 bits)

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]valuethe value to write

◆ feetech_writer_sync_write_begin()

void feetech_writer_sync_write_begin ( feetech_writer_t writer,
uint8_t  reg,
size_t  size 
)

Begin to build a SYNC_WRITE packet.

Parameters
[out]writerthe packet writer
[in]regthe register to write in
[in]sizethe data buffer's size

◆ feetech_writer_sync_write_end()

void feetech_writer_sync_write_end ( feetech_writer_t writer)

End the building of a SYNC_WRITE packet.

Parameters
[out]writerthe packet writer

◆ feetech_writer_write16_make()

void feetech_writer_write16_make ( feetech_writer_t writer,
uint8_t  id,
uint8_t  reg,
uint16_t  value 
)

Build a WRITE packet (16 bits)

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]regthe register to write in
[in]valuethe value to write in the register

◆ feetech_writer_write8_make()

void feetech_writer_write8_make ( feetech_writer_t writer,
uint8_t  id,
uint8_t  reg,
uint8_t  value 
)

Build a WRITE packet (8 bits)

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]regthe register to write in
[in]valuethe value to write in the register

◆ feetech_writer_write_make()

void feetech_writer_write_make ( feetech_writer_t writer,
uint8_t  id,
uint8_t  reg,
const uint8_t *  buffer,
size_t  size 
)

Build a WRITE packet.

Parameters
[out]writerthe packet writer
[in]idthe destination's id
[in]regthe register to write in
[in]bufferthe data buffer to write
[in]sizethe data buffer's size