diff options
-rw-r--r-- | gpsmon.c | 164 | ||||
-rw-r--r-- | gpsmon.xml | 21 | ||||
-rw-r--r-- | monitor_proto.c | 4 | ||||
-rw-r--r-- | sirfmon.c | 4 |
4 files changed, 95 insertions, 98 deletions
@@ -1,18 +1,6 @@ /* $Id$ */ /* - * GPS packet monitor - * - * A Useful commands: - * l -- toggle packet logging - * b -- change baud rate. - * n -- change from native t o binary mode orr vice-versa. - * s -- send hex bytes to device. - * q -- quit, leaving device in binary mode. - * Ctrl-S -- freeze display. - * Ctrl-Q -- unfreeze display. - * - * There may be chipset-specific commands associated with monitor-object method - * tables, as well. + * The generic GPS packet monitor. */ #include <sys/types.h> #include <stdio.h> @@ -530,44 +518,52 @@ int main (int argc, char **argv) } switch (line[0]) { - case 'b': - monitor_dump_send(); + case 'c': /* send control packet */ + len = 0; + /*@ -compdef @*/ + while (*p != '\0') + { + (void)sscanf(p,"%x",&v); + putbyte(buf, len, v); + len++; + while (*p != '\0' && !isspace(*p)) + p++; + while (*p != '\0' && isspace(*p)) + p++; + } if (active == NULL) monitor_complain("No device defined yet"); - else if (serial) { - v = (unsigned)atoi(line+1); - /* Ugh...should have a controlfd slot - * in the session structure, really - */ - if ((*active)->driver->speed_switcher) { - int dfd = session.gpsdata.gps_fd; - session.gpsdata.gps_fd = controlfd; - (void)(*active)->driver->speed_switcher(&session, v); - /* - * See the comment attached to the 'B' command in gpsd. - * Allow the control string time to register at the - * GPS before we do the baud rate switch, which - * effectively trashes the UART's buffer. - */ - (void)tcdrain(session.gpsdata.gps_fd); - (void)usleep(50000); - session.gpsdata.gps_fd = dfd; - (void)gpsd_set_speed(&session, v, - (unsigned char)session.gpsdata.parity, - session.gpsdata.stopbits); - } else - monitor_complain("Device type has no speed switcher"); - } else { - line[0] = 'b'; - /*@ -sefparams @*/ - assert(write(session.gpsdata.gps_fd, line, strlen(line)) != -1); - /* discard response */ - assert(read(session.gpsdata.gps_fd, buf, sizeof(buf)) != -1); - /*@ +sefparams @*/ + else if ((*active)->driver->control_send != NULL) + (void)monitor_control_send(buf, (size_t)len); + else + monitor_complain("Device type has no control-send method."); + /*@ +compdef @*/ + break; + + case 'i': /* start probing for subtype */ + if (active == NULL) + monitor_complain("No GPS type detected."); + else { + if (strcspn(line, "01") == strlen(line)) + context.readonly = !context.readonly; + else + context.readonly = (atoi(line+1) == 0); + (void)gpsd_switch_driver(&session, + (*active)->driver->type_name); + } + break; + + case 'l': /* open logfile */ + if (logfile != NULL) { + (void)wprintw(packetwin, ">>> Logging to %s off", logfile); + (void)fclose(logfile); } + + if ((logfile = fopen(line+1,"a")) != NULL) + (void)wprintw(packetwin, ">>> Logging to %s on", logfile); break; - case 'n': + case 'n': /* change mode */ /* if argument not specified, toggle */ if (strcspn(line, "01") == strlen(line)) v = (unsigned int)TEXTUAL_PACKET_TYPE(session.packet.type); @@ -602,52 +598,44 @@ int main (int argc, char **argv) } break; - case 'i': /* start probing for subtype */ - if (active == NULL) - monitor_complain("No GPS type detected."); - else { - if (strcspn(line, "01") == strlen(line)) - context.readonly = !context.readonly; - else - context.readonly = (atoi(line+1) == 0); - (void)gpsd_switch_driver(&session, - (*active)->driver->type_name); - } - break; - - case 'l': /* open logfile */ - if (logfile != NULL) { - (void)wprintw(packetwin, ">>> Logging to %s off", logfile); - (void)fclose(logfile); - } - - if ((logfile = fopen(line+1,"a")) != NULL) - (void)wprintw(packetwin, ">>> Logging to %s on", logfile); - break; - - case 'q': + case 'q': /* quit */ goto quit; - case 's': - len = 0; - /*@ -compdef @*/ - while (*p != '\0') - { - (void)sscanf(p,"%x",&v); - putbyte(buf, len, v); - len++; - while (*p != '\0' && !isspace(*p)) - p++; - while (*p != '\0' && isspace(*p)) - p++; - } + case 's': /* change speed */ + monitor_dump_send(); if (active == NULL) monitor_complain("No device defined yet"); - else if ((*active)->driver->control_send != NULL) - (void)monitor_control_send(buf, (size_t)len); - else - monitor_complain("Device type has no control-send method."); - /*@ +compdef @*/ + else if (serial) { + v = (unsigned)atoi(line+1); + /* Ugh...should have a controlfd slot + * in the session structure, really + */ + if ((*active)->driver->speed_switcher) { + int dfd = session.gpsdata.gps_fd; + session.gpsdata.gps_fd = controlfd; + (void)(*active)->driver->speed_switcher(&session, v); + /* + * See the comment attached to the 'B' command in gpsd. + * Allow the control string time to register at the + * GPS before we do the baud rate switch, which + * effectively trashes the UART's buffer. + */ + (void)tcdrain(session.gpsdata.gps_fd); + (void)usleep(50000); + session.gpsdata.gps_fd = dfd; + (void)gpsd_set_speed(&session, v, + (unsigned char)session.gpsdata.parity, + session.gpsdata.stopbits); + } else + monitor_complain("Device type has no speed switcher"); + } else { + line[0] = 'b'; + /*@ -sefparams @*/ + assert(write(session.gpsdata.gps_fd, line, strlen(line)) != -1); + /* discard response */ + assert(read(session.gpsdata.gps_fd, buf, sizeof(buf)) != -1); + /*@ +sefparams @*/ + } break; default: @@ -117,9 +117,10 @@ have such modes.</para> <para></para> </listitem> </varlistentry> <varlistentry> -<term>b</term> +<term>s</term> <listitem> -<para>Change baud rate.</para> +<para>Change baud rate. Follow it with a number interpreted as bits +per second, for example "s9600".</para> </listitem> </varlistentry> <varlistentry> @@ -135,9 +136,9 @@ correctly.</para> </listitem> </varlistentry> <varlistentry> -<term>s</term> +<term>c</term> <listitem> -<para>Send hex bytes to device. Following the 's' you may type hex +<para>Send hex bytes to device. Following the 'c' you may type hex digit pairs; end with a newline. These will become the payload of a control packet shipped to the device.</para> </listitem> @@ -154,13 +155,20 @@ control packet shipped to the device.</para> <para>Unfreeze display, resume normal operation.</para> </listitem> </varlistentry> +<varlistentry> +<term>q</term> +<listitem> +<para>Quit <application>gpsmon</application>. Control-C, or whatever +your current interrupt chracter is, works as well.</para> +</listitem> +</varlistentry> </variablelist> <para>The following commands are supported for SiRF GPSes only:</para> <variablelist> <varlistentry> -<term>c</term> +<term>m</term> <listitem> <para>Set (c1) or clear (c0) static navigation. The SiRF documentation says <quote>Static navigation is a position filter designed to be used @@ -211,7 +219,8 @@ work for Zodiacs and not always work for Garmins in binary mode. --> <para>This tool used to be called 'sirfmon', and worked only on SiRF -devices. It now has support for generic NMEA devices; +devices (and the command set has changed to resemble the command +switches of <command>gpsctl</command>). It now has support for generic NMEA devices; support for other device types is a work in progress. It will behave sanely, just dumping packets, when connected to a GPS type it knows nothing about.</para> diff --git a/monitor_proto.c b/monitor_proto.c index 439e780d..0b644923 100644 --- a/monitor_proto.c +++ b/monitor_proto.c @@ -119,8 +119,8 @@ const struct monitor_object_t PROTO_mmt = { .min_y = 23, .min_x = 80, /* size of the device window */ /* * The gpsd driver type for your device. gpsmon will use the mode_switcher - * method for 'n', the speed_switcher for 'b', and the control_send method - * for 's'. Additionally, the driver type name will be displayed before + * method for 'n', the speed_switcher for 's', and the control_send method + * for 'c'. Additionally, the driver type name will be displayed before * the '>' command prompt in the top line of the display. */ .driver = &PROTO, @@ -4,8 +4,8 @@ * * These are the SiRF-specific commands: * a -- toggle receipt of 50BPS subframe data (undocumented). - * c -- set or clear static navigation mode * d -- MID 4 rate change (undocumented) + * m -- set or clear static navigation mode * t -- toggle navigation-parameter display mode */ #include <stdio.h> @@ -646,7 +646,7 @@ static int sirf_command(char line[]) (void)monitor_control_send(buf, 25); return COMMAND_MATCH; - case 'c': /* static navigation */ + case 'm': /* static navigation */ putbyte(buf, 0,0x8f); /* id */ putbyte(buf, 1, atoi(line+1)); (void)monitor_control_send(buf, 2); |