Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Loss in precision from GGA parsing #4

Open
kknives opened this issue Aug 28, 2023 · 0 comments
Open

Loss in precision from GGA parsing #4

kknives opened this issue Aug 28, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@kknives
Copy link
Collaborator

kknives commented Aug 28, 2023

The following test:

void test_gga_parsing_over_examples(void) {
const char* examples[] = {
"$GPGGA,002153.000,3342.6618,N,11751.3858,W,1,10,1.2,27.0,M,-34.2,M,,0000*5E"};
gps_t handle = gps_init();
TEST_ASSERT_EQUAL(GPS_NO_ERROR, gps_update(handle, examples[0], strlen(examples[0])));
int latlon_degmins[2];
int latlon_minfracs[2];
gps_get_lat_lon(handle, latlon_degmins, latlon_minfracs);
TEST_ASSERT_EQUAL(3342, latlon_degmins[0]);
TEST_ASSERT_EQUAL(6618, latlon_minfracs[0]);
TEST_ASSERT_EQUAL(11751, latlon_degmins[1]);
TEST_ASSERT_EQUAL(3858, latlon_minfracs[1]);
}

Fails with the output:

$ ./test_parsing.out
test_parsing.c:17:test_gga_parsing_over_examples:FAIL: Expected 3858 Was 3857
                                                                                                                                                                                              
-----------------------
1 Tests 1 Failures 0 Ignored
FAIL

There is a loss in precision after parsing the sentence: the sentence provided has the longitude minutes different from the one returned by gps_get_lat_lon.

Find the cause and a way to fix this, so that the test passes. In addition, try out other values to make sure that this bug never occurs again.

@kknives kknives added the bug Something isn't working label Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant