From c01cbcf342c74efe79876140e87ae6af0cf5f9a1 Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 5 Sep 2018 08:45:41 +0800 Subject: [PATCH 1/9] modify dgps_age type change dgps_age type from int to struct minmea_float. example: $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh --- minmea.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minmea.h b/minmea.h index b80124c..181d8c7 100644 --- a/minmea.h +++ b/minmea.h @@ -76,7 +76,7 @@ struct minmea_sentence_gga { struct minmea_float hdop; struct minmea_float altitude; char altitude_units; struct minmea_float height; char height_units; - int dgps_age; + struct minmea_float dgps_age; }; enum minmea_gll_status { From c4a5a01d66c6802c8657439b7265e7f8190d5996 Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 5 Sep 2018 08:47:49 +0800 Subject: [PATCH 2/9] modify dgps_age type change dgps_age type from int to struct minmea_float. example: $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,x,xx,x.x,x.x,M,x.x,M,x.x,xxxx*hh --- minmea.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/minmea.c b/minmea.c index 43d6926..32f7881 100644 --- a/minmea.c +++ b/minmea.c @@ -415,7 +415,7 @@ bool minmea_parse_gga(struct minmea_sentence_gga *frame, const char *sentence) int latitude_direction; int longitude_direction; - if (!minmea_scan(sentence, "tTfdfdiiffcfci_", + if (!minmea_scan(sentence, "tTfdfdiiffcfcf_", type, &frame->time, &frame->latitude, &latitude_direction, From 79b964a5b2c20b93fb4524d35e2669227f3b372f Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Sat, 8 Sep 2018 13:10:06 +0800 Subject: [PATCH 3/9] modefy initialization for dgps_age modefy initialization for dgps_age --- tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.c b/tests.c index 4e90c44..fff286d 100644 --- a/tests.c +++ b/tests.c @@ -519,7 +519,7 @@ START_TEST(test_minmea_parse_gga1) .altitude_units = 'M', .height = { 469, 10 }, .height_units = 'M', - .dgps_age = 0, + .dgps_age = { 0, 10 }, }; ck_assert(minmea_check(sentence, false) == true); ck_assert(minmea_check(sentence, true) == true); From 59c3e0a8135371df6aa8990056f5a83b5e9660ce Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Sat, 8 Sep 2018 14:12:10 +0800 Subject: [PATCH 4/9] fix gga char alignment problem in test.c In c compiler, a char takes 4 bytes in a structure though its size is 1 bytes. The initialization for `struct minmea_sentence_gga`: ``` struct minmea_sentence_gga expected = { .time = { 12, 35, 19, 0 }, .latitude = { 4807038, 1000 }, .longitude = { 1131000, 1000 }, .fix_quality = 1, .satellites_tracked = 8, .hdop = { 9, 10 }, .altitude = { 5454, 10 }, .altitude_units = 'M', .height = { 469, 10 }, .height_units = 'M', .dgps_age = { 0, 0 }, }; ``` has the binary sequence like these: ``` 0c 00 00 00 23 00 00 00 13 00 00 00 00 00 00 00 7e 59 49 00 e8 03 00 00 f8 41 11 00 e8 03 00 00 01 00 00 00 08 00 00 00 09 00 00 00 0a 00 00 00 4e 15 00 00 0a 00 00 00 4d cc cc cc d5 01 00 00 0a 00 00 00 4d cc cc cc 00 00 00 00 00 00 00 00 ``` which the `4d cc cc cc` is the `'M'`, and cause memcmp return none zero. Therefore I add some code to remove `cc cc cc`: ``` memset(&expected.altitude_units + 1, 0, 3); memset(&expected.height_units + 1, 0, 3); ``` --- tests.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests.c b/tests.c index fff286d..f55e17a 100644 --- a/tests.c +++ b/tests.c @@ -508,7 +508,7 @@ START_TEST(test_minmea_parse_gga1) { const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; struct minmea_sentence_gga frame = {}; - static const struct minmea_sentence_gga expected = { + struct minmea_sentence_gga expected = { .time = { 12, 35, 19, 0 }, .latitude = { 4807038, 1000 }, .longitude = { 1131000, 1000 }, @@ -519,11 +519,13 @@ START_TEST(test_minmea_parse_gga1) .altitude_units = 'M', .height = { 469, 10 }, .height_units = 'M', - .dgps_age = { 0, 10 }, + .dgps_age = { 0, 0 }, }; ck_assert(minmea_check(sentence, false) == true); ck_assert(minmea_check(sentence, true) == true); ck_assert(minmea_parse_gga(&frame, sentence) == true); + memset(&expected.altitude_units + 1, 0, 3); + memset(&expected.height_units + 1, 0, 3); ck_assert(!memcmp(&frame, &expected, sizeof(frame))); } END_TEST From 9fcd2450f52f3c05c00f004e10fa78bae055d684 Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Sat, 8 Sep 2018 14:14:43 +0800 Subject: [PATCH 5/9] remove indent --- tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.c b/tests.c index f55e17a..5f3e971 100644 --- a/tests.c +++ b/tests.c @@ -525,7 +525,7 @@ START_TEST(test_minmea_parse_gga1) ck_assert(minmea_check(sentence, true) == true); ck_assert(minmea_parse_gga(&frame, sentence) == true); memset(&expected.altitude_units + 1, 0, 3); - memset(&expected.height_units + 1, 0, 3); + memset(&expected.height_units + 1, 0, 3); ck_assert(!memcmp(&frame, &expected, sizeof(frame))); } END_TEST From 35b00bca2f364de70e5e5bd10439cbc0d2e2f68b Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 19 Sep 2018 14:01:55 +0800 Subject: [PATCH 6/9] fix test in gga --- tests.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests.c b/tests.c index 5f3e971..158c7bd 100644 --- a/tests.c +++ b/tests.c @@ -508,7 +508,8 @@ START_TEST(test_minmea_parse_gga1) { const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; struct minmea_sentence_gga frame = {}; - struct minmea_sentence_gga expected = { + struct minmea_sentence_gga expected = {}; + expected = (struct minmea_sentence_gga) { .time = { 12, 35, 19, 0 }, .latitude = { 4807038, 1000 }, .longitude = { 1131000, 1000 }, @@ -524,8 +525,6 @@ START_TEST(test_minmea_parse_gga1) ck_assert(minmea_check(sentence, false) == true); ck_assert(minmea_check(sentence, true) == true); ck_assert(minmea_parse_gga(&frame, sentence) == true); - memset(&expected.altitude_units + 1, 0, 3); - memset(&expected.height_units + 1, 0, 3); ck_assert(!memcmp(&frame, &expected, sizeof(frame))); } END_TEST From 113221d7a9b5b5a4635bd32ed0bb93bdf39cf77d Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 19 Sep 2018 14:15:51 +0800 Subject: [PATCH 7/9] fix test for gga --- tests.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/tests.c b/tests.c index 158c7bd..3309c63 100644 --- a/tests.c +++ b/tests.c @@ -509,19 +509,17 @@ START_TEST(test_minmea_parse_gga1) const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; struct minmea_sentence_gga frame = {}; struct minmea_sentence_gga expected = {}; - expected = (struct minmea_sentence_gga) { - .time = { 12, 35, 19, 0 }, - .latitude = { 4807038, 1000 }, - .longitude = { 1131000, 1000 }, - .fix_quality = 1, - .satellites_tracked = 8, - .hdop = { 9, 10 }, - .altitude = { 5454, 10 }, - .altitude_units = 'M', - .height = { 469, 10 }, - .height_units = 'M', - .dgps_age = { 0, 0 }, - }; + expected.time = { 12, 35, 19, 0 }; + expected.latitude = { 4807038, 1000 }; + expected.longitude = { 1131000, 1000 }; + expected.fix_quality = 1; + expected.satellites_tracked = 8; + expected.hdop = { 9, 10 }; + expected.altitude = { 5454, 10 }; + expected.altitude_units = 'M'; + expected.height = { 469, 10 }; + expected.height_units = 'M'; + expected.dgps_age = { 0, 0 }; ck_assert(minmea_check(sentence, false) == true); ck_assert(minmea_check(sentence, true) == true); ck_assert(minmea_parse_gga(&frame, sentence) == true); From 4514f6dd5e89e2c1fe1fddc4ccd22778a042d440 Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 19 Sep 2018 14:29:19 +0800 Subject: [PATCH 8/9] fix test for gga --- tests.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests.c b/tests.c index 3309c63..44f175d 100644 --- a/tests.c +++ b/tests.c @@ -507,19 +507,19 @@ END_TEST START_TEST(test_minmea_parse_gga1) { const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; - struct minmea_sentence_gga frame = {}; - struct minmea_sentence_gga expected = {}; - expected.time = { 12, 35, 19, 0 }; - expected.latitude = { 4807038, 1000 }; - expected.longitude = { 1131000, 1000 }; - expected.fix_quality = 1; - expected.satellites_tracked = 8; - expected.hdop = { 9, 10 }; - expected.altitude = { 5454, 10 }; - expected.altitude_units = 'M'; - expected.height = { 469, 10 }; - expected.height_units = 'M'; - expected.dgps_age = { 0, 0 }; + struct minmea_sentence_gga frame = { 0 }; + struct minmea_sentence_gga expected = { 0 }; + expected.time = (struct minmea_time) { 12, 35, 19, 0 }; + expected.latitude = (struct minmea_float) { 4807038, 1000 }; + expected.longitude = (struct minmea_float) { 1131000, 1000 }; + expected.fix_quality = 1; + expected.satellites_tracked = 8; + expected.hdop = (struct minmea_float) { 9, 10 }; + expected.altitude = (struct minmea_float) { 5454, 10 }; + expected.altitude_units = 'M'; + expected.height = (struct minmea_float) { 469, 10 }; + expected.height_units = 'M'; + expected.dgps_age = (struct minmea_float) { 0, 0 }; ck_assert(minmea_check(sentence, false) == true); ck_assert(minmea_check(sentence, true) == true); ck_assert(minmea_parse_gga(&frame, sentence) == true); From 61c6ef7dddc4ea39a33e3cd39710e409d2262397 Mon Sep 17 00:00:00 2001 From: gdpinchina Date: Wed, 19 Sep 2018 14:38:49 +0800 Subject: [PATCH 9/9] fix test for gga --- tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests.c b/tests.c index 44f175d..c2ae730 100644 --- a/tests.c +++ b/tests.c @@ -507,8 +507,8 @@ END_TEST START_TEST(test_minmea_parse_gga1) { const char *sentence = "$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47"; - struct minmea_sentence_gga frame = { 0 }; - struct minmea_sentence_gga expected = { 0 }; + struct minmea_sentence_gga frame = {}; + struct minmea_sentence_gga expected = {}; expected.time = (struct minmea_time) { 12, 35, 19, 0 }; expected.latitude = (struct minmea_float) { 4807038, 1000 }; expected.longitude = (struct minmea_float) { 1131000, 1000 };