hex2int: fix hex digit parsing

This commit is contained in:
Kosma Moczek 2014-02-26 13:19:00 +01:00
parent b341777f60
commit c5860da6c8
2 changed files with 6 additions and 2 deletions

View File

@ -19,9 +19,9 @@ static int hex2int(char c)
if (c >= '0' && c <= '9') if (c >= '0' && c <= '9')
return c - '0'; return c - '0';
if (c >= 'A' && c <= 'F') if (c >= 'A' && c <= 'F')
return c - 'A'; return c - 'A' + 10;
if (c >= 'a' && c <= 'f') if (c >= 'a' && c <= 'f')
return c - 'a'; return c - 'a' + 10;
return -1; return -1;
} }

View File

@ -20,6 +20,8 @@ static const char *valid_sequences[] = {
"$GPGGA,,,,,,0,00,99.99,,,,,,*48", "$GPGGA,,,,,,0,00,99.99,,,,,,*48",
"$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30", "$GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30",
"$GPGLL,,,,,,V,N*64", "$GPGLL,,,,,,V,N*64",
"$GPXTE,A,A,0.67,L,N*6F",
"$GPXTE,A,A,0.67,L,N*6f",
NULL, NULL,
}; };
@ -32,6 +34,8 @@ static const char *invalid_sequences[] = {
"$$GPGGA,,,,,,0,00,99.99,,,,,,*48", "$$GPGGA,,,,,,0,00,99.99,,,,,,*48",
"GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30", "GPGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.99*30",
"gps: $GPGLL,,,,,,V,N", "gps: $GPGLL,,,,,,V,N",
"$GPXTE,A,A,0.67,L,N*6e",
"$GPXTE,A,A,0.67,L,N*6g",
NULL, NULL,
}; };