Skip to content

Commit acc2b39

Browse files
linguini1xiaoxiang781216
authored andcommitted
examples/gps: Allow GPS serial port to be specified as command line argument, mark MINMEA dependency in Kconfig.
1 parent add50b3 commit acc2b39

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ build
4747
.ccls-cache
4848
compile_commands.json
4949
.aider*
50+
.clang-format

examples/gps/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config EXAMPLES_GPS
77
tristate "GPS example"
88
default n
9-
select GPSUTILS_MINMEA_LIB
9+
depends on GNSSUTILS_MINMEA_LIB
1010
---help---
1111
Enable the gps test example
1212

examples/gps/gps_main.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,22 @@ int main(int argc, FAR char *argv[])
5454
int cnt;
5555
char ch;
5656
char line[MINMEA_MAX_LENGTH];
57+
char *port = "/dev/ttyS1";
58+
59+
/* Get the GPS serial port argument. If none specified, default to ttyS1 */
60+
61+
if (argc > 1)
62+
{
63+
port = argv[1];
64+
}
5765

5866
/* Open the GPS serial port */
5967

60-
fd = open("/dev/ttyS1", O_RDONLY);
68+
fd = open(port, O_RDONLY);
6169
if (fd < 0)
6270
{
63-
printf("Unable to open file /dev/ttyS1\n");
71+
fprintf(stderr, "Unable to open file %s\n", port);
72+
return 1;
6473
}
6574

6675
/* Run forever */

0 commit comments

Comments
 (0)