43     if (msg->
talker[0] == 
'P') {
 
   60         for (
int ri = 0; ri < msg->
rawlen; ri++) {
 
   88     if (msg->
checksum == a) { 
return true; }
 
  102     if (msg->
talker[0] == 
'P') {
 
  131     outarray[ix++] = msg->
talker[0];
 
  132     outarray[ix++] = msg->
talker[1];
 
  133     if (msg->
talker[0] == 
'P') {
 
  134         outarray[ix++] = msg->
talker[2];
 
  135         outarray[ix++] = msg->
talker[3];
 
  137     outarray[ix++] = msg->
message[0];
 
  138     outarray[ix++] = msg->
message[1];
 
  139     outarray[ix++] = msg->
message[2];
 
  142             outarray[ix++] = 
',';
 
  148         outarray[ix++] = 
',';
 
  149         for (
int ri = 0; ri < msg->
rawlen; ri++) {
 
  150             outarray[ix++] = msg->
raw[ri];
 
  155     const char *hd = 
"0123456789ABCDEF";
 
  156     outarray[ix++] = hd[(msg->
checksum >> 8) & 0xF];
 
  157     outarray[ix++] = hd[msg->
checksum & 0xF];
 
  177     str = realloc(str, s + 1);
 
  204     const uint8_t *fields[80] = {0};
 
  205     int lengths[80] = {0};
 
  207     const uint8_t *sp = nmsg->
raw;
 
  208     for (
int fp = 0; fp < nmsg->
rawlen; fp++) {
 
  209         if ((nmsg->
raw[fp] == 
',') || (nmsg->
raw[fp] == 0)) {
 
  211             lengths[fc] = &(nmsg->
raw[fp]) - sp;
 
  213             sp = &(nmsg->
raw[fp + 1]);
 
  217     lengths[fc] = &(nmsg->
raw[nmsg->
rawlen]) - sp;
 
  221     if (sa == NULL) { 
return false; }
 
  222     for (
int fn = 0; fn < fc; fn++) {
 
  241     const char *tk = 
"II";
 
  242     const char *mt = 
"ZDA";
 
  243     if ((strncmp(msg->
talker, tk, 2) != 0) || (strncmp(msg->
message, mt, 3) != 0)) { 
return NULL; }
 
  245     if (sa == NULL) { 
return NULL; }
 
  271     struct tm *tout = calloc(1, 
sizeof(
struct tm));
 
  281         if (errno || day < 0 || day > 31) {
 
  292         if (errno || mon < 0 || mon > 12) {
 
  298         tout->tm_mon = mon - 1; 
 
  306         if (errno || year < 1970 || year > 2100) {
 
  312         tout->tm_year = year - 1900;
 
  323     if (mktime(tout) == (time_t)(-1)) {
 
  333         if (errno || time < 0 || time > 235960) {
 
  339         tout->tm_hour = time / 10000;
 
  340         tout->tm_min = (time % 10000) / 100;
 
  341         tout->tm_sec = (time % 100);
 
  352         if (errno || tzhours < -13 || tzhours > 13 || tzmins < -60 || tzmins > 60) {
 
  359         tout->tm_gmtoff = 3600 * tzhours + 60 * tzmins;
 
#define NMEA_CSUM_MARK
NMEA Checksum Delimiter.
 
#define NMEA_START_BYTE2
NMEA Start Byte 2.
 
#define NMEA_START_BYTE1
NMEA0183 Start Byte 1.
 
size_t nmea_message_length(const nmea_msg_t *msg)
Calculate number of bytes required to represent message.
 
struct tm * nmea_parse_zda(const nmea_msg_t *msg)
Get date/time from NMEA ZDA message.
 
void nmea_print_hex(const nmea_msg_t *msg)
Print NMEA message.
 
char * nmea_string_hex(const nmea_msg_t *msg)
Return NMEA message as string.
 
void nmea_calc_checksum(const nmea_msg_t *msg, uint8_t *cs)
Calculate checksum for NMEA message.
 
size_t nmea_flat_array(const nmea_msg_t *msg, char **out)
Convert NMEA message to array of bytes for transmission.
 
void nmea_set_checksum(nmea_msg_t *msg)
Set checksum bytes for NMEA message.
 
strarray * nmea_parse_fields(const nmea_msg_t *nmsg)
Parse raw data into fields.
 
bool nmea_check_checksum(const nmea_msg_t *msg)
Verify checksum bytes of NMEA message.
 
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.
 
Generic NMEA message structure.
 
strarray fields
If parsed, array of fields.
 
bool encapsulated
Encapsulated message (all data in raw)
 
uint8_t checksum
Message Checksum.
 
char message[3]
Message ID.
 
char talker[4]
Talker ID (2-4 characters)
 
uint8_t rawlen
Length of data stored in raw.
 
int entries
Maximum number of strings in array, set when calling sa_new()
 
string * strings
Simple array of string structures.
 
char * data
Character array, should be null terminated.
 
size_t length
This should include a terminating null byte where possible.