69 uint8_t *buf = calloc(
N2K_BUFF,
sizeof(uint8_t));
77 if (out.
PGN == 129025) {
86 "[N2K:%s] Error pushing message to queue",
98 "[N2K:%s] Error pushing message to queue",
107 "[N2K:%s] Failed to decode message (PGN %d, Source %d)",
117 "[N2K:%s] Unable to serialise message (PGN %d, Source %d)",
119 if (rd) { free(rd); }
126 "[N2K:%s] Error pushing message to queue",
149 "[N2K:%s] Error signalled from n2k_readMessage_buf",
164 if (n2k_hw == 1024 && n2k_index == 0) {
185 if (n2kInfo->
handle >= 0) {
279 log_error(lta->
pstate,
"[N2K:%s] Unable to allocate memory for device parameters",
312 int sn = strtol(t->
value, NULL, 0);
315 lta->
tag, strerror(errno));
332 "[N2K:%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.
#define N2K_BUFF
Default serial buffer allocation size.
void n2k_closeConnection(int handle)
Close N2K serial connection.
int n2k_openConnection(const char *device, const int baud)
Open connection to an N2K serial device.
bool n2k_act_readMessage_buf(int handle, n2k_act_message *out, uint8_t buf[N2K_BUFF], size_t *index, size_t *hw)
Read data from handle, and parse message if able.
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_float(const uint8_t source, const uint8_t type, const float val)
Create new message with a single numeric value.
bool n2k_129025_values(const n2k_act_message *n, double *lat, double *lon)
Extract values from PGN 129025: Device position.
bool n2k_act_to_bytes(const n2k_act_message *act, uint8_t **out, size_t *len)
Convert N2K message to a series of bytes compatible with ACT gateway devices.
#define SLCHAN_MAP
Channel name map (excludes log channels)
#define SLCHAN_NAME
Name of source device.
#define N2KCHAN_RAW
Raw data (recorded unmodified)
bool n2k_parseConfig(log_thread_args_t *lta, config_section *s)
Take a configuration section and parse parameters.
void * n2k_channels(void *ptargs)
N2K Channel map.
void * n2k_setup(void *ptargs)
N2K Setup.
#define N2KCHAN_NAME
Source name.
#define N2KCHAN_MAP
Channel map.
#define N2KCHAN_LON
Longitude (from GPS)
void * n2k_shutdown(void *ptargs)
N2K Shutdown.
n2k_params n2k_getParams()
Fill out default N2K parameters.
void * n2k_logging(void *ptargs)
N2K logging (with pthread function signature)
#define N2KCHAN_LAT
Latitude (from GPS)
device_callbacks n2k_getCallbacks()
Fill out device callback functions for logging.
#define N2KCHAN_TSTAMP
Timestamps.
#define SLSOURCE_N2K
N2K 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.
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)
uint8_t priority
N2K Message priority value.
uint32_t PGN
24 bit PGN identifier
uint8_t * data
Message payload.
uint8_t src
Message source.
N2K Device specific parameters.
char * portName
Target port name.
uint8_t sourceNum
Source ID for messages.
char * sourceName
User defined name for this source.
int baudRate
Baud rate for operations.
int handle
Handle for currently opened device.