interface to NMEA parser More...
#include <stdint.h>
#include "gps-parser.h"
Go to the source code of this file.
Data Structures | |
struct | proto_nmea_parser_s |
Defines | |
#define | NMEA_BUFLEN (122) |
size of parser input buffer, including trailing '' | |
Typedefs | |
typedef struct proto_nmea_parser_s | proto_nmea_parser_t |
Functions | |
gps_line_status_t | nmea_recvd (gps_parser_t *, usart_rxdata_t) |
give one character to NMEA parser |
interface to NMEA parser
gps_line_status_t nmea_recvd | ( | gps_parser_t * | , | |
usart_rxdata_t | ||||
) |
give one character to NMEA parser
{ gps_parser_t * p = parser; /* for shorter source code */ proto_nmea_parser_t * pp = (proto_nmea_parser_t*)parser->proto_parser; gps_line_status_t ret; if (c.flags & USART_NO_RX) { return GPS_LINE_CKERR; } if (c.flags & USART_FRAME_ERROR) { return GPS_LINE_MORE; } if (pp->bufidx >= sizeof(pp->buf)-1) { /* no more space in buffer */ if (c.data == '$') { /* uBlox may intermix binary and NMEA sentences, at * least this is what I understand from docs */ pp->bufidx = 0; pp->buf[(pp->bufidx)++] = c.data; return GPS_LINE_MORE; } if (c.data == '\n') { /* line finished -> reset */ pp->bufidx = 0; /* but return error indication anyway */ } return GPS_LINE_OVERFLOW; } if (pp->bufidx == 0) { /* save timestamp */ gps_timestamp_start_of_message (parser); } pp->buf[pp->bufidx++] = c.data; if (c.data != '\n') { /* not finished yet */ return GPS_LINE_MORE; } /* put in terminating NUL byte */ pp->buf[pp->bufidx] = '\0'; /* reset start index */ pp->bufidx = 0; /* check checksum */ if (nmea_line_csum_check (pp)) { return GPS_LINE_CKERR; } /* now we have a complete line with correct checksum * and we can start parsing */ ret = nmea_line_parse (p); return ret; }