From 1bfe45e78503e10f1f392d4d5fe66fbd932470c0 Mon Sep 17 00:00:00 2001 From: Jan Mohr Date: Fri, 20 Oct 2023 17:01:34 +0200 Subject: [PATCH 1/4] tests/pkg/minmea: adding GGA, GSA and RMC sentences to test application --- tests/pkg/minmea/main.c | 138 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 127 insertions(+), 11 deletions(-) diff --git a/tests/pkg/minmea/main.c b/tests/pkg/minmea/main.c index abe0ccad7739..8ab72545f81e 100644 --- a/tests/pkg/minmea/main.c +++ b/tests/pkg/minmea/main.c @@ -14,31 +14,147 @@ * @brief minmea GPS NMEA parser library package test application * * @author Kaspar Schleiser + * @author Jan Mohr * * @} */ +#include +#include + #include "fmt.h" #include "minmea.h" +static const char *_gga = "$GNGGA,142142.227,5227.022,N,01317.919,E,1,12,1.0,0.0,M,0.0,M,,*70"; static const char *_gll = "$GNGLL,5229.0178,N,01326.7605,E,114350.000,A,A*45"; +static const char *_gsa = "$GNGSA,A,3,01,02,03,04,05,06,07,08,09,10,11,12,1.0,1.0,1.0*2E"; +static const char *_rmc = "$GPRMC,142142.227,A,5227.022,N,01317.919,E,,,201023,000.0,W*78"; + +int _parse_nmea_msg(const char* nmea_msg) +{ + /* get message type */ + int msg_type = minmea_sentence_id(nmea_msg, false); + switch (msg_type) { + case MINMEA_SENTENCE_GGA: { + struct minmea_sentence_gga frame; + if (minmea_parse_gga(&frame, nmea_msg) && frame.fix_quality) { + puts("check_nmea: GGA recorded"); + + /* print values */ + print_str("\tlat: "); + print_float(minmea_tocoord(&frame.latitude), 6); + printf("\n"); + print_str("\tlon: "); + print_float(minmea_tocoord(&frame.longitude), 6); + printf("\n"); + printf("\talt: %"PRId32"\n", minmea_rescale(&frame.altitude, 1)); + printf("\tn_sats: %d\n", frame.satellites_tracked); + } + else { + puts("check_nmea: invalid GGA record"); + } + } break; + case MINMEA_SENTENCE_GLL: { + struct minmea_sentence_gll frame; + if (minmea_parse_gll(&frame, nmea_msg)) { + puts("check_nmea: GLL recorded"); + + /* print values */ + print_str("\tlat: "); + print_float(minmea_tocoord(&frame.latitude), 6); + printf("\n"); + print_str("\tlon: "); + print_float(minmea_tocoord(&frame.longitude), 6); + printf("\n"); + } + else { + puts("check_nmea: invalid GLL record"); + } + } break; + case MINMEA_SENTENCE_GSA: { + struct minmea_sentence_gsa frame; + if (minmea_parse_gsa(&frame, nmea_msg)) { + puts("check_nmea: GSA recorded"); + + /* print values */ + printf("\tmode: %c\n", frame.mode); /* (A)automatic and (M)manual mode */ + /* identify fix-type */ + switch (frame.fix_type) { + case MINMEA_GPGSA_FIX_NONE: + printf("\tfix_type: %s\n", "NONE"); + break; + case MINMEA_GPGSA_FIX_2D: + printf("\tfix_type: %s\n", "2D"); + break; + case MINMEA_GPGSA_FIX_3D: + printf("\tfix_type: %s\n", "3D"); + break; + default: + printf("\tfix_type: %s\n", "UNKNOWN"); + } + /* always a record of 12 satellites */ + for (int i = 0; i < 12; i++) { + printf("\t%d. sat: %d\n", i, frame.sats[i]); + } + } + else { + puts("check_nmea: invalid GSA record"); + } + } break; + case MINMEA_SENTENCE_RMC: { + struct minmea_sentence_rmc frame; + if (minmea_parse_rmc(&frame, nmea_msg) && frame.valid) { + puts("check_nmea: RMC recorded"); + + /* parse timestamp */ + struct tm tm; + time_t timestamp; + minmea_getdatetime(&tm, &frame.date, &frame.time); + timestamp = mktime(&tm); + + /* print values */ + print_str("\tlat: "); + print_float(minmea_tocoord(&frame.latitude), 6); + printf("\n"); + print_str("\tlon: "); + print_float(minmea_tocoord(&frame.longitude), 6); + printf("\n"); + printf("\ttime: %"PRIu32"\n", (uint32_t)timestamp); + } + else { + puts("check_nmea: invalid RMC record"); + } + } break; + default: + printf("check_nmea: unknown message type %d\n", msg_type); + return -1; + } + + return 0; +} int main(void) { - print_str("START\n"); - struct minmea_sentence_gll frame; + puts("START"); - int res = minmea_parse_gll(&frame, _gll); - if (!res) { - print_str("FAILURE: error parsing GPS sentence\n"); + /* check GGA */ + if (_parse_nmea_msg(_gga) != 0) { + puts("Error parsing GGA"); } - else { - print_str("parsed coordinates: lat="); - print_float(minmea_tocoord(&frame.latitude), 6); - print_str(" lon="); - print_float(minmea_tocoord(&frame.longitude), 6); - print_str("\nSUCCESS\n"); + /* check GLL */ + if (_parse_nmea_msg(_gll) != 0) { + puts("Error parsing GLL"); } + /* check GSA */ + if (_parse_nmea_msg(_gsa) != 0) { + puts("Error parsing GSA"); + } + /* check RMC */ + if (_parse_nmea_msg(_rmc) != 0) { + puts("Error parsing RMC"); + } + + puts("SUCCESS"); return 0; } From d569cdf4f0a365b0b48341f179dc03ca95f1bd60 Mon Sep 17 00:00:00 2001 From: Jan Mohr Date: Mon, 23 Oct 2023 09:56:19 +0200 Subject: [PATCH 2/4] tests/pkg/minmea: adapting test file --- tests/pkg/minmea/tests/01-run.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/pkg/minmea/tests/01-run.py b/tests/pkg/minmea/tests/01-run.py index 66ae905c0417..6b91ac437a6d 100755 --- a/tests/pkg/minmea/tests/01-run.py +++ b/tests/pkg/minmea/tests/01-run.py @@ -5,9 +5,35 @@ def testfunc(child): - child.expect_exact('START') - child.expect('parsed coordinates: lat=52.483631 lon=13.446008') - child.expect_exact('SUCCESS') + child.expect_exact('START\r\n') + child.expect_exact('check_nmea: GGA recorded\r\n') + child.expect_exact('\tlat: 52.450366\r\n') + child.expect_exact('\tlon: 13.298649\r\n') + child.expect_exact('\talt: 0\r\n') + child.expect_exact('\tn_sats: 12\r\n') + child.expect_exact('check_nmea: GLL recorded\r\n') + child.expect_exact('\tlat: 52.483631\r\n') + child.expect_exact('\tlon: 13.446008\r\n') + child.expect_exact('check_nmea: GSA recorded\r\n') + child.expect_exact('\tmode: A\r\n') + child.expect_exact('\tfix_type: 3D\r\n') + child.expect_exact('\t0. sat: 1\r\n') + child.expect_exact('\t1. sat: 2\r\n') + child.expect_exact('\t2. sat: 3\r\n') + child.expect_exact('\t3. sat: 4\r\n') + child.expect_exact('\t4. sat: 5\r\n') + child.expect_exact('\t5. sat: 6\r\n') + child.expect_exact('\t6. sat: 7\r\n') + child.expect_exact('\t7. sat: 8\r\n') + child.expect_exact('\t8. sat: 9\r\n') + child.expect_exact('\t9. sat: 10\r\n') + child.expect_exact('\t10. sat: 11\r\n') + child.expect_exact('\t11. sat: 12\r\n') + child.expect_exact('check_nmea: RMC recorded\r\n') + child.expect_exact('\tlat: 52.450366\r\n') + child.expect_exact('\tlon: 13.298649\r\n') + child.expect_exact('\ttime: 1697808102\r\n') + child.expect_exact('SUCCESS\r\n') if __name__ == "__main__": From 51ee3b64dcde618eaa415a55aa331ec6024a6be7 Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Mon, 23 Oct 2023 11:54:08 +0200 Subject: [PATCH 3/4] release-test.yml: Fix strasbourg spelling Small typo fix... stasbourg -> strasbourg --- .github/workflows/release-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index a2c386888891..17a6d16cbcea 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -85,12 +85,12 @@ jobs: IOTLAB_USER=$(cat ~/.iotlabrc | cut -f1 -d:) ssh -oStrictHostKeyChecking=accept-new \ ${IOTLAB_USER}@lille.iot-lab.info exit - - name: Fetch host key from IoT-LAB stasbourg site + - name: Fetch host key from IoT-LAB strasbourg site if: ${{ matrix.pytest_mark == 'iotlab_creds' }} run: | IOTLAB_USER=$(cat ~/.iotlabrc | cut -f1 -d:) ssh -oStrictHostKeyChecking=accept-new \ - ${IOTLAB_USER}@stasbourg.iot-lab.info exit + ${IOTLAB_USER}@strasbourg.iot-lab.info exit - name: Checkout Release-Specs uses: actions/checkout@main with: From bdb1bc30188e3b7ae65c0d9b708cc95738279c12 Mon Sep 17 00:00:00 2001 From: Jan Mohr Date: Mon, 23 Oct 2023 11:19:58 +0200 Subject: [PATCH 4/4] tests/pkg/minmea: exclude boards with small memory --- tests/pkg/minmea/Makefile.ci | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/pkg/minmea/Makefile.ci b/tests/pkg/minmea/Makefile.ci index 7f561684577a..8d800e187928 100644 --- a/tests/pkg/minmea/Makefile.ci +++ b/tests/pkg/minmea/Makefile.ci @@ -1,4 +1,6 @@ BOARD_INSUFFICIENT_MEMORY := \ atmega8 \ + nucleo-l011k4 \ + samd10-xmini \ stm32f030f4-demo \ #