SELKIELogger
1.0.0
|
Go to the source code of this file.
Macros | |
#define | LPMS_BUFF 1024 |
Default serial buffer allocation size. | |
Functions | |
int | lpms_openConnection (const char *device, const int baud) |
Open connection to an LPMS serial device. More... | |
void | lpms_closeConnection (int handle) |
Close LPMS serial connection. More... | |
bool | lpms_readMessage (int handle, lpms_message *out) |
Static wrapper around lpms_readMessage_buf. More... | |
bool | lpms_readMessage_buf (int handle, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw) |
Read data from handle, and parse message if able. More... | |
bool | lpms_find_messages (int handle, size_t numtypes, const uint8_t types[], int timeout, lpms_message *out, uint8_t buf[LPMS_BUFF], size_t *index, size_t *hw) |
Read data from handle until first of specified message types is found. More... | |
bool | lpms_send_command (const int handle, lpms_message *m) |
Write command defined by structure to handle. | |
bool | lpms_send_command_mode (const int handle) |
Shortcut: Send LPMS_MSG_MODE_CMD. | |
bool | lpms_send_stream_mode (const int handle) |
Shortcut: Send LPMS_MSG_MODE_STREAM. | |
bool | lpms_send_get_config (const int handle) |
Shortcut: Send LPMS_MSG_GET_OUTPUTS. | |
LPMS connection handling
Definition in file LPMSConnection.h.
void lpms_closeConnection | ( | int | handle | ) |
Close LPMS serial connection.
[in] | handle | File handle from lpms_openConnection() |
Definition at line 48 of file LPMSConnection.c.
bool lpms_find_messages | ( | int | handle, |
size_t | numtypes, | ||
const uint8_t | types[], | ||
int | timeout, | ||
lpms_message * | out, | ||
uint8_t | buf[LPMS_BUFF], | ||
size_t * | index, | ||
size_t * | hw | ||
) |
Read data from handle until first of specified message types is found.
Read messages from serial data and discard them until a message matching one of the provided types is seen, or a timeout is reached.
Uses lpms_readMessage_buf() internally, and can make use of the same buffer if the same buf
, index
, and hw
parameters are passed in.
[in] | handle | File descriptor from lpms_openConnection() |
[in] | numtypes | Number of entries in types[] |
[in] | types | Array of message/commands to match. |
[in] | timeout | Number of seconds to wait for matching message |
[out] | out | Pointer to message structure to fill with data |
[in,out] | buf | Serial data buffer |
[in,out] | index | Current search position within buf |
[in,out] | hw | End of current valid data in buf |
Definition at line 157 of file LPMSConnection.c.
int lpms_openConnection | ( | const char * | device, |
const int | baud | ||
) |
Open connection to an LPMS serial device.
Delegates to openSerialConnection() to open the serial device.
[in] | device | Path to device to open |
[in] | baud | Baud rate to connect with (as integer) |
Definition at line 40 of file LPMSConnection.c.
bool lpms_readMessage | ( | int | handle, |
lpms_message * | out | ||
) |
Static wrapper around lpms_readMessage_buf.
For single threaded development and testing, uses static variables rather than requiring state to be tracked by caller.
See lpms_readMessage_buf() for full description.
[in] | handle | File descriptor from lpms_openConnection() |
[out] | out | Pointer to message structure to fill with data |
Definition at line 63 of file LPMSConnection.c.
bool lpms_readMessage_buf | ( | int | handle, |
lpms_message * | out, | ||
uint8_t | buf[LPMS_BUFF], | ||
size_t * | index, | ||
size_t * | hw | ||
) |
Read data from handle, and parse message if able.
Pulls data from handle
and stores it in buf
, tracking the current search position in index
and the current fill level/buffer high water mark in hw
If a valid message is found then it is written to the structure provided as a parameter and the function returns true.
If a message cannot be read, the function returns false
[in] | handle | File descriptor from lpms_openConnection() |
[out] | out | Pointer to message structure to fill with data |
[in,out] | buf | Serial data buffer |
[in,out] | index | Current search position within buf |
[in,out] | hw | End of current valid data in buf |
Definition at line 87 of file LPMSConnection.c.