diff options
author | Jason Reiss <jreiss@multitech.com> | 2022-11-21 11:37:12 -0600 |
---|---|---|
committer | Jason Reiss <jreiss@multitech.com> | 2022-11-21 11:37:12 -0600 |
commit | 928c234b0ebec37f302d5c1e4b0c0f03b6e58d2d (patch) | |
tree | 8b6a3e0deb53305b416c45733243cf856956b58d /libloragw/tst | |
parent | 25065e728b18fe174dd5f06396276f22ddb04ee2 (diff) | |
download | lora_gateway_mtac_full-928c234b0ebec37f302d5c1e4b0c0f03b6e58d2d.tar.gz lora_gateway_mtac_full-928c234b0ebec37f302d5c1e4b0c0f03b6e58d2d.tar.bz2 lora_gateway_mtac_full-928c234b0ebec37f302d5c1e4b0c0f03b6e58d2d.zip |
gps: fix calculation of cnt in the past, PPS may be updated after packet is received and stamped5.0.21
Diffstat (limited to 'libloragw/tst')
-rw-r--r-- | libloragw/tst/test_loragw_gps.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/libloragw/tst/test_loragw_gps.c b/libloragw/tst/test_loragw_gps.c index c535878..6d41a0d 100644 --- a/libloragw/tst/test_loragw_gps.c +++ b/libloragw/tst/test_loragw_gps.c @@ -112,16 +112,36 @@ static void gps_process_sync(void) { x = ppm_tstamp + 500000; printf(" * Test of timestamp counter <-> GPS value conversion *\n"); printf(" Test value: %u\n", x); - lgw_cnt2gps(ppm_ref, x, &y); + i = lgw_cnt2gps(ppm_ref, x, &y); printf(" Conversion to GPS: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); - lgw_gps2cnt(ppm_ref, y, &z); + i = lgw_gps2cnt(ppm_ref, y, &z); printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); printf(" * Test of timestamp counter <-> UTC value conversion *\n"); printf(" Test value: %u\n", x); - lgw_cnt2utc(ppm_ref, x, &y); + i = lgw_cnt2utc(ppm_ref, x, &y); printf(" Conversion to UTC: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); - lgw_utc2cnt(ppm_ref, y, &z); + i = lgw_utc2cnt(ppm_ref, y, &z); printf(" Converted back: %u ==> %dµs\n", z, (int32_t)(z-x)); + + x = ppm_tstamp - 500000; + printf(" * Test of timestamp counter <-> past GPS value conversion *\n"); + printf(" Test value: %u\n", x); + i = lgw_cnt2gps(ppm_ref, x, &y); + printf(" Conversion to GPS: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + i = lgw_gps2cnt(ppm_ref, y, &z); + if (i != LGW_GPS_ERROR) + printf(" ** FAILED **: Converted past time back: %u ==> %dµs\n", z, (int32_t)(z-x)); + else + printf(" ** PASS **: Could not convert to CNT, GPS time has passed\n"); + printf(" * Test of timestamp counter <-> past UTC value conversion *\n"); + printf(" Test value: %u\n", x); + i = lgw_cnt2utc(ppm_ref, x, &y); + printf(" Conversion to UTC: %lld.%09ld\n", (long long)y.tv_sec, y.tv_nsec); + i = lgw_utc2cnt(ppm_ref, y, &z); + if (i != LGW_GPS_ERROR) + printf(" ** FAILED **: Converted past time back: %u ==> %dµs\n", z, (int32_t)(z-x)); + else + printf(" ** PASS **: Could not convert to CNT, UTC time has passed\n"); } static void gps_process_coords(void) { |