" -s <path> Path to ubus socket\n"
" -d <level> Enable debug messages\n"
" -S Print messages to stdout\n"
+ " -b Set gps device baud rate\n"
"\n", prog);
return -1;
}
+static speed_t get_baudrate(int baudrate)
+{
+ switch (baudrate) {
+ case 4800:
+ return B4800;
+ case 9600:
+ return B9600;
+ case 19200:
+ return B19200;
+ case 38400:
+ return B38400;
+ case 57600:
+ return B57600;
+ case 115200:
+ return B115200;
+ default:
+ fprintf(stderr, "ERROR: incorrect baud rate. Default 4800 baud rate has been set\n");
+ return B4800;
+ }
+}
+
int
main(int argc, char ** argv)
{
char *device = NULL;
char *dbglvl = getenv("DBGLVL");
int ulog_channels = ULOG_KMSG;
+ speed_t baudrate = B4800;
signal(SIGPIPE, SIG_IGN);
unsetenv("DBGLVL");
}
- while ((ch = getopt(argc, argv, "ad:s:S")) != -1) {
+ while ((ch = getopt(argc, argv, "ad:s:S:b:")) != -1) {
switch (ch) {
case 'a':
adjust_clock = -1;
case 'S':
ulog_channels = ULOG_STDIO;
break;
+ case 'b':
+ baudrate = get_baudrate(atoi(optarg));
+ break;
default:
return usage(argv[0]);
}
conn.cb = ubus_connect_handler;
ubus_auto_connect(&conn);
- if (nmea_open(device, &stream, B4800) < 0)
+ if (nmea_open(device, &stream, baudrate) < 0)
return -1;
uloop_run();