39 if (nmeaInfo->
handle < 0) {
77 if ((strncmp(out.
talker,
"II", 2) == 0) &&
78 (strncmp(out.
message,
"ZDA", 3) == 0)) {
81 time_t epoch = mktime(t) - t->tm_gmtoff;
82 if (epoch != (time_t)(-1)) {
89 "[NMEA:%s] Error pushing message to queue",
105 "[NMEA:%s] Error pushing message to queue",
120 if (!(out.
raw[0] == 0xFF || out.
raw[0] == 0xFD || out.
raw[0] == 0xEE)) {
131 "[NMEA:%s] Error signalled from nmea_readMessage_buf",
163 if (nmeaInfo->
handle >= 0) {
194 log_error(args->
pstate,
"[NMEA:%s] Error pushing channel name to queue",
257 log_error(lta->
pstate,
"[NMEA:%s] Unable to allocate memory for device parameters",
290 int sn = strtol(t->
value, NULL, 0);
293 lta->
tag, strerror(errno));
310 "[NMEA:%s] Unexpected Source ID number (0x%02x)- this may cause analysis problems",
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_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.
msg_t * msg_new_timestamp(const uint8_t source, const uint8_t type, const uint32_t ts)
Create a timestamp message.
bool nmea_readMessage_buf(int handle, nmea_msg_t *out, uint8_t buf[NMEA_SERIAL_BUFF], int *index, int *hw)
Read data from handle, and parse message if able.
int nmea_openConnection(const char *port, const int baudRate)
Set up a connection to the specified port.
void nmea_closeConnection(int handle)
Close existing connection.
#define NMEA_SERIAL_BUFF
Default serial buffer allocation size.
#define SLCHAN_TSTAMP
Source timestamp (milliseconds, arbitrary epoch)
#define SLCHAN_RAW
Raw device data (Not mandatory)
#define SLCHAN_MAP
Channel name map (excludes log channels)
#define SLCHAN_NAME
Name of source device.
void * nmea_shutdown(void *ptargs)
NMEA Shutdown.
void * nmea_logging(void *ptargs)
NMEA logging (with pthread function signature)
device_callbacks nmea_getCallbacks()
Fill out device callback functions for logging.
void * nmea_channels(void *ptargs)
NMEA Channel map.
nmea_params nmea_getParams()
Fill out default NMEA parameters.
bool nmea_parseConfig(log_thread_args_t *lta, config_section *s)
Take a configuration section and parse parameters.
void * nmea_setup(void *ptargs)
NMEA Setup.
#define SLSOURCE_NMEA
NMEA Bus.
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.
struct tm * nmea_parse_zda(const nmea_msg_t *msg)
Get date/time from NMEA ZDA message.
size_t nmea_flat_array(const nmea_msg_t *msg, char **out)
Convert NMEA message to array of bytes for transmission.
bool queue_push(msgqueue *queue, msg_t *msg)
Add a message to the tail of the queue.
void sa_destroy(strarray *sa)
Destroy array and contents.
strarray * sa_new(int entries)
Allocate storage for a new array.
bool sa_create_entry(strarray *array, const int index, const size_t len, const char *src)
Create an string in a given position from a character array and length.
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)
Generic NMEA message structure.
strarray fields
If parsed, array of fields.
char message[3]
Message ID.
char talker[4]
Talker ID (2-4 characters)
NMEA Device specific parameters.
uint8_t sourceNum
Source ID for messages.
char * sourceName
User defined name for this source.
int handle
Handle for currently opened device.
char * portName
Target port name.
int baudRate
Baud rate for operations.