2 * This file is Copyright (c) 2010 by the GPSD project
3 * BSD terms apply: see the file COPYING in the distribution root for details.
12 #endif /* S_SPLINT_S */
17 #include "gpsd_config.h"
23 #endif /* HAVE_NCURSES_H */
30 #include "driver_italk.h"
32 extern const struct gps_type_t italk_binary;
33 static WINDOW *satwin, *navfixwin;
35 #define display (void)mvwprintw
36 static bool italk_initialize(void)
41 /* "heavily inspired" by monitor_nmea.c */
43 derwin(devicewin, MAX_NR_VISIBLE_PRNS + 3, 27, 0, 0)) == NULL)
45 (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true);
46 (void)wattrset(satwin, A_BOLD);
47 display(satwin, 1, 1, "Ch PRN Az El S/N Flag U");
48 for (i = 0; i < MAX_NR_VISIBLE_PRNS; i++)
49 display(satwin, (int)(i + 2), 1, "%2d", i);
50 display(satwin, MAX_NR_VISIBLE_PRNS + 2, 7, " PRN_STATUS ");
51 (void)wattrset(satwin, A_NORMAL);
53 /* "heavily inspired" by monitor_nmea.c */
54 if ((navfixwin = derwin(devicewin, 13, 52, 0, 27)) == NULL)
56 (void)wborder(navfixwin, 0, 0, 0, 0, 0, 0, 0, 0),
57 (void)wattrset(navfixwin, A_BOLD);
58 (void)wmove(navfixwin, 1, 1);
59 (void)wprintw(navfixwin, "ECEF Pos:");
60 (void)wmove(navfixwin, 2, 1);
61 (void)wprintw(navfixwin, "ECEF Vel:");
63 (void)wmove(navfixwin, 4, 1);
64 (void)wprintw(navfixwin, "LTP Pos:");
65 (void)wmove(navfixwin, 5, 1);
66 (void)wprintw(navfixwin, "LTP Vel:");
68 (void)wmove(navfixwin, 7, 1);
69 (void)wprintw(navfixwin, "Time UTC:");
70 (void)wmove(navfixwin, 8, 1);
71 (void)wprintw(navfixwin, "Time GPS: Day:");
73 (void)wmove(navfixwin, 10, 1);
74 (void)wprintw(navfixwin, "DOP [H] [V] [P] [T] [G]");
75 (void)wmove(navfixwin, 11, 1);
76 (void)wprintw(navfixwin, "Fix:");
78 display(navfixwin, 12, 20, " NAV_FIX ");
79 (void)wattrset(navfixwin, A_NORMAL);
84 static void display_itk_navfix(unsigned char *buf, size_t len)
87 unsigned int tow, tod, nsec, d, svlist;
88 unsigned short gps_week, flags, cflags, pflags, nsv;
89 unsigned short year, mon, day, hour, min, sec;
90 double epx, epy, epz, evx, evy, evz;
91 double latitude, longitude;
92 float altitude, speed, track, climb;
93 float hdop, gdop, pdop, vdop, tdop;
98 flags = (ushort) getleuw(buf, 7 + 4);
99 cflags = (ushort) getleuw(buf, 7 + 6);
100 pflags = (ushort) getleuw(buf, 7 + 8);
102 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
103 nsv = (ushort) MAX(getleuw(buf, 7 + 12), getleuw(buf, 7 + 14));
104 svlist = (ushort) getleul(buf, 7 + 16) | getleul(buf, 7 + 24);
106 hour = (ushort) getleuw(buf, 7 + 66);
107 min = (ushort) getleuw(buf, 7 + 68);
108 sec = (ushort) getleuw(buf, 7 + 70);
109 nsec = (ushort) getleul(buf, 7 + 72);
110 year = (ushort) getleuw(buf, 7 + 76);
111 mon = (ushort) getleuw(buf, 7 + 78);
112 day = (ushort) getleuw(buf, 7 + 80);
113 gps_week = (ushort) getlesw(buf, 7 + 82);
114 tow = (ushort) getleul(buf, 7 + 84);
116 epx = (double)(getlesl(buf, 7 + 96) / 100.0);
117 epy = (double)(getlesl(buf, 7 + 100) / 100.0);
118 epz = (double)(getlesl(buf, 7 + 104) / 100.0);
119 evx = (double)(getlesl(buf, 7 + 186) / 1000.0);
120 evy = (double)(getlesl(buf, 7 + 190) / 1000.0);
121 evz = (double)(getlesl(buf, 7 + 194) / 1000.0);
123 latitude = (double)(getlesl(buf, 7 + 144) / 1e7);
124 longitude = (double)(getlesl(buf, 7 + 148) / 1e7);
125 altitude = (float)(getlesl(buf, 7 + 152) / 1e3);
126 climb = (float)(getlesl(buf, 7 + 206) / 1e3);
127 speed = (float)(getleul(buf, 7 + 210) / 1e3);
128 track = (float)(getleuw(buf, 7 + 214) / 1e2);
130 hdop = (float)(getleuw(buf, 7 + 56) / 100.0);
131 gdop = (float)(getleuw(buf, 7 + 58) / 100.0);
132 pdop = (float)(getleuw(buf, 7 + 60) / 100.0);
133 vdop = (float)(getleuw(buf, 7 + 62) / 100.0);
134 tdop = (float)(getleuw(buf, 7 + 64) / 100.0);
136 (void)wmove(navfixwin, 1, 11);
137 (void)wprintw(navfixwin, "%12.2lf %12.2lf %12.2lfm", epx, epy, epz);
138 (void)wmove(navfixwin, 2, 11);
139 (void)wprintw(navfixwin, "%11.2lf %11.2lf %11.2lfm/s", evx, evy, evz);
141 (void)wmove(navfixwin, 4, 11);
142 (void)wprintw(navfixwin, "%11.8lf %13.8lf %8.1lfm",
143 latitude, longitude, altitude);
144 (void)mvwaddch(navfixwin, 4, 22, ACS_DEGREE);
145 (void)mvwaddch(navfixwin, 4, 38, ACS_DEGREE);
146 (void)wmove(navfixwin, 5, 11);
147 (void)wprintw(navfixwin, "%6.2lfm/s %5.1lf %6.2lfm/s climb",
148 speed, track, climb);
149 (void)mvwaddch(navfixwin, 5, 27, ACS_DEGREE);
151 (void)wmove(navfixwin, 7, 11);
152 (void)wprintw(navfixwin, "%04u-%02u-%02u %02u:%02u:%02u",
153 year, mon, day, hour, min, sec);
154 (void)wmove(navfixwin, 8, 11);
155 (void)wprintw(navfixwin, "%04u+%010.3lf", gps_week, tow / 1000.0);
156 (void)wmove(navfixwin, 8, 33);
157 d = (tow / 1000) / 86400;
158 tod = (tow / 1000) - (d * 86400);
159 sec = (unsigned short)tod % 60;
160 min = (unsigned short)(tod / 60) % 60;
161 hour = (unsigned short)tod / 3600;
162 (void)wprintw(navfixwin, "%1d %02d:%02d:%02d", d, hour, min, sec);
164 (void)wmove(navfixwin, 10, 9);
165 (void)wprintw(navfixwin, "%-5.1f", hdop);
166 (void)wmove(navfixwin, 10, 18);
167 (void)wprintw(navfixwin, "%-5.1f", vdop);
168 (void)wmove(navfixwin, 10, 27);
169 (void)wprintw(navfixwin, "%-5.1f", pdop);
170 (void)wmove(navfixwin, 10, 36);
171 (void)wprintw(navfixwin, "%-5.1f", tdop);
172 (void)wmove(navfixwin, 10, 45);
173 (void)wprintw(navfixwin, "%-5.1f", gdop);
175 (void)wmove(navfixwin, 11, 6);
177 char prn[4], satlist[38];
180 for (i = 0; i < 32; i++) {
181 if (svlist & (1 << i)) {
182 (void)snprintf(prn, 4, "%u ", i + 1);
183 (void)strlcat(satlist, prn, 38);
186 (void)wprintw(navfixwin, "%02d = %-38s", nsv, satlist);
188 (void)wnoutrefresh(navfixwin);
192 static void display_itk_prnstatus(unsigned char *buf, size_t len)
198 nchan = (int)getleuw(buf, 7 + 50);
199 if (nchan > MAX_NR_VISIBLE_PRNS)
200 nchan = MAX_NR_VISIBLE_PRNS;
201 for (i = 0; i < nchan; i++) {
202 int off = 7 + 52 + 10 * i;
204 unsigned char ss, prn, el, az;
206 fl = (unsigned short)getleuw(buf, off);
207 ss = (unsigned char)getleuw(buf, off + 2) & 0xff;
208 prn = (unsigned char)getleuw(buf, off + 4) & 0xff;
209 el = (unsigned char)getlesw(buf, off + 6) & 0xff;
210 az = (unsigned char)getlesw(buf, off + 8) & 0xff;
211 (void)wmove(satwin, i + 2, 4);
212 (void)wprintw(satwin, "%3d %3d %2d %02d %04x %c",
214 (fl & PRN_FLAG_USE_IN_NAV) ? 'Y' : ' ');
216 for (; i < MAX_NR_VISIBLE_PRNS; i++) {
217 (void)wmove(satwin, (int)i + 2, 4);
218 (void)wprintw(satwin, " ");
220 (void)wnoutrefresh(satwin);
224 static void italk_update(void)
230 buf = session.packet.outbuffer;
231 len = session.packet.outbuflen;
232 type = (unsigned char)getub(buf, 4);
235 display_itk_navfix(buf, len);
237 case ITALK_PRN_STATUS:
238 display_itk_prnstatus(buf, len);
245 static int italk_command(char line[]UNUSED)
247 return COMMAND_UNKNOWN;
250 static void italk_wrap(void)
252 (void)delwin(satwin);
256 const struct monitor_object_t italk_mmt = {
257 .initialize = italk_initialize,
258 .update = italk_update,
259 .command = italk_command,
261 .min_y = 23,.min_x = 80, /* size of the device window */
262 .driver = &italk_binary,