minmea: add minmea_talker_id()
This commit is contained in:
parent
5bc6fddb55
commit
ea1bbcbfa5
13
minmea.c
13
minmea.c
@ -259,6 +259,19 @@ end:
|
||||
return result;
|
||||
}
|
||||
|
||||
bool minmea_talker_id(char talker[3], const char *sentence)
|
||||
{
|
||||
char type[6];
|
||||
if (!minmea_scan(sentence, "t", type))
|
||||
return false;
|
||||
|
||||
talker[0] = type[0];
|
||||
talker[1] = type[1];
|
||||
talker[2] = '\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
enum minmea_sentence_id minmea_sentence_id(const char *sentence)
|
||||
{
|
||||
if (!minmea_check(sentence))
|
||||
|
5
minmea.h
5
minmea.h
@ -92,6 +92,11 @@ struct minmea_sentence_gsa {
|
||||
*/
|
||||
bool minmea_check(const char *sentence);
|
||||
|
||||
/**
|
||||
* Determine talker identifier.
|
||||
*/
|
||||
bool minmea_talker_id(char talker[3], const char *sentence);
|
||||
|
||||
/**
|
||||
* Determine sentence identifier.
|
||||
*/
|
||||
|
7
tests.c
7
tests.c
@ -382,7 +382,7 @@ START_TEST(test_minmea_usage1)
|
||||
const char *sentences[] = {
|
||||
"$GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62",
|
||||
"$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47",
|
||||
"$GPGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1*39",
|
||||
"$GNGSA,A,3,04,05,,09,12,,,24,,,,,2.5,1.3,2.1",
|
||||
NULL,
|
||||
};
|
||||
|
||||
@ -407,6 +407,11 @@ START_TEST(test_minmea_usage1)
|
||||
default: {
|
||||
} break;
|
||||
}
|
||||
|
||||
char talker[3];
|
||||
char expected[3] = { (*sentence)[1], (*sentence)[2], '\0' };
|
||||
ck_assert(minmea_talker_id(talker, *sentence) == true);
|
||||
ck_assert_str_eq(talker, expected);
|
||||
}
|
||||
}
|
||||
END_TEST
|
||||
|
Loading…
Reference in New Issue
Block a user