55 bool msgSuccess =
true;
135 uint8_t *data = NULL;
137 bool handled =
false;
140 uint32_t ts = out.
data[0] + (out.
data[1] << 8) +
141 (out.
data[2] << 16) + (out.
data[3] << 24);
146 "[GPS:%s] Error pushing message to queue",
158 "[GPS:%s] Unable to decode NAV-PVT message",
187 "[GPS:%s] Error pushing messages to queue",
198 if (!handled || gpsInfo->
dumpAll) {
202 "[GPS:%s] Error pushing message to queue",
227 "[GPS:%s] Error signalled from gps_readMessage_buf",
261 if (gpsInfo->
handle >= 0) {
341 .targetBaud = 115200,
360 log_error(lta->
pstate,
"[GPS:%s] Unable to allocate memory for device parameters",
398 lta->
tag, strerror(errno));
407 int sn = strtol(t->
value, NULL, 0);
410 lta->
tag, strerror(errno));
427 "[GPS:%s] Unexpected Source ID number (0x%02x)- this may cause analysis problems",
int config_parse_bool(const char *b)
Parse string to boolean.
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.
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.
bool ubx_readMessage_buf(int handle, ubx_message *out, uint8_t buf[UBX_SERIAL_BUFF], int *index, int *hw)
Read data from handle, and parse message if able.
#define UBX_SERIAL_BUFF
Serial buffer size.
int ubx_openConnection(const char *port, const int initialBaud)
Set up a connection to a UBlox module on a given port.
void ubx_closeConnection(int handle)
Close a connection opened with ubx_openConnection()
#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 * gps_channels(void *ptargs)
GPS Channel map.
void * gps_setup(void *ptargs)
GPS Setup.
void * gps_shutdown(void *ptargs)
GPS Shutdown.
device_callbacks gps_getCallbacks()
Fill out device callback functions for logging.
gps_params gps_getParams()
Fill out default GPS parameters.
bool gps_parseConfig(log_thread_args_t *lta, config_section *s)
Parse configuration section.
void * gps_logging(void *ptargs)
GPS logging (with pthread function signature)
#define SLSOURCE_GPS
GPS (or other satellite navigation) sources.
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.
bool ubx_pollMessage(const int handle, const uint8_t msgClass, const uint8_t msgID)
Request specific message by class and ID.
bool ubx_setI2CAddress(const int handle, const uint8_t addr)
Set I2C address.
bool ubx_setNavigationRate(const int handle, const uint16_t interval, const uint16_t outputRate)
Set UBX navigation calculation and reporting rate.
bool ubx_enableGalileo(const int handle)
Enable Galileo constellation use.
bool ubx_enableLogMessages(const int handle)
Enable log/information messages from GPS device.
bool ubx_setMessageRate(const int handle, const uint8_t msgClass, const uint8_t msgID, const uint8_t rate)
Send UBX rate command to enable/disable message types.
bool ubx_decode_nav_pvt(const ubx_message *msg, ubx_nav_pvt *out)
Decode UBX NAV-PVT message.
size_t ubx_flat_array(const ubx_message *msg, uint8_t **out)
Convert UBX message to flat array of bytes.
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.
GPS Device specific parameters.
int handle
Handle for currently opened device.
char * portName
Target port name.
bool dumpAll
Dump all GPS messages to output queue.
int targetBaud
Baud rate for operations (currently unused)
char * sourceName
User defined name for this GPS.
uint8_t sourceNum
Source ID for messages.
int initialBaud
Baud rate for initial configuration.
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)
Internal representation of a UBX message.
uint8_t sync1
Should always be 0xB5.
uint8_t data[256]
Data if length <= 256.
uint8_t msgClass
A value from ubx_class.
uint8_t msgID
Message ID byte.
Represent decoded NAV-PVT message.
int32_t downV
Velocity (Down, mm/s)
uint8_t second
Second (UTC)
uint8_t minute
Minute (UTC)
int32_t ASL
Height above mean sea level (?datum)
uint32_t accuracy
Estimated time accuracy (ns)
float latitude
WGS84 Latitude.
uint32_t vertAcc
Vertical accuracy estimate.
int32_t headingAcc
Heading accuracy estimate.
int32_t speedAcc
Speed/velocity accuracy estimate.
uint16_t year
Calendar year.
int32_t groundSpeed
Ground Speed (mm/s)
int32_t northV
Velocity (North, mm/s)
int32_t height
WGS84 Height.
uint32_t horizAcc
Horizontal accuracy estimate (mm)
float heading
Motion heading.
int32_t eastV
Velocity (East, mm/s)
int32_t nanosecond
+/- nanosecond (UTC)
uint8_t month
Calendar month.
float longitude
WGS84 Longitude.