examples/gps: Allow GPS serial port to be specified as command line argument, mark MINMEA dependency in Kconfig.

This commit is contained in:
Matteo Golin 2025-01-22 19:44:05 -05:00 committed by Xiang Xiao
parent add50b3bd5
commit acc2b390c3
3 changed files with 13 additions and 3 deletions

1
.gitignore vendored
View File

@ -47,3 +47,4 @@ build
.ccls-cache
compile_commands.json
.aider*
.clang-format

View File

@ -6,7 +6,7 @@
config EXAMPLES_GPS
tristate "GPS example"
default n
select GPSUTILS_MINMEA_LIB
depends on GNSSUTILS_MINMEA_LIB
---help---
Enable the gps test example

View File

@ -54,13 +54,22 @@ int main(int argc, FAR char *argv[])
int cnt;
char ch;
char line[MINMEA_MAX_LENGTH];
char *port = "/dev/ttyS1";
/* Get the GPS serial port argument. If none specified, default to ttyS1 */
if (argc > 1)
{
port = argv[1];
}
/* Open the GPS serial port */
fd = open("/dev/ttyS1", O_RDONLY);
fd = open(port, O_RDONLY);
if (fd < 0)
{
printf("Unable to open file /dev/ttyS1\n");
fprintf(stderr, "Unable to open file %s\n", port);
return 1;
}
/* Run forever */