83 "[MP:%s] Unexpected message type (0x%02x) for source name (Source ID: 0x{%02x})",
91 "[MP:%s] Received source ID (0x%02x) does not match cached value (0x%02x) - multiple devices on a single input not currently supported!",
105 "[MP:%s] Received source ID (0x%02x) does not match cached value (0x%02x) - multiple devices on a single input not currently supported!",
112 "[MP:%s] Error caching channel map", args->
tag);
134 "[MP:%s] Error signalled from mp_readMessage_buf",
172 if (mpInfo->
cname != NULL) {
210 if (mpInfo->
handle >= 0) {
258 log_error(lta->
pstate,
"[MP:%s] Unable to allocate memory for device parameters",
char * config_qstrdup(const char *c)
Duplicate string, stripping optional leading/trailing quote marks.
config_kv * config_get_key(const config_section *cs, const char *kn)
Find configugration key within specific section, by name.
void signalHandlersBlock(void)
Block signals that we have handlers for.
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.
void msg_destroy(msg_t *msg)
Destroy a message.
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.
@ MSG_ERROR
An error code is returned in data.value.
@ MSG_STRING
Single string.
int mp_openConnection(const char *port, const int baudRate)
Set up a connection to the specified port.
bool mp_readMessage_buf(int handle, msg_t *out, uint8_t buf[MP_SERIAL_BUFF], int *index, int *hw)
Read data from handle, and parse message if able.
#define MP_SERIAL_BUFF
Default serial buffer allocation size.
void mp_closeConnection(int handle)
Close existing connection.
#define SLCHAN_MAP
Channel name map (excludes log channels)
#define SLCHAN_NAME
Name of source device.
void * mp_logging(void *ptargs)
MP source main logging loop.
void * mp_shutdown(void *ptargs)
MP source shutdown.
void * mp_setup(void *ptargs)
MP connection setup.
device_callbacks mp_getCallbacks()
Fill out device callback functions for logging.
bool mp_parseConfig(log_thread_args_t *lta, config_section *s)
Take a configuration section and parse parameters.
mp_params mp_getParams()
Fill out default MP source parameters.
void * mp_channels(void *ptargs)
Push device information from cache to queue.
atomic_bool shutdownFlag
Trigger clean software shutdown.
#define SERIAL_SLEEP
Default serial wait time.
void log_info(const program_state *s, const int level, const char *format,...)
Output formatted information message at a given level.
void log_warning(const program_state *s, const char *format,...)
Output formatted warning message.
void log_error(const program_state *s, const char *format,...)
Output formatted error message.
bool queue_push(msgqueue *queue, msg_t *msg)
Add a message to the tail of the queue.
bool sa_copy(strarray *dst, const strarray *src)
Copy an array of strings from src to dst.
Represent a key=value pair.
char * value
Configuration item value.
Configuration file section.
Device specific function information.
device_fn startup
Called serially at startup, opens devices etc.
Logging thread information.
msgqueue * logQ
Main message queue. Pushed to by threads, consumed by main()
char * tag
Tag/source name for messages etc.
void * dParams
Device/Thread specific data.
program_state * pstate
Current program state, used for logging.
int returnCode
Thread return code (output)
MP Source device specific parameters.
int baudRate
Baud rate for operations (currently unused)
strarray cmap
Cache latest channel map.
int handle
Handle for currently opened device.
char * portName
Target port name.
uint8_t csource
Cache source ID.
char * cname
Cache latest device name.
msg_data_t data
Embedded data.
uint8_t type
Message type. Common types to be documented.
uint8_t source
Maps to a specific sensor unit or data source.
msg_dtype_t dtype
Embedded data type.
int entries
Maximum number of strings in array, set when calling sa_new()
char * data
Character array, should be null terminated.
string string
Single character array with length.
float value
Generic numerical data.
strarray names
Array of strings, intended for use to provide channel names.