2 * monitor_tnt.c - gpsmon support for True North Revolution devices.
4 * This file is Copyright (c) 2010 by the GPSD project
5 * BSD terms apply: see the file COPYING in the distribution root for details.
14 #endif /* S_SPLINT_S */
19 #include "gpsd_config.h"
25 #endif /* HAVE_NCURSES_H */
32 extern const struct gps_type_t trueNorth;
34 static WINDOW *thtmwin;
36 static bool tnt_initialize(void)
39 thtmwin = derwin(devicewin, 6, 80, 0, 0);
40 (void)wborder(thtmwin, 0, 0, 0, 0, 0, 0, 0, 0),
41 (void)syncok(thtmwin, true);
42 (void)wattrset(thtmwin, A_BOLD);
43 (void)mvwaddstr(thtmwin, 0, 35, " PTNTHTM ");
44 (void)mvwaddstr(thtmwin, 1, 1, "Heading: ");
45 (void)mvwaddstr(thtmwin, 2, 1, "Pitch: ");
46 (void)mvwaddstr(thtmwin, 3, 1, "Roll: ");
47 (void)mvwaddstr(thtmwin, 4, 1, "Dip: ");
49 (void)mvwaddstr(thtmwin, 1, 40, "Magnetometer Status: ");
50 (void)mvwaddstr(thtmwin, 2, 40, "Pitch Status: ");
51 (void)mvwaddstr(thtmwin, 3, 40, "Roll Status ");
52 (void)mvwaddstr(thtmwin, 4, 40, "Horizontal Field: ");
53 (void)wattrset(thtmwin, A_NORMAL);
58 static void tnt_update(void)
61 * We have to do our own field parsing because the way this
62 * gets valled, nmea_parse() is never called on the sentence.
64 (void)nmea_parse((char *)session.packet.outbuffer, &session);
66 (void)mvwaddstr(thtmwin, 1, 19, session.driver.nmea.field[1]);
67 (void)mvwaddstr(thtmwin, 2, 19, session.driver.nmea.field[3]);
68 (void)mvwaddstr(thtmwin, 3, 19, session.driver.nmea.field[5]);
69 (void)mvwaddstr(thtmwin, 4, 19, session.driver.nmea.field[7]);
71 (void)mvwaddstr(thtmwin, 1, 61, session.driver.nmea.field[2]);
72 (void)mvwaddstr(thtmwin, 2, 61, session.driver.nmea.field[4]);
73 (void)mvwaddstr(thtmwin, 3, 61, session.driver.nmea.field[6]);
74 (void)mvwaddstr(thtmwin, 4, 61, session.driver.nmea.field[8]);
77 static int tnt_command(char line[])
80 * Interpret a command line. Whatever characters the user types will
81 * be echoed in the command buffer at the top right of the display. When
82 * he/she presses enter the command line will be passed to this function
83 * for interpretation. Note: packet receipt is suspended while this
84 * function is executing.
86 * This method is optional. If you set the command method pointer to
87 * NULL, gpsmon will behave sanely, accepting no device-specific commands.
89 * It is a useful convention to use uppercase letters for
90 * driver-specific commands and leave lowercase ones for the
91 * generic gpsmon ones.
95 * Return COMMAND_UNKNOWN to tell gpsmon you can't interpret the line, and
96 * it will be passed to the generic command interpreter to be handled there.
97 * You can alse return COMMAND_MATCH to tell it you handled the command,
98 * or COMMAND_TERMINATE to tell gpsmon you handled it and gpsmon should
101 return COMMAND_UNKNOWN;
104 static void tnt_wrap(void)
106 (void)delwin(thtmwin);
110 * Use mmt = monitor method table as a suffix for naming these things
111 * Yours will need to be added to the monitor_objects table in gpsmon.c,
112 * then of course you need to link your module into gpsmon.
114 const struct monitor_object_t tnt_mmt = {
115 .initialize = tnt_initialize,
116 .update = tnt_update,
117 .command = tnt_command,
119 .min_y = 6,.min_x = 80, /* size of the device window */
120 .driver = &trueNorth,
122 #endif /* TNT_ENABLE */
127 * bool monitor_control_send(unsigned char *buf, size_t len)
128 * Ship a packet payload to the device. Calls the driver send_control()
129 * method to add headers/trailers/checksum; also dumps the sent
130 * packet to the packet window, if the send_control() is playing
131 * nice by using session.msgbuf to assemble the message.
133 * void monitor_log(const char *fmt, ...)
134 * Write a message to the packet window. Safe if the packet window
137 * void monitor_complain(const char *fmt, ...)
138 * Post an error message to the command window, wait till user presses a key.
139 * You get to make sure the message will fit.
141 * void monitor_fixframe(WINDOW *win)
142 * Fix the frame of win to the right of the current location by redrawing
143 * ACS_VLINE there. Useful after doing wclrtoeol() and writing on the
146 * The libgpsd session object is accessible as the global variable 'session'.