SELKIELogger
1.0.0
|
Modules | |
UBX Commands | |
UBX Message handling | |
Files | |
file | GPSCommands.h |
file | GPSMessages.h |
file | GPSSerial.h |
file | GPSTypes.h |
Classes | |
struct | ubx_message |
Internal representation of a UBX message. More... | |
struct | ubx_message_name |
UBX Message descriptions. More... | |
struct | ubx_nav_pvt |
Represent decoded NAV-PVT message. More... | |
Macros | |
#define | UBX_SERIAL_BUFF 4096 |
Serial buffer size. | |
#define | UBX_SYNC_BYTE1 0xB5 |
UBX Serial synchronisation byte 1. More... | |
#define | UBX_SYNC_BYTE2 0x62 |
UBX Serial synchronisation byte 2. More... | |
Typedefs | |
typedef enum ubx_class | ubx_class |
UBX Message class ID bytes. | |
typedef struct ubx_message | ubx_message |
Internal representation of a UBX message. More... | |
typedef struct ubx_message_name | ubx_message_name |
UBX Message descriptions. | |
typedef struct ubx_nav_pvt | ubx_nav_pvt |
Represent decoded NAV-PVT message. | |
Enumerations | |
enum | ubx_class { UBXNAV = 0x01 , UBXRXM = 0x02 , UBXINF = 0x04 , UBXACK = 0x05 , UBXCFG = 0x06 , UBXUPD = 0x09 , UBXMON = 0x0A , UBXAID = 0x0B , UBXTIM = 0x0D , UBXESF = 0x10 , UBXMGA = 0x13 , UBXLOG = 0x21 , UBXSEC = 0x27 , UBXHNR = 0x28 } |
UBX Message class ID bytes. | |
Functions | |
int | ubx_openConnection (const char *port, const int initialBaud) |
Set up a connection to a UBlox module on a given port. More... | |
void | ubx_closeConnection (int handle) |
Close a connection opened with ubx_openConnection() More... | |
bool | ubx_readMessage (int handle, ubx_message *out) |
Static wrapper around ubx_readMessage_buf() More... | |
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. More... | |
bool | ubx_waitForMessage (const int handle, const uint8_t msgClass, const uint8_t msgID, const int maxDelay, ubx_message *out) |
Read (and discard) messages until required message seen or timeout reached. More... | |
bool | ubx_writeMessage (int handle, const ubx_message *out) |
Send message to attached device. More... | |
#define UBX_SYNC_BYTE1 0xB5 |
UBX Serial synchronisation byte 1.
0xB5 as defined in UBlox documentation.
Represents the UTF-8 ยต glyph
Definition at line 43 of file GPSTypes.h.
#define UBX_SYNC_BYTE2 0x62 |
UBX Serial synchronisation byte 2.
Defined as 0x62 in UBlox documentation. Represents a b in ASCII or UTF-8.
Definition at line 50 of file GPSTypes.h.
typedef struct ubx_message ubx_message |
Internal representation of a UBX message.
All messages must start with two sync bytes: 0xB5 0x62
Short messages are stored in the data array, larger messages will be stored at the location pointed to by the extdata member.
If extdata is set, it must be explicitly freed when message is disposed of.
void ubx_closeConnection | ( | int | handle | ) |
Close a connection opened with ubx_openConnection()
Currently just closes the handle, but could deconfigure and reset the module or put it into a power saving mode in future.
[in] | handle | File descriptor from ubx_openConnection() |
Definition at line 111 of file GPSSerial.c.
int ubx_openConnection | ( | const char * | port, |
const int | initialBaud | ||
) |
Set up a connection to a UBlox module on a given port.
Uses openSerialConnection() from the base library to open an initial connection, then sends UBX commands to configure the module for 115200 baud UBX output.
If the module was already operating at 115200 then it will stop listening to serial commands when we transmit at the wrong rate, so this function will sleep for 1 second before configuring the protocols again.
[in] | port | Path to character device connected to UBlox module |
[in] | initialBaud | Initial baud rate for connection. Usually 9600, but may vary. |
Definition at line 51 of file GPSSerial.c.
bool ubx_readMessage | ( | int | handle, |
ubx_message * | out | ||
) |
Static wrapper around ubx_readMessage_buf()
For single threaded development and testing, uses static variables rather than requiring state to be tracked by caller.
See ubx_readMessage_buf() for full description.
[in] | handle | File descriptor from ubx_openConnection() |
[out] | out | Pointer to message structure to fill with data |
Definition at line 125 of file GPSSerial.c.
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.
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
The source handle can be anything supported by read(), but would usually be a file or a serial port.
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 and the sync1
field is set to an error value:
[in] | handle | File descriptor from ubx_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 158 of file GPSSerial.c.
bool ubx_waitForMessage | ( | const int | handle, |
const uint8_t | msgClass, | ||
const uint8_t | msgID, | ||
const int | maxDelay, | ||
ubx_message * | out | ||
) |
Read (and discard) messages until required message seen or timeout reached.
Messages are read with ubx_readMessage() and discarded until either a message matches the supplied message class and ID values or the maximum delay time is reached.
Note that the function exits as soon as the time specified by maxDelay
is exceeded. The maximum delay specified in this function is 50us, but no guarantees are given regarding time spent reading in messages.
[in] | handle | File descriptor from ubx_openConnection() |
[in] | msgClass | Message class to wait for |
[in] | msgID | Message ID/Type to wait for |
[in] | maxDelay | Timeout in seconds. |
[out] | out | Pointer to message structure to fill with data |
Definition at line 276 of file GPSSerial.c.
bool ubx_writeMessage | ( | int | handle, |
const ubx_message * | out | ||
) |
Send message to attached device.
Takes a ubx_message, validates the checksum and sync bytes and writes data to the device or file connected to handle
.
[in] | handle | File descriptor from ubx_openConnection() |
[in] | out | Pointer to message structure to be sent. |
handle
Definition at line 298 of file GPSSerial.c.