mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-07-04 19:07:16 +08:00
examples/gps: Allow GPS serial port to be specified as command line argument, mark MINMEA dependency in Kconfig.
This commit is contained in:
parent
add50b3bd5
commit
acc2b390c3
1
.gitignore
vendored
1
.gitignore
vendored
@ -47,3 +47,4 @@ build
|
||||
.ccls-cache
|
||||
compile_commands.json
|
||||
.aider*
|
||||
.clang-format
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user