|
TypeLenVal
|
Type-Length-Value (TLV) Data Serializer (Hardware-Agnostic) More...
#include <stdbool.h>#include <stdint.h>#include <string.h>#include <assert.h>Go to the source code of this file.
Data Structures | |
| struct | tlv_entry |
| struct | tlv_buf |
Macros | |
| #define | TLV_TAGLEN_SIZE (sizeof(tlv_tag_t) + sizeof(tlv_len_t)) |
Typedefs | |
| typedef uint8_t | tlv_tag_t |
| typedef uint8_t | tlv_len_t |
Functions | |
| static void | tlv_buf_init (struct tlv_buf *self, uint8_t *mem, const size_t cap) |
| static void | tlv_entry_init (struct tlv_entry *self, const uint8_t tag, const uint8_t len, void *val) |
| static bool | tlv_buf_push (struct tlv_buf *self, struct tlv_entry *entry) |
| static bool | tlv_buf_pop (struct tlv_buf *self, struct tlv_entry *entry) |
| static void | tlv_buf_reset_head (struct tlv_buf *self) |
| static void | tlv_buf_reset (struct tlv_buf *self) |
| static size_t | tlv_buf_get_occupied_mem_size (struct tlv_buf *self) |
| static size_t | tlv_buf_get_free_mem_size (struct tlv_buf *self) |
Type-Length-Value (TLV) Data Serializer (Hardware-Agnostic)
This file contains the software implementation of the TLV logic. The design is hardware-agnostic, requiring an external adaptation layer for hardware interaction.
Conventions: C89, Linux kernel style, MISRA, rule of 10, No hardware specific code, only generic C and some binding layer. Be extra specific about types.
Scientific units where posible at end of the names, for example:
Keep variables without units if they're unknown or not specified or hard to define with short notation.
Be free, be wise and take care of yourself! With best wishes and respect, furdog
| typedef uint8_t tlv_tag_t |
TLV tag data type
| typedef uint8_t tlv_len_t |
TLV len data type
|
static |
Initialize TLV buffer. Provide pointer to uint8_t memory to be used by TLV entries and buffer capacity in bytes
|
static |
Initialize TLV entry to be used by PUSH operation
Push(FIFO) tag, len and val to TLV buffer. Returns (bool) true on success
Pop(FIFO) entry from TLV buffer, which contains tag, len and val. Returns (bool) true on success
|
static |
Resets TLV buffer head, so tlv_buf_pop will read the same data again
|
static |
Resets TLV buffer to its initial state
|
static |
Get occupied memory size
|
static |
Get free(remaining) memory size