1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
/* $Id$ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#ifndef S_SPLINT_S
#include <unistd.h>
#endif /* S_SPLINT_S */
#include <stdarg.h>
#include <stdbool.h>
#include <assert.h>
#include "gpsd_config.h"
#ifdef HAVE_NCURSES_H
#include <ncurses.h>
#else
#include <curses.h>
#endif /* HAVE_NCURSES_H */
#include "gpsd.h"
#include "bits.h"
#include "gpsmon.h"
#ifdef ITRAX_ENABLE
#include "driver_italk.h"
extern const struct gps_type_t italk_binary;
static WINDOW *satwin, *navfixwin;
#define display (void)mvwprintw
static bool italk_initialize(void)
{
int i;
/* "heavily inspired" by monitor_nmea.c */
if ((satwin = derwin(devicewin, MAX_NR_VISIBLE_PRNS+3, 27, 0, 0)) == NULL)
return false;
(void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0),
(void)syncok(satwin, true);
(void)wattrset(satwin, A_BOLD);
display(satwin, 1, 1, "Ch PRN Az El S/N Flag U");
for (i = 0; i < MAX_NR_VISIBLE_PRNS; i++)
display(satwin, (int)(i+2), 1, "%2d",i);
display(satwin, MAX_NR_VISIBLE_PRNS+2, 7, " PRN_STATUS ");
(void)wattrset(satwin, A_NORMAL);
/* "heavily inspired" by monitor_nmea.c */
if ((navfixwin = derwin(devicewin, 13, 52, 0, 27)) == NULL)
return false;
(void)wborder(navfixwin, 0, 0, 0, 0, 0, 0, 0, 0),
(void)wattrset(navfixwin, A_BOLD);
(void)wmove(navfixwin, 1,1);
(void)wprintw(navfixwin, "ECEF Pos:");
(void)wmove(navfixwin, 2,1);
(void)wprintw(navfixwin, "ECEF Vel:");
(void)wmove(navfixwin, 4,1);
(void)wprintw(navfixwin, "LTP Pos:");
(void)wmove(navfixwin, 5,1);
(void)wprintw(navfixwin, "LTP Vel:");
(void)wmove(navfixwin, 7,1);
(void)wprintw(navfixwin, "Time UTC:");
(void)wmove(navfixwin, 8,1);
(void)wprintw(navfixwin, "Time GPS: Day:");
(void)wmove(navfixwin, 10,1);
(void)wprintw(navfixwin, "DOP [H] [V] [P] [T] [G]");
(void)wmove(navfixwin, 11,1);
(void)wprintw(navfixwin, "Fix:");
display(navfixwin, 12, 20, " NAV_FIX ");
(void)wattrset(navfixwin, A_NORMAL);
return true;
}
static void display_itk_navfix(unsigned char *buf, size_t len){
unsigned int tow, tod, nsec, d, svlist;
unsigned short gps_week, flags, cflags, pflags, nsv;
unsigned short year, mon, day, hour, min, sec;
double epx, epy, epz, evx, evy, evz;
double latitude, longitude;
float altitude, speed, track, climb;
float hdop, gdop, pdop, vdop, tdop;
if (len != 296)
return;
flags = getleuw(buf, 7 + 4);
cflags = getleuw(buf, 7 + 6);
pflags = getleuw(buf, 7 + 8);
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
nsv = MAX(getleuw(buf, 7 + 12), getleuw(buf, 7 + 14));
svlist = getleul(buf, 7 + 16) | getleul(buf, 7 + 24);
hour = getleuw(buf, 7 + 66);
min = getleuw(buf, 7 + 68);
sec = getleuw(buf, 7 + 70);
nsec = getleul(buf, 7 + 72);
year = getleuw(buf, 7 + 76);
mon = getleuw(buf, 7 + 78);
day = getleuw(buf, 7 + 80);
gps_week = (ushort)getlesw(buf, 7 + 82);
tow = getleul(buf, 7 + 84);
epx = (double)(getlesl(buf, 7 + 96)/100.0);
epy = (double)(getlesl(buf, 7 + 100)/100.0);
epz = (double)(getlesl(buf, 7 + 104)/100.0);
evx = (double)(getlesl(buf, 7 + 186)/1000.0);
evy = (double)(getlesl(buf, 7 + 190)/1000.0);
evz = (double)(getlesl(buf, 7 + 194)/1000.0);
latitude = (double)(getlesl(buf, 7 + 144)/1e7);
longitude = (double)(getlesl(buf, 7 + 148)/1e7);
altitude = (float)(getlesl(buf, 7 + 152)/1e3);
climb = (float)(getlesl(buf, 7 + 206)/1e3);
speed = (float)(getleul(buf, 7 + 210)/1e3);
track = (float)(getleuw(buf, 7 + 214)/1e2);
hdop = (float)(getleuw(buf, 7 + 56)/100.0);
gdop = (float)(getleuw(buf, 7 + 58)/100.0);
pdop = (float)(getleuw(buf, 7 + 60)/100.0);
vdop = (float)(getleuw(buf, 7 + 62)/100.0);
tdop = (float)(getleuw(buf, 7 + 64)/100.0);
(void)wmove(navfixwin, 1,11);
(void)wprintw(navfixwin, "%12.2lf %12.2lf %12.2lfm", epx, epy, epz);
(void)wmove(navfixwin, 2,11);
(void)wprintw(navfixwin, "%11.2lf %11.2lf %11.2lfm/s", evx, evy, evz);
(void)wmove(navfixwin, 4,11);
(void)wprintw(navfixwin, "%11.8lf %13.8lf %8.1lfm",
latitude, longitude, altitude);
(void)mvwaddch(navfixwin, 4, 22, ACS_DEGREE);
(void)mvwaddch(navfixwin, 4, 38, ACS_DEGREE);
(void)wmove(navfixwin, 5,11);
(void)wprintw(navfixwin, "%6.2lfm/s %5.1lf %6.2lfm/s climb",
speed, track, climb);
(void)mvwaddch(navfixwin, 5, 27, ACS_DEGREE);
(void)wmove(navfixwin, 7,11);
(void)wprintw(navfixwin, "%04u-%02u-%02u %02u:%02u:%02u",
year, mon, day, hour, min, sec);
(void)wmove(navfixwin, 8,11);
(void)wprintw(navfixwin, "%04u+%010.3lf", gps_week, tow/1000.0);
(void)wmove(navfixwin, 8,33);
d = (tow/1000) / 86400;
tod = (tow/1000) - (d*86400);
sec = tod % 60;
min = (tod / 60) % 60;
hour = tod / 3600;
(void)wprintw(navfixwin, "%1d %02d:%02d:%02d", d, hour, min, sec);
(void)wmove(navfixwin, 10,9);
(void)wprintw(navfixwin, "%-5.1f", hdop);
(void)wmove(navfixwin, 10,18);
(void)wprintw(navfixwin, "%-5.1f", vdop);
(void)wmove(navfixwin, 10,27);
(void)wprintw(navfixwin, "%-5.1f", pdop);
(void)wmove(navfixwin, 10,36);
(void)wprintw(navfixwin, "%-5.1f", tdop);
(void)wmove(navfixwin, 10,45);
(void)wprintw(navfixwin, "%-5.1f", gdop);
(void)wmove(navfixwin, 11,6);
{
char prn[4], satlist[38];
unsigned int i;
satlist[0] = '\0';
for(i = 0; i<32; i++){
if (svlist & (1<<i)){
snprintf(prn, 4, "%u ", i+1);
strlcat(satlist, prn, 38);
}
}
(void)wprintw(navfixwin, "%02d = %-38s", nsv, satlist);
}
wnoutrefresh(navfixwin);
}
static void display_itk_prnstatus(unsigned char *buf, size_t len)
{
unsigned int i, nchan;
if (len < 62)
return;
nchan = (unsigned int)getleuw(buf, 7 +50);
if (nchan > MAX_NR_VISIBLE_PRNS)
nchan = MAX_NR_VISIBLE_PRNS;
for (i = 0; i < nchan; i++) {
unsigned int off = 7+ 52 + 10 * i;
unsigned short fl;
unsigned char ss, prn, el, az;
fl = getleuw(buf, off);
ss = (unsigned char)getleuw(buf, off+2)&0xff;
prn = (unsigned char)getleuw(buf, off+4)&0xff;
el = (unsigned char)getlesw(buf, off+6)&0xff;
az = (unsigned char)getlesw(buf, off+8)&0xff;
(void)wmove(satwin, i+2, 4);
(void)wprintw(satwin, "%3d %3d %2d %02d %04x %c",
prn, az, el, ss, fl,
(fl & PRN_FLAG_USE_IN_NAV)? 'Y' : ' ');
}
for ( ; i < MAX_NR_VISIBLE_PRNS; i++){
(void)wmove(satwin, (int)i+2, 4);
(void)wprintw(satwin, " ");
}
(void)wnoutrefresh(satwin);
return;
}
static void italk_update(void)
{
unsigned char *buf;
size_t len;
unsigned char type;
buf = session.packet.outbuffer;
len = session.packet.outbuflen;
type = getub(buf, 4);
switch (type) {
case ITALK_NAV_FIX:
display_itk_navfix(buf, len);
break;
case ITALK_PRN_STATUS:
display_itk_prnstatus(buf, len);
break;
default:
break;
}
}
static int italk_command(char line[] UNUSED)
{
return COMMAND_UNKNOWN;
}
static void italk_wrap(void)
{
(void)delwin(satwin);
return;
}
const struct monitor_object_t italk_mmt = {
.initialize = italk_initialize,
.update = italk_update,
.command = italk_command,
.wrap = italk_wrap,
.min_y = 23, .min_x = 80, /* size of the device window */
.driver = &italk_binary,
};
#endif
|