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 committed Jan 23, 2025
1 parent 57c8a62 commit 2225cd0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 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
1 change: 1 addition & 0 deletions examples/gps/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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 *ser_port = "/dev/ttyS1";

/* Get the GPS serial port argument. If none specified, default to ttyS1 */

if (argc > 1)
{
ser_port = argv[1];
}

/* Open the GPS serial port */

fd = open("/dev/ttyS1", O_RDONLY);
fd = open(ser_port, O_RDONLY);
if (fd < 0)
{
printf("Unable to open file /dev/ttyS1\n");
fprintf(stderr, "Unable to open file %s\n", ser_port);
return 1;
}

/* Run forever */
Expand Down

0 comments on commit 2225cd0

Please sign in to comment.