SELKIELogger
1.0.0
|
Modules | |
Logger Source IDs | |
Logger Channel IDs | |
Classes | |
union | msg_data_t |
struct | msg_t |
Queuable message. More... | |
Enumerations | |
enum | msg_dtype_t { MSG_ERROR = -1 , MSG_UNDEF = 0 , MSG_FLOAT , MSG_TIMESTAMP , MSG_BYTES , MSG_STRING , MSG_STRARRAY , MSG_NUMARRAY } |
Each data type should map to an entry in the msg_data_t union. More... | |
Functions | |
msg_t * | msg_new_float (const uint8_t source, const uint8_t type, const float val) |
Create new message with a single numeric value. More... | |
msg_t * | msg_new_timestamp (const uint8_t source, const uint8_t type, const uint32_t ts) |
Create a timestamp message. More... | |
msg_t * | msg_new_string (const uint8_t source, const uint8_t type, const size_t len, const char *str) |
Create a new message with a single string embedded. More... | |
msg_t * | msg_new_string_array (const uint8_t source, const uint8_t type, const strarray *array) |
Create a new message containing an array of strings. More... | |
msg_t * | msg_new_bytes (const uint8_t source, const uint8_t type, const size_t len, const uint8_t *bytes) |
Create a new message containing raw binary data. More... | |
msg_t * | msg_new_float_array (const uint8_t source, const uint8_t type, const size_t entries, const float *array) |
Create a new message containing an array of floating point data. More... | |
char * | msg_to_string (const msg_t *msg) |
Generate string representation of message. More... | |
char * | msg_data_to_string (const msg_t *msg) |
Generate string representation of message data. More... | |
char * | msg_data_narr_to_string (const msg_t *msg) |
Convert numerical array to string. More... | |
char * | msg_data_sarr_to_string (const msg_t *msg) |
Represent string array as single string. More... | |
void | msg_destroy (msg_t *msg) |
Destroy a message. More... | |
enum msg_dtype_t |
Each data type should map to an entry in the msg_data_t union.
Enumerator | |
---|---|
MSG_ERROR | An error code is returned in data.value. |
MSG_UNDEF | Undefined/Uninitialised message. |
MSG_FLOAT | Generic numerical data. |
MSG_TIMESTAMP | Timestamp (milliseconds since defined epoch/event) |
MSG_BYTES | Raw binary data. |
MSG_STRING | Single string.
|
MSG_STRARRAY | Array of strings.
|
MSG_NUMARRAY | Array of floating point values. |
Definition at line 55 of file messages.h.
char* msg_data_narr_to_string | ( | const msg_t * | msg | ) |
Convert numerical array to string.
Generate string for numeric arrays
Each value in the array is separated by a forward slash (/), to avoid issues when using in CSV outputs.
Allocated character array must be freed by the caller.
[in] | msg | Message containing data to be represented |
Definition at line 280 of file messages.c.
char* msg_data_sarr_to_string | ( | const msg_t * | msg | ) |
Represent string array as single string.
Generate string for string arrays
Each value in the array is separated by a forward slash (/), to avoid issues when using in CSV outputs.
Allocated character array must be freed by the caller.
[in] | msg | Message containing data to be represented |
Definition at line 310 of file messages.c.
char* msg_data_to_string | ( | const msg_t * | msg | ) |
Generate string representation of message data.
Generate string representation of message data
Allocates a suitable character array, which must be freed by the caller.
[in] | msg | Message containing data to be represented |
Definition at line 222 of file messages.c.
void msg_destroy | ( | msg_t * | msg | ) |
Destroy a message.
Destroy a message, regardless of data type.
Note that this function does not free the message itself, only the data embedded within it.
[in] | msg | Message to be destroyed |
Definition at line 349 of file messages.c.
msg_t* msg_new_bytes | ( | const uint8_t | source, |
const uint8_t | type, | ||
const size_t | len, | ||
const uint8_t * | bytes | ||
) |
Create a new message containing raw binary data.
Allocates a new msg_t, copies in the source, type and values and sets the data type to MSG_BYTES
Intended for sending/receiving arbitrary binary data.
The length stored in the message structure is the only way to reliably determine how much information is embedded in it.
[in] | source | Message source |
[in] | type | Message type |
[in] | len | Length of array to be copied |
[in] | bytes | Pointer to existing array of uint8_t |
Definition at line 147 of file messages.c.
msg_t* msg_new_float | ( | const uint8_t | source, |
const uint8_t | type, | ||
const float | val | ||
) |
Create new message with a single numeric value.
Allocates a new msg_t, copies in the source, type and value and sets the data type to MSG_FLOAT.
[in] | source | Message source |
[in] | type | Message type |
[in] | val | General numeric value, represented as single precision float |
Definition at line 38 of file messages.c.
msg_t* msg_new_float_array | ( | const uint8_t | source, |
const uint8_t | type, | ||
const size_t | entries, | ||
const float * | array | ||
) |
Create a new message containing an array of floating point data.
Allocates a new msg_t, copies in the source, type and array and sets the data type to MSG_NUMARRAY
The original array can be freed by the caller after creating the message.
[in] | source | Message source |
[in] | type | Message type |
[in] | entries | Number of entries in array |
[in] | array | Pointer to array of floats |
Definition at line 176 of file messages.c.
msg_t* msg_new_string | ( | const uint8_t | source, |
const uint8_t | type, | ||
const size_t | len, | ||
const char * | str | ||
) |
Create a new message with a single string embedded.
Allocates a new msg_t, copies in the source, type and value and sets the data type to MSG_STRING
Intended for sending/receiving source/device names.
String is created with str_update()
The length value for a string message is redundant, and duplicates the value embedded in the string itself.
[in] | source | Message source |
[in] | type | Message type |
[in] | len | Maximum length of character array |
[in] | str | Pointer to character array |
Definition at line 84 of file messages.c.
Create a new message containing an array of strings.
Allocates a new msg_t, copies in the source, type and values and sets the data type to MSG_STRARRAY
Intended for sending/receiving channel names
String is copied with sa_copy()
The length value embedded in the message is set to the number of entries in the array. The length of the individual strings has to be extracted from the information in the array itself.
[in] | source | Message source |
[in] | type | Message type |
[in] | array | Pointer to existing string array |
Definition at line 116 of file messages.c.
msg_t* msg_new_timestamp | ( | const uint8_t | source, |
const uint8_t | type, | ||
const uint32_t | ts | ||
) |
Create a timestamp message.
Allocates a new msg_t, copies in the source, type and value and sets the data type to MSG_TIMESTAMP.
[in] | source | Message source |
[in] | type | Message type |
[in] | ts | Timestamp, assumed to be milliseconds from an arbitrary epoch |
Definition at line 57 of file messages.c.
char* msg_to_string | ( | const msg_t * | msg | ) |
Generate string representation of message.
Generate string representation of message.
Allocates a suitable character array, which must be freed by the caller.
[in] | msg | Message to be represented |
Definition at line 201 of file messages.c.