diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | gpsmon.c | 18 | ||||
-rw-r--r-- | gpsmon.h | 5 | ||||
-rw-r--r-- | monitor_proto.c | 15 | ||||
-rw-r--r-- | nmeamon.c | 4 |
5 files changed, 30 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am index b2c90355..c5c84382 100644 --- a/Makefile.am +++ b/Makefile.am @@ -368,7 +368,7 @@ splint: gpsd.h packet_names.h @echo "Running splint on gpsctl..." -splint $(SPLINTOPTS) $(gpsctl_SOURCES) @echo "Running splint on gpsmon..." - -splint $(SPLINTOPTS) $(gpsmon_SOURCES) + -splint $(SPLINTOPTS) -exportlocal $(gpsmon_SOURCES) @echo "Running splint on gpspipe..." -splint $(SPLINTOPTS) $(gpspipe_SOURCES) @echo "Running splint on rtcmdecode..." @@ -92,7 +92,7 @@ static const struct monitor_object_t **active; #define display (void)mvwprintw -void fixframe(WINDOW *win) +void monitor_fixframe(WINDOW *win) { int ymax, xmax, ycur, xcur; @@ -274,7 +274,7 @@ static void command(char buf[], size_t len, const char *fmt, ... ) } } -static void error_and_pause(const char *fmt, ...) +void monitor_complain(const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -533,7 +533,7 @@ int main (int argc, char **argv) case 'b': monitor_dump_send(); if (active == NULL) - error_and_pause("No device defined yet"); + monitor_complain("No device defined yet"); else if (serial) { v = (unsigned)atoi(line+1); /* Ugh...should have a controlfd slot @@ -556,7 +556,7 @@ int main (int argc, char **argv) (unsigned char)session.gpsdata.parity, session.gpsdata.stopbits); } else - error_and_pause("Device type has no speed switcher"); + monitor_complain("Device type has no speed switcher"); } else { line[0] = 'b'; /*@ -sefparams @*/ @@ -574,7 +574,7 @@ int main (int argc, char **argv) else v = (unsigned)atoi(line+1); if (active == NULL) - error_and_pause("No device defined yet"); + monitor_complain("No device defined yet"); else if (serial) { // FIXME: some sort of debug window display here? /* Ugh...should have a controlfd slot @@ -589,7 +589,7 @@ int main (int argc, char **argv) (void)usleep(50000); session.gpsdata.gps_fd = dfd; } else - error_and_pause("Device type has no mode switcher"); + monitor_complain("Device type has no mode switcher"); } else { line[0] = 'n'; line[1] = ' '; @@ -604,7 +604,7 @@ int main (int argc, char **argv) case 'i': /* start probing for subtype */ if (active == NULL) - error_and_pause("No GPS type detected."); + monitor_complain("No GPS type detected."); else { context.readonly = false; (void)gpsd_switch_driver(&session, @@ -639,11 +639,11 @@ int main (int argc, char **argv) p++; } if (active == NULL) - error_and_pause("No device defined yet"); + monitor_complain("No device defined yet"); else if ((*active)->driver->control_send != NULL) (void)monitor_control_send(buf, (size_t)len); else - error_and_pause("Device type has no control-send method."); + monitor_complain("Device type has no control-send method."); /*@ +compdef @*/ break; } @@ -14,9 +14,10 @@ struct monitor_object_t { const struct gps_type_t *driver; /* device driver table */ }; -// Device-specific code will need these. +// Device-specific may need these. extern bool monitor_control_send(unsigned char *buf, size_t len); -extern void fixframe(WINDOW *win); +extern void monitor_fixframe(WINDOW *win); +extern void monitor_complain(const char *fmt, ...); #define BUFLEN 2048 diff --git a/monitor_proto.c b/monitor_proto.c index 01408495..39718954 100644 --- a/monitor_proto.c +++ b/monitor_proto.c @@ -32,6 +32,21 @@ * as gpsd to dispatch on packet type to select an active device driver. * Your monitor object will become the handler for incoming packets whenever * the driver your object points at is selected. + * + * bool monitor_control_send(unsigned char *buf, size_t len) + * Ship a packet payload to the device. Calls the driver send_control() + * method to add headers/trailers/checksum; also dumps the sent + * packet to the packet window, if the send_control() is playing + * nice by using session.msgbuf to assemble the message. + * + * void monitor_complain(const char *fmt, ...) + * Post an error message to the command window, wait till user presses a key. + * You get to make sure the message will fit. + * + * void monitor_fixframe(WINDOW *win) + * Fix the frame of win to the right of the current location by redrawing + * ACS_VLINE there. Useful after doing wclrtoeol() and writing on the + * line. */ extern const struct gps_type_t PROTO; @@ -170,7 +170,7 @@ static void nmea_update(void) (void)wmove(gprmcwin, 1, 7); (void)wclrtoeol(gprmcwin); (void)waddstr(gprmcwin, scr); - fixframe(gprmcwin); + monitor_fixframe(gprmcwin); /* Fill in the latitude. */ if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.latitude)==0) { @@ -226,7 +226,7 @@ static void nmea_update(void) mvwaddch(gpgsawin, 2, xmax-3-7, (chtype)'.'); mvwaddch(gpgsawin, 2, xmax-4-7, (chtype)'.'); } - fixframe(gpgsawin); + monitor_fixframe(gpgsawin); (void)wmove(gpgsawin, 3, 7); (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.hdop); (void)wmove(gpgsawin, 4, 7); |