Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/nmea/nmea.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ nmea_validate(const char *sentence, size_t length, int check_checksum)

/* should have a 5 letter, uppercase word */
n = sentence;
while (++n < sentence + 6) {
while (++n <= sentence + NMEA_PREFIX_LENGTH) {
if (*n < 'A' || *n > 'Z') {
/* not uppercase letter */
return -1;
}
}

/* should have a comma after the type word */
if (',' != sentence[6]) {
if (',' != sentence[NMEA_PREFIX_LENGTH+1]) {
return -1;
}

Expand Down
8 changes: 8 additions & 0 deletions src/nmea/nmea.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ typedef struct {
} nmea_position;

/* NMEA sentence max length, including \r\n (chars) */
#ifndef NMEA_MAX_LENGTH
#define NMEA_MAX_LENGTH 82
#endif

/* NMEA sentence endings, should be \r\n according the NMEA 0183 standard */
#ifndef NMEA_END_CHAR_1
#define NMEA_END_CHAR_1 '\r'
#endif
#ifndef NMEA_END_CHAR_2
#define NMEA_END_CHAR_2 '\n'
#endif

/* NMEA sentence prefix length (num chars), Ex: GPGLL */
#ifndef NMEA_PREFIX_LENGTH
#define NMEA_PREFIX_LENGTH 5
#endif

#ifdef __cplusplus
extern "C" {
Expand Down