From 7477e3caa38b3f2390c5b4dfec7a09211d0a1933 Mon Sep 17 00:00:00 2001 From: Kosma Moczek Date: Tue, 17 Jun 2014 15:00:51 +0200 Subject: [PATCH] minmea_parse_gll: make mode field optional --- minmea.c | 2 +- tests.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/minmea.c b/minmea.c index 0b06143..f14290b 100644 --- a/minmea.c +++ b/minmea.c @@ -439,7 +439,7 @@ bool minmea_parse_gll(struct minmea_sentence_gll *frame, const char *sentence) int latitude_direction; int longitude_direction; - if (!minmea_scan(sentence, "tfdfdTcc", + if (!minmea_scan(sentence, "tfdfdTc;c", type, &frame->latitude, &latitude_direction, &frame->longitude, &longitude_direction, diff --git a/tests.c b/tests.c index 9791a23..5edc737 100644 --- a/tests.c +++ b/tests.c @@ -537,6 +537,24 @@ START_TEST(test_minmea_parse_gll1) } END_TEST +START_TEST(test_minmea_parse_gll2) +{ + const char *sentence = "$GPGLL,4916.45,N,12311.12,W,225444,A"; + struct minmea_sentence_gll frame = {}; + struct minmea_sentence_gll expected = { + .latitude = { 491645, 100 }, + .longitude = { -1231112, 100 }, + .time = { 22, 54, 44 }, + .status = MINMEA_GLL_STATUS_DATA_VALID, + .mode = 0, + }; + + ck_assert(minmea_check(sentence) == true); + ck_assert(minmea_parse_gll(&frame, sentence) == true); + ck_assert(!memcmp(&frame, &expected, sizeof(frame))); +} +END_TEST + START_TEST(test_minmea_parse_gsv1) { const char *sentence = "$GPGSV,3,3,11,22,42,067,42,24,14,311,43,27,05,244,00,,,,*4D"; @@ -717,6 +735,7 @@ Suite *minmea_suite(void) tcase_add_test(tc_parse, test_minmea_parse_gga1); tcase_add_test(tc_parse, test_minmea_parse_gsa1); tcase_add_test(tc_parse, test_minmea_parse_gll1); + tcase_add_test(tc_parse, test_minmea_parse_gll2); tcase_add_test(tc_parse, test_minmea_parse_gst1); tcase_add_test(tc_parse, test_minmea_parse_gsv1); suite_add_tcase(s, tc_parse);