SELKIELogger  1.0.0
NMEA Device communication
Collaboration diagram for NMEA Device communication:

Modules

 NMEA Message support functions
 

Files

file  NMEAMessages.h
 
file  NMEASerial.h
 
file  NMEATypes.h
 

Classes

struct  nmea_msg_t
 Generic NMEA message structure. More...
 

Macros

#define NMEA_SERIAL_BUFF   1024
 Default serial buffer allocation size.
 
#define NMEA_START_BYTE1   0x24
 NMEA0183 Start Byte 1.
 
#define NMEA_START_BYTE2   0x21
 NMEA Start Byte 2.
 
#define NMEA_CSUM_MARK   0x2a
 NMEA Checksum Delimiter.
 
#define NMEA_END_BYTE1   0x0d
 NMEA End Byte 1: Carriage Return.
 
#define NMEA_END_BYTE2   0x0a
 NMEA End Byte 1: Line Feed.
 

Functions

int nmea_openConnection (const char *port, const int baudRate)
 Set up a connection to the specified port. More...
 
void nmea_closeConnection (int handle)
 Close existing connection. More...
 
bool nmea_readMessage (int handle, nmea_msg_t *out)
 Static wrapper around mp_readMessage_buf. More...
 
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. More...
 
bool nmea_writeMessage (int handle, const nmea_msg_t *out)
 Send message to attached device. More...
 

Detailed Description

Function Documentation

◆ nmea_closeConnection()

void nmea_closeConnection ( int  handle)

Close existing connection.

Currently just closes the file descriptor passed as handle

Parameters
[in]handleFile descriptor opened with nmea_openConnection()

Definition at line 52 of file NMEASerial.c.

◆ nmea_openConnection()

int nmea_openConnection ( const char *  port,
const int  baudRate 
)

Set up a connection to the specified port.

Currently just wraps openSerialConnection()

Parameters
[in]portTarget character device (i.e. Serial port)
[in]baudRateTarget baud rate
Returns
Return value of openSerialConnection()

Definition at line 43 of file NMEASerial.c.

◆ nmea_readMessage()

bool nmea_readMessage ( int  handle,
nmea_msg_t out 
)

Static wrapper around mp_readMessage_buf.

For single threaded development and testing, uses static variables rather than requiring state to be tracked by caller.

See nmea_readMessage_buf() for full description.

Parameters
[in]handleFile descriptor from nmea_openConnection()
[out]outPointer to message structure to fill with data
Returns
True if out now contains a valid message, false otherwise.

Definition at line 66 of file NMEASerial.c.

◆ nmea_readMessage_buf()

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.

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 and the first byte of the raw array is set to an error value:

  • 0xFF means no message found yet, and more data is required
  • 0xFD is a synonym for 0xFF, but indicates that zero bytes were read from source. This could indicate EOF if reading from file, but can be ignored when streaming from a device.
  • 0xAA means that an error occurred reading in data
  • 0XEE means a valid message header was found, but no valid message
Parameters
[in]handleFile descriptor from nmea_openConnection()
[out]outPointer to message structure to fill with data
[in,out]bufSerial data buffer
[in,out]indexCurrent search position within buf
[in,out]hwEnd of current valid data in buf
Returns
True if out now contains a valid message, false otherwise.

Definition at line 98 of file NMEASerial.c.

◆ nmea_writeMessage()

bool nmea_writeMessage ( int  handle,
const nmea_msg_t out 
)

Send message to attached device.

Takes a message, validates the checksum and writes it out to the device or file connected to handle.

Parameters
[in]handleFile descriptor from nmea_openConnection()
[in]outPointer to message structure to be sent.
Returns
True if data successfullt written to handle

Definition at line 318 of file NMEASerial.c.