SELKIELogger  1.0.0
Internal message format and functions
Collaboration diagram for Internal message format and functions:

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_tmsg_new_float (const uint8_t source, const uint8_t type, const float val)
 Create new message with a single numeric value. More...
 
msg_tmsg_new_timestamp (const uint8_t source, const uint8_t type, const uint32_t ts)
 Create a timestamp message. More...
 
msg_tmsg_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_tmsg_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_tmsg_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_tmsg_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...
 

Detailed Description

Enumeration Type Documentation

◆ 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.

See also
string
MSG_STRARRAY 

Array of strings.

See also
strarray
MSG_NUMARRAY 

Array of floating point values.

Definition at line 55 of file messages.h.

Function Documentation

◆ msg_data_narr_to_string()

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.

Parameters
[in]msgMessage containing data to be represented
Returns
Pointer to string, or NULL

Definition at line 280 of file messages.c.

◆ msg_data_sarr_to_string()

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.

Parameters
[in]msgMessage containing data to be represented
Returns
Pointer to string, or NULL

Definition at line 310 of file messages.c.

◆ msg_data_to_string()

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.

Parameters
[in]msgMessage containing data to be represented
Returns
Pointer to string, or NULL

Definition at line 222 of file messages.c.

◆ msg_destroy()

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.

Parameters
[in]msgMessage to be destroyed

Definition at line 349 of file messages.c.

◆ msg_new_bytes()

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]lenLength of array to be copied
[in]bytesPointer to existing array of uint8_t
Returns
Pointer to new message, NULL on failure

Definition at line 147 of file messages.c.

◆ msg_new_float()

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]valGeneral numeric value, represented as single precision float
Returns
Pointer to new message

Definition at line 38 of file messages.c.

◆ msg_new_float_array()

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]entriesNumber of entries in array
[in]arrayPointer to array of floats
Returns
Pointer to new message

Definition at line 176 of file messages.c.

◆ msg_new_string()

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]lenMaximum length of character array
[in]strPointer to character array
Returns
Pointer to new message, NULL on failure

Definition at line 84 of file messages.c.

◆ msg_new_string_array()

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.

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]arrayPointer to existing string array
Returns
Pointer to new message, NULL on failure

Definition at line 116 of file messages.c.

◆ msg_new_timestamp()

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.

Parameters
[in]sourceMessage source
[in]typeMessage type
[in]tsTimestamp, assumed to be milliseconds from an arbitrary epoch
Returns
Pointer to new message

Definition at line 57 of file messages.c.

◆ msg_to_string()

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.

Parameters
[in]msgMessage to be represented
Returns
Pointer to string, or NULL

Definition at line 201 of file messages.c.