SELKIELogger  1.0.0
NMEA Message support functions
Collaboration diagram for NMEA Message support functions:

Functions

void nmea_calc_checksum (const nmea_msg_t *msg, uint8_t *cs)
 Calculate checksum for NMEA message. More...
 
void nmea_set_checksum (nmea_msg_t *msg)
 Set checksum bytes for NMEA message. More...
 
bool nmea_check_checksum (const nmea_msg_t *msg)
 Verify checksum bytes of NMEA message. More...
 
size_t nmea_message_length (const nmea_msg_t *msg)
 Calculate number of bytes required to represent message. More...
 
size_t nmea_flat_array (const nmea_msg_t *msg, char **out)
 Convert NMEA message to array of bytes for transmission. More...
 
char * nmea_string_hex (const nmea_msg_t *msg)
 Return NMEA message as string. More...
 
void nmea_print_hex (const nmea_msg_t *msg)
 Print NMEA message. More...
 
strarraynmea_parse_fields (const nmea_msg_t *nmsg)
 Parse raw data into fields. More...
 
struct tm * nmea_parse_zda (const nmea_msg_t *msg)
 Get date/time from NMEA ZDA message. More...
 

Detailed Description

Convert and verify NMEA protocol messages

Function Documentation

◆ nmea_calc_checksum()

void nmea_calc_checksum ( const nmea_msg_t msg,
uint8_t *  cs 
)

Calculate checksum for NMEA message.

Calculates the checksum for an NMEA0183 style message

Parameters
[in]msgInput message
[out]csChecksum byte

Definition at line 37 of file NMEAMessages.c.

◆ nmea_check_checksum()

bool nmea_check_checksum ( const nmea_msg_t msg)

Verify checksum bytes of NMEA message.

Calculates checksum with nmea_calc_checksum() and compares to checksumstored in the provided message.

Parameters
[in]msgInput message
Returns
Checksum validity (true/false)

Definition at line 85 of file NMEAMessages.c.

◆ nmea_flat_array()

size_t nmea_flat_array ( const nmea_msg_t msg,
char **  out 
)

Convert NMEA message to array of bytes for transmission.

Allocates a new array of bytes and copies message into array in transmission order (e.g. out[0] to be sent first). Note that this will include a trailing CRLF pair!

Output array must be freed by caller.

Parameters
[in]msgInput message
[out]outBase address of output array
Returns
Size of output array

Definition at line 127 of file NMEAMessages.c.

◆ nmea_message_length()

size_t nmea_message_length ( const nmea_msg_t msg)

Calculate number of bytes required to represent message.

Calculate the number of bytes/characters required to represent or transmit an NMEA message

Parameters
[in]msgPointer to NMEA message structure
Returns
Bytes required

Definition at line 99 of file NMEAMessages.c.

◆ nmea_parse_fields()

strarray* nmea_parse_fields ( const nmea_msg_t nmsg)

Parse raw data into fields.

Parses fields from raw into a string array

Parameters
[in]nmsgPointer to NMEA message
Returns
Pointer to string array (NULL on failure)

Definition at line 203 of file NMEAMessages.c.

◆ nmea_parse_zda()

struct tm* nmea_parse_zda ( const nmea_msg_t msg)

Get date/time from NMEA ZDA message.

Converts time encoded in message to a libc struct tm representation

Caller to free returned structure

Parameters
[in]msgInput message
Returns
Pointer to struct tm, or NULL on failure

Definition at line 240 of file NMEAMessages.c.

◆ nmea_print_hex()

void nmea_print_hex ( const nmea_msg_t msg)

Print NMEA message.

Primarily for debug purposes. Will print string generated by nmea_string_hex() to stdout.

Parameters
[in]*msgInput message

Definition at line 188 of file NMEAMessages.c.

◆ nmea_set_checksum()

void nmea_set_checksum ( nmea_msg_t msg)

Set checksum bytes for NMEA message.

Simple wrapper around nmea_calc_checksum() to update the checksum bytes within the structure.

Parameters
[in,out]msgMessage to update

Definition at line 74 of file NMEAMessages.c.

◆ nmea_string_hex()

char* nmea_string_hex ( const nmea_msg_t msg)

Return NMEA message as string.

Allocates a character array and fills with hexadecimal character pairs representing the message content.

As we're dealing with ASCII anyway, this just wraps nmea_flat_array and adds a null terminator

Character array must be freed by caller.

Parameters
[in]msgInput message
Returns
Pointer to character array

Definition at line 174 of file NMEAMessages.c.