-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pr/siriobalmelli-goss-pubx-time' into develop
- Loading branch information
Showing
10 changed files
with
415 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -383,3 +383,4 @@ log_file.txt | |
project.ioc | ||
mx.scratch | ||
*.tilen majerle | ||
*.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# gps-nmea-parser examples and tests Makefile | ||
# (c) 2020 Sirio, Balmelli Analog & Digital | ||
|
||
TARGETS := \ | ||
example.exe \ | ||
example_stat.exe \ | ||
test_code.exe \ | ||
test_time.exe | ||
|
||
.PHONY: all clean test | ||
all: $(TARGETS) | ||
|
||
clean: | ||
@rm -fv $(TARGETS) | ||
|
||
test: $(TARGETS) | ||
@for tgt in $(TARGETS); do \ | ||
echo "\n--- $$tgt ---"; \ | ||
./$$tgt; \ | ||
done | ||
|
||
CFLAGS += -Wall \ | ||
-DDEBUG=1 \ | ||
-I../gps_nmea_parser/src/include \ | ||
-I./ | ||
|
||
example.exe: example.c | ||
|
||
example_stat.exe: CFLAGS += -DGPS_CFG_STATUS=1 | ||
example_stat.exe: example_stat.c | ||
|
||
test_code.exe: ../gps_nmea_parser/src/gps/gps.c test_code.c ../dev/VisualStudio/main.c | ||
|
||
test_time.exe: CFLAGS += \ | ||
-DGPS_CFG_STATEMENT_PUBX=1 \ | ||
-DGPS_CFG_STATEMENT_PUBX_TIME=1 | ||
test_time.exe: ../gps_nmea_parser/src/gps/gps.c test_time.c ../dev/VisualStudio/main.c | ||
|
||
$(TARGETS) : ../gps_nmea_parser/src/gps/gps.c | ||
$(CC) -o $@ $(CFLAGS) $^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* This example tests the callback functionality of gps_process() | ||
* when the GPS_CFG_STATUS flag is set. | ||
*/ | ||
#include "gps/gps.h" | ||
#include <string.h> | ||
#include <stdio.h> | ||
|
||
#if ! GPS_CFG_STATUS | ||
#error "this test must be compiled with -DGPS_CFG_STATUS=1" | ||
#endif /* ! GPS_CFG_STATUS */ | ||
|
||
/* GPS handle */ | ||
gps_t hgps; | ||
|
||
/** | ||
* \brief Dummy data from GPS receiver | ||
*/ | ||
const char | ||
gps_rx_data[] = "" | ||
"$GPRMC,183729,A,3907.356,N,12102.482,W,000.0,360.0,080301,015.5,E*6F\r\n" | ||
"$GPRMB,A,,,,,,,,,,,,V*71\r\n" | ||
"$GPGGA,183730,3907.356,N,12102.482,W,1,05,1.6,646.4,M,-24.1,M,,*75\r\n" | ||
"$GPGSA,A,3,02,,,07,,09,24,26,,,,,1.6,1.6,1.0*3D\r\n" | ||
"$GPGSV,2,1,08,02,43,088,38,04,42,145,00,05,11,291,00,07,60,043,35*71\r\n" | ||
"$GPGSV,2,2,08,08,02,145,00,09,46,303,47,24,16,178,32,26,18,231,43*77\r\n" | ||
"$PGRME,22.0,M,52.9,M,51.0,M*14\r\n" | ||
"$GPGLL,3907.360,N,12102.481,W,183730,A*33\r\n" | ||
"$PGRMZ,2062,f,3*2D\r\n" | ||
"$PGRMM,WGS84*06\r\n" | ||
"$GPBOD,,T,,M,,*47\r\n" | ||
"$GPRTE,1,1,c,0*07\r\n" | ||
"$GPRMC,183731,A,3907.482,N,12102.436,W,000.0,360.0,080301,015.5,E*67\r\n" | ||
"$GPRMB,A,,,,,,,,,,,,V*71\r\n"; | ||
|
||
const gps_statement_t expected[] = { | ||
STAT_RMC, | ||
STAT_UNKNOWN, | ||
STAT_GGA, | ||
STAT_GSA, | ||
STAT_GSV, | ||
STAT_GSV, | ||
STAT_UNKNOWN, | ||
STAT_UNKNOWN, | ||
STAT_UNKNOWN, | ||
STAT_CHECKSUM_FAIL, | ||
STAT_UNKNOWN, | ||
STAT_UNKNOWN, | ||
STAT_RMC, | ||
STAT_UNKNOWN | ||
}; | ||
|
||
static int err_cnt; | ||
|
||
void callback(gps_statement_t res) { | ||
static int i; | ||
|
||
if (res != expected[i]) { | ||
printf("failed i %d, expected res %d but received %d\n", | ||
i, expected[i], res); | ||
++err_cnt; | ||
} | ||
|
||
++i; | ||
} | ||
|
||
int | ||
main() { | ||
/* Init GPS */ | ||
gps_init(&hgps); | ||
|
||
/* Process all input data */ | ||
gps_process(&hgps, gps_rx_data, strlen(gps_rx_data), callback); | ||
|
||
return err_cnt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef TEST_COMMON_HDR_H | ||
#define TEST_COMMON_HDR_H | ||
|
||
#include <math.h> | ||
#include <stdlib.h> | ||
|
||
#define RUN_TEST(x) do { \ | ||
if ((x)) { \ | ||
printf("Test passed on line %u with condition " # x "\r\n", (unsigned)__LINE__); \ | ||
} else { \ | ||
printf("Test FAILED on line %u with condition " # x "\r\n", (unsigned)__LINE__ ); \ | ||
exit(1); \ | ||
} \ | ||
} while (0) | ||
#define FLT_IS_EQUAL(x, y) (fabs((double)(x) - (double)(y)) < 0.00001) | ||
#define INT_IS_EQUAL(x, y) ((int)((x) == (y))) | ||
|
||
#endif /* TEST_COMMON_HDR_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* This example uses direct processing function, | ||
* to process dummy PUBX TIME packets from GPS receiver | ||
*/ | ||
#include <string.h> | ||
#include <stdio.h> | ||
#include "gps/gps.h" | ||
#include "test_common.h" | ||
|
||
#if ! GPS_CFG_STATEMENT_PUBX_TIME | ||
#error "this test must be compiled with -DGPS_CFG_STATEMENT_PUBX_TIME=1" | ||
#endif /* ! GPS_CFG_STATEMENT_PUBX_TIME */ | ||
|
||
/* GPS handle */ | ||
gps_t hgps; | ||
|
||
/** | ||
* \brief Dummy data from GPS receiver | ||
*/ | ||
const char | ||
gps_rx_data_A[] = "" | ||
"$PUBX,04*37\r\n" | ||
"$PUBX,04,073731.00,091202,113851.00,1196,15D,1930035,-2660.664,43*71\r\n" | ||
""; | ||
const char | ||
gps_rx_data_B[] = "" | ||
"$PUBX,04,200714.00,230320,158834.00,2098,18,536057,257.043,16*12\r\b" | ||
""; | ||
|
||
|
||
/** | ||
* \brief Run the test of raw input data | ||
*/ | ||
void | ||
run_tests() { | ||
gps_init(&hgps); /* Init GPS */ | ||
|
||
/* Process and test block A */ | ||
gps_process(&hgps, gps_rx_data_A, strlen(gps_rx_data_A)); | ||
|
||
RUN_TEST(INT_IS_EQUAL(hgps.hours, 7)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.minutes, 37)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.seconds, 31)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.date, 9)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.month, 12)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.year, 2)); | ||
RUN_TEST(FLT_IS_EQUAL(hgps.utc_tow, 113851.00)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.utc_wk, 1196)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.leap_sec, 15)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.clk_bias, 1930035)); | ||
RUN_TEST(FLT_IS_EQUAL(hgps.clk_drift, -2660.664)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.tp_gran, 43)); | ||
|
||
/* Process and test block B */ | ||
gps_process(&hgps, gps_rx_data_B, strlen(gps_rx_data_B)); | ||
|
||
RUN_TEST(INT_IS_EQUAL(hgps.hours, 20)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.minutes, 7)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.seconds, 14)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.date, 23)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.month, 3)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.year, 20)); | ||
RUN_TEST(FLT_IS_EQUAL(hgps.utc_tow, 158834.00)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.utc_wk, 2098)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.leap_sec, 18)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.clk_bias, 536057)); | ||
RUN_TEST(FLT_IS_EQUAL(hgps.clk_drift, 257.043)); | ||
RUN_TEST(INT_IS_EQUAL(hgps.tp_gran, 16)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.