MIP_SDK
latest-2-g34f3e39
MicroStrain Communications Library for embedded systems
|
#include "serialization.h"
Macros | |
#define | INSERT_MACRO(name, type) |
#define | EXTRACT_MACRO(name, type) |
Functions | |
void | microstrain_serializer_init_insertion (microstrain_serializer *serializer, uint8_t *buffer, size_t buffer_size) |
Initialize a serialization struct for insertion into a buffer. More... | |
void | microstrain_serializer_init_extraction (microstrain_serializer *serializer, const uint8_t *buffer, size_t buffer_size) |
Initialize a serialization struct for extraction from a buffer. More... | |
size_t | microstrain_serializer_capacity (const microstrain_serializer *serializer) |
Determines the total length the buffer. More... | |
size_t | microstrain_serializer_length (const microstrain_serializer *serializer) |
Determines the length of the data in the buffer. More... | |
int | microstrain_serializer_remaining (const microstrain_serializer *serializer) |
Determines the difference between the length and buffer size. More... | |
bool | microstrain_serializer_is_ok (const microstrain_serializer *serializer) |
Determines if the data read/written is less than the buffer size. More... | |
bool | microstrain_serializer_is_complete (const microstrain_serializer *serializer) |
Determines if the number of remaining bytes is 0. More... | |
void | microstrain_extract_count (microstrain_serializer *serializer, uint8_t *count_out, uint8_t max_count) |
Similar to microstrain_extract_u8 but allows a maximum value to be specified. More... | |
#define EXTRACT_MACRO | ( | name, | |
type | |||
) |
#define INSERT_MACRO | ( | name, | |
type | |||
) |
void microstrain_extract_count | ( | microstrain_serializer * | serializer, |
uint8_t * | count_out, | ||
uint8_t | max_count | ||
) |
Similar to microstrain_extract_u8 but allows a maximum value to be specified.
If the maximum count would be exceeded, an error is generated which causes further extraction to fail.
serializer | |
count_out | The counter value read from the buffer. |
max_count | The maximum value of the counter. If the count exceeds this, it is set to 0 and the serializer is insert into an error state. |
size_t microstrain_serializer_capacity | ( | const microstrain_serializer * | serializer | ) |
Determines the total length the buffer.
serializer |
void microstrain_serializer_init_extraction | ( | microstrain_serializer * | serializer, |
const uint8_t * | buffer, | ||
size_t | buffer_size | ||
) |
Initialize a serialization struct for extraction from a buffer.
serializer | |
buffer | A pointer from which data will be read. |
buffer_size | Maximum number of bytes to be read from the buffer. |
void microstrain_serializer_init_insertion | ( | microstrain_serializer * | serializer, |
uint8_t * | buffer, | ||
size_t | buffer_size | ||
) |
Initialize a serialization struct for insertion into a buffer.
serializer | |
buffer | Buffer into which data will be written. Can be NULL if buffer_size==0. |
buffer_size | Size of the buffer. Data will not be written beyond this size. |
bool microstrain_serializer_is_complete | ( | const microstrain_serializer * | serializer | ) |
Determines if the number of remaining bytes is 0.
Use this to determine if the entire buffer has been extracted. It is not particularly useful for insertion.
serializer |
bool microstrain_serializer_is_ok | ( | const microstrain_serializer * | serializer | ) |
Determines if the data read/written is less than the buffer size.
If the application attempts to read or write beyond the end of the buffer (as defined by the buffer_size passed to the init function), the read or write will be a no-op but the offset will still be advanced. This allows the condition to be detected.
serializer |
size_t microstrain_serializer_length | ( | const microstrain_serializer * | serializer | ) |
Determines the length of the data in the buffer.
serializer | For insertion, returns how many bytes have been written. For extraction, returns how many bytes have been read. |
int microstrain_serializer_remaining | ( | const microstrain_serializer * | serializer | ) |
Determines the difference between the length and buffer size.
serializer | For insertion, returns how many unwritten bytes remain in the buffer. For extraction, returns how many bytes have not been read. |