Skip to content

Commit

Permalink
examples/gps: Allow GPS serial port to be specified as command line a…
Browse files Browse the repository at this point in the history
…rgument, mark MINMEA dependency in Kconfig.
  • Loading branch information
linguini1 authored and xiaoxiang781216 committed Jan 23, 2025
1 parent add50b3 commit acc2b39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ build
.ccls-cache
compile_commands.json
.aider*
.clang-format
2 changes: 1 addition & 1 deletion examples/gps/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 11 additions & 2 deletions examples/gps/gps_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit acc2b39

Please sign in to comment.