summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gpsmon.c73
-rw-r--r--gpsmon.h2
-rw-r--r--monitor_proto.c2
-rw-r--r--nmeamon.c280
-rw-r--r--sirfmon.c544
5 files changed, 448 insertions, 453 deletions
diff --git a/gpsmon.c b/gpsmon.c
index ebc06c45..8834b3cd 100644
--- a/gpsmon.c
+++ b/gpsmon.c
@@ -448,47 +448,46 @@ int main (int argc, char **argv)
(void)wattrset(statwin, A_NORMAL);
(void)wmove(cmdwin, 0,0);
- /* get a packet -- calls gpsd_poll */
+ /* get a packet -- calls gpsd_poll() */
if ((len = readpkt()) > 0 && session.packet.outbuflen > 0) {
- (void)wprintw(packetwin, "(%d) ", session.packet.outbuflen);
- packet_dump((char *)session.packet.outbuffer,session.packet.outbuflen);
- }
-
- /* switch types on packet receipt */
- if (session.packet.type != last_type) {
- const struct monitor_object_t **trial, **newobject;
- last_type = session.packet.type;
- newobject = NULL;
- for (trial = monitor_objects; *trial; trial++)
- if ((*trial)->driver == session.device_type)
- newobject = trial;
- if (newobject) {
- if (active != NULL) {
- (*active)->wrap();
- (void)delwin(devicewin);
+ /* switch types on packet receipt */
+ if (session.packet.type != last_type) {
+ const struct monitor_object_t **trial, **newobject;
+ last_type = session.packet.type;
+ newobject = NULL;
+ for (trial = monitor_objects; *trial; trial++)
+ if ((*trial)->driver == session.device_type)
+ newobject = trial;
+ if (newobject) {
+ if (active != NULL) {
+ (*active)->wrap();
+ (void)delwin(devicewin);
+ }
+ active = newobject;
+ devicewin = newwin((*active)->min_y+1, (*active)->min_x+1,1,0);
+ if (!(*active)->initialize())
+ goto quit;
+ (void)wresize(packetwin, LINES-(*active)->min_y-1, 80);
+ (void)mvwin(packetwin, (*active)->min_y+1, 0);
+ (void)wsetscrreg(packetwin, 0, LINES-(*active)->min_y-2);
}
- active = newobject;
- devicewin = newwin((*active)->min_y+1, (*active)->min_x+1,1,0);
- if (!(*active)->initialize())
- goto quit;
- (void)wresize(packetwin, LINES-(*active)->min_y-1, 80);
- (void)mvwin(packetwin, (*active)->min_y+1, 0);
- (void)wsetscrreg(packetwin, 0, LINES-(*active)->min_y-2);
}
- }
- /* refresh all windows */
- (void)wprintw(cmdwin, type_name);
- (void)wprintw(cmdwin, "> ");
- (void)wclrtoeol(cmdwin);
- if (active != NULL)
- (*active)->update((size_t)len);
- (void)wnoutrefresh(statwin);
- (void)wnoutrefresh(cmdwin);
- if (devicewin != 0)
- (void)wnoutrefresh(devicewin);
- (void)wnoutrefresh(packetwin);
- (void)doupdate();
+ /* refresh all windows */
+ (void)wprintw(cmdwin, type_name);
+ (void)wprintw(cmdwin, "> ");
+ (void)wclrtoeol(cmdwin);
+ if (active != NULL && len > 0 && session.packet.outbuflen > 0)
+ (*active)->update();
+ (void)wprintw(packetwin, "(%d) ", session.packet.outbuflen);
+ packet_dump((char *)session.packet.outbuffer,session.packet.outbuflen);
+ (void)wnoutrefresh(statwin);
+ (void)wnoutrefresh(cmdwin);
+ if (devicewin != 0)
+ (void)wnoutrefresh(devicewin);
+ (void)wnoutrefresh(packetwin);
+ (void)doupdate();
+ }
/* rest of this invoked only if user has pressed a key */
FD_SET(0,&select_set);
diff --git a/gpsmon.h b/gpsmon.h
index d7ac826b..a6e938b5 100644
--- a/gpsmon.h
+++ b/gpsmon.h
@@ -7,7 +7,7 @@
struct monitor_object_t {
/* a device-specific capability table for the monitor */
bool (*initialize)(void); /* paint legends on windows */
- void (*update)(size_t); /* now paint the data */
+ void (*update)(void); /* now paint the data */
int (*command)(char[]); /* interpret device-specfic commands */
void (*wrap)(void); /* deallocate storage */
int min_y, min_x; /* space required for device info */
diff --git a/monitor_proto.c b/monitor_proto.c
index c4c1cf02..01408495 100644
--- a/monitor_proto.c
+++ b/monitor_proto.c
@@ -56,7 +56,7 @@ static bool PROTO_initialize(void)
return true;
}
-static void PROTO_update(size_t len)
+static void PROTO_update(void)
{
/*
* Called on each packet received. The packet will be accessible in
diff --git a/nmeamon.c b/nmeamon.c
index 89492077..a8581f69 100644
--- a/nmeamon.c
+++ b/nmeamon.c
@@ -94,160 +94,158 @@ static bool nmea_initialize(void)
}
/*@ -globstate -nullpass (splint is confused) */
-static void nmea_update(size_t len)
+static void nmea_update(void)
{
+ static char sentences[NMEA_MAX];
+ char **fields;
+
assert(nmeawin!=NULL);
assert(gpgsawin!=NULL);
assert(gpggawin!=NULL);
assert(gprmcwin!=NULL);
- if (len > 0 && session.packet.outbuflen > 0)
- {
- static char sentences[NMEA_MAX];
- char **fields;
-
- fields = session.driver.nmea.field;
-
- if (session.packet.outbuffer[0] == (unsigned char)'$') {
- int ymax, xmax;
- double now;
- char newid[NMEA_MAX];
- getmaxyx(nmeawin, ymax, xmax);
- (void)strlcpy(newid, (char *)session.packet.outbuffer+1,
- strcspn((char *)session.packet.outbuffer+1, ",")+1);
- if (strstr(sentences, newid) == NULL) {
- char *s_end = sentences + strlen(sentences);
- if ((int)(strlen(sentences) + strlen(newid)) < xmax-2) {
- *s_end++ = ' ';
- (void)strcpy(s_end, newid);
- } else {
- *--s_end = '.';
- *--s_end = '.';
- *--s_end = '.';
- }
- mvwaddstr(nmeawin, SENTENCELINE, 1, sentences);
- }
- /*
- * If the interval between this and last update is
- * the longest we've seen yet, boldify the corresponding
- * tag.
- */
- now = timestamp();
- if (now > last_tick && (now - last_tick) > tick_interval)
- {
- char *findme = strstr(sentences, newid);
-
- tick_interval = now - last_tick;
- if (findme != NULL) {
- mvwchgat(nmeawin, SENTENCELINE, 1, xmax-13, A_NORMAL, 0, NULL);
- mvwchgat(nmeawin,
- SENTENCELINE, 1+(findme-sentences),
- (int)strlen(newid),
- A_BOLD, 0, NULL);
- }
+ fields = session.driver.nmea.field;
+
+ if (session.packet.outbuffer[0] == (unsigned char)'$') {
+ int ymax, xmax;
+ double now;
+ char newid[NMEA_MAX];
+ getmaxyx(nmeawin, ymax, xmax);
+ (void)strlcpy(newid, (char *)session.packet.outbuffer+1,
+ strcspn((char *)session.packet.outbuffer+1, ",")+1);
+ if (strstr(sentences, newid) == NULL) {
+ char *s_end = sentences + strlen(sentences);
+ if ((int)(strlen(sentences) + strlen(newid)) < xmax-2) {
+ *s_end++ = ' ';
+ (void)strcpy(s_end, newid);
+ } else {
+ *--s_end = '.';
+ *--s_end = '.';
+ *--s_end = '.';
}
- last_tick = now;
-
- if (strcmp(newid, "GPGSV") == 0) {
- int i;
-
- for (i = 0; i < session.gpsdata.satellites; i++) {
- (void)wmove(satwin, i+2, 3);
- (void)wprintw(satwin, " %3d %3d%3d %3d",
- session.gpsdata.PRN[i],
- session.gpsdata.azimuth[i],
- session.gpsdata.elevation[i],
- session.gpsdata.ss[i]);
- }
+ mvwaddstr(nmeawin, SENTENCELINE, 1, sentences);
+ }
+
+ /*
+ * If the interval between this and last update is
+ * the longest we've seen yet, boldify the corresponding
+ * tag.
+ */
+ now = timestamp();
+ if (now > last_tick && (now - last_tick) > tick_interval)
+ {
+ char *findme = strstr(sentences, newid);
+
+ tick_interval = now - last_tick;
+ if (findme != NULL) {
+ mvwchgat(nmeawin, SENTENCELINE, 1, xmax-13, A_NORMAL, 0, NULL);
+ mvwchgat(nmeawin,
+ SENTENCELINE, 1+(findme-sentences),
+ (int)strlen(newid),
+ A_BOLD, 0, NULL);
}
+ }
+ last_tick = now;
- if (strcmp(newid, "GPRMC") == 0) {
- /* Not dumped yet: magnetic variation */
- char scr[128];
- if (isnan(session.gpsdata.fix.time)==0) {
- (void)unix_to_iso8601(session.gpsdata.fix.time, scr, sizeof(scr));
- } else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)wmove(gprmcwin, 1, 7);
- (void)wclrtoeol(gprmcwin);
- (void)waddstr(gprmcwin, scr);
- fixframe(gprmcwin);
-
- /* Fill in the latitude. */
- if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.latitude)==0) {
- (void)snprintf(scr, sizeof(scr), "%s %c",
- deg_to_str(deg_ddmmss, fabs(session.gpsdata.fix.latitude)),
- (session.gpsdata.fix.latitude < 0) ? 'S' : 'N');
- } else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)mvwprintw(gprmcwin, 2, 11, "%-17s", scr);
-
- /* Fill in the longitude. */
- if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.longitude)==0) {
- (void)snprintf(scr, sizeof(scr), "%s %c",
- deg_to_str(deg_ddmmss, fabs(session.gpsdata.fix.longitude)),
- (session.gpsdata.fix.longitude < 0) ? 'W' : 'E');
- } else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)mvwprintw(gprmcwin, 3, 11, "%-17s", scr);
-
- /* Fill in the speed. */
- if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.track)==0)
- (void)snprintf(scr, sizeof(scr), "%.1f meters/sec", session.gpsdata.fix.speed);
- else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)mvwprintw(gprmcwin, 4, 11, "%-17s", scr);
-
- if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.track)==0)
- (void)snprintf(scr, sizeof(scr), "%.1f deg", session.gpsdata.fix.track);
- else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)mvwprintw(gprmcwin, 5, 11, "%-17s", scr);
-
- /* the status field and FAA code */
- (void)mvwaddstr(gprmcwin, 6, 11, fields[2]);
- (void)mvwaddstr(gprmcwin, 6, 23, fields[12]);
+ if (strcmp(newid, "GPGSV") == 0) {
+ int i;
+
+ for (i = 0; i < session.gpsdata.satellites; i++) {
+ (void)wmove(satwin, i+2, 3);
+ (void)wprintw(satwin, " %3d %3d%3d %3d",
+ session.gpsdata.PRN[i],
+ session.gpsdata.azimuth[i],
+ session.gpsdata.elevation[i],
+ session.gpsdata.ss[i]);
}
+ }
- if (strcmp(newid, "GPGSA") == 0) {
- char scr[128];
- int i;
- (void)mvwprintw(gpgsawin, 1,7, "%1s %s", fields[1], fields[2]);
- (void)wmove(gpgsawin, 2, 7);
- (void)wclrtoeol(gpgsawin);
- scr[0] = '\0';
- for (i = 0; i < session.gpsdata.satellites_used; i++) {
- (void)snprintf(scr + strlen(scr), sizeof(scr)-strlen(scr),
- "%d ", session.gpsdata.used[i]);
- }
- getmaxyx(gpgsawin, ymax, xmax);
- (void)mvwaddnstr(gpgsawin, 2, 7, scr, xmax-2-7);
- if (strlen(scr) >= (size_t)(xmax-2)) {
- mvwaddch(gpgsawin, 2, xmax-2-7, (chtype)'.');
- mvwaddch(gpgsawin, 2, xmax-3-7, (chtype)'.');
- mvwaddch(gpgsawin, 2, xmax-4-7, (chtype)'.');
- }
- fixframe(gpgsawin);
- (void)wmove(gpgsawin, 3, 7);
- (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.hdop);
- (void)wmove(gpgsawin, 4, 7);
- (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.vdop);
- (void)wmove(gpgsawin, 5, 7);
- (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.pdop);
+ if (strcmp(newid, "GPRMC") == 0) {
+ /* Not dumped yet: magnetic variation */
+ char scr[128];
+ if (isnan(session.gpsdata.fix.time)==0) {
+ (void)unix_to_iso8601(session.gpsdata.fix.time, scr, sizeof(scr));
+ } else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)wmove(gprmcwin, 1, 7);
+ (void)wclrtoeol(gprmcwin);
+ (void)waddstr(gprmcwin, scr);
+ fixframe(gprmcwin);
+
+ /* Fill in the latitude. */
+ if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.latitude)==0) {
+ (void)snprintf(scr, sizeof(scr), "%s %c",
+ deg_to_str(deg_ddmmss, fabs(session.gpsdata.fix.latitude)),
+ (session.gpsdata.fix.latitude < 0) ? 'S' : 'N');
+ } else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)mvwprintw(gprmcwin, 2, 11, "%-17s", scr);
+
+ /* Fill in the longitude. */
+ if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.longitude)==0) {
+ (void)snprintf(scr, sizeof(scr), "%s %c",
+ deg_to_str(deg_ddmmss, fabs(session.gpsdata.fix.longitude)),
+ (session.gpsdata.fix.longitude < 0) ? 'W' : 'E');
+ } else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)mvwprintw(gprmcwin, 3, 11, "%-17s", scr);
+
+ /* Fill in the speed. */
+ if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.track)==0)
+ (void)snprintf(scr, sizeof(scr), "%.1f meters/sec", session.gpsdata.fix.speed);
+ else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)mvwprintw(gprmcwin, 4, 11, "%-17s", scr);
+
+ if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.track)==0)
+ (void)snprintf(scr, sizeof(scr), "%.1f deg", session.gpsdata.fix.track);
+ else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)mvwprintw(gprmcwin, 5, 11, "%-17s", scr);
+
+ /* the status field and FAA code */
+ (void)mvwaddstr(gprmcwin, 6, 11, fields[2]);
+ (void)mvwaddstr(gprmcwin, 6, 23, fields[12]);
+ }
+
+ if (strcmp(newid, "GPGSA") == 0) {
+ char scr[128];
+ int i;
+ (void)mvwprintw(gpgsawin, 1,7, "%1s %s", fields[1], fields[2]);
+ (void)wmove(gpgsawin, 2, 7);
+ (void)wclrtoeol(gpgsawin);
+ scr[0] = '\0';
+ for (i = 0; i < session.gpsdata.satellites_used; i++) {
+ (void)snprintf(scr + strlen(scr), sizeof(scr)-strlen(scr),
+ "%d ", session.gpsdata.used[i]);
}
- if (strcmp(newid, "GPGGA") == 0) {
- char scr[128];
- /* Fill in the altitude. */
- if (session.gpsdata.fix.mode == MODE_3D && isnan(session.gpsdata.fix.altitude)==0)
- (void)snprintf(scr, sizeof(scr), "%.1f meters",session.gpsdata.fix.altitude);
- else
- (void)snprintf(scr, sizeof(scr), "n/a");
- (void)mvwprintw(gpggawin, 1, 11, "%-17s", scr);
- (void)mvwprintw(gpggawin, 2, 10, "%1.1s", fields[6]);
- (void)mvwprintw(gpggawin, 2, 19, "%2.2s", fields[7]);
- (void)mvwprintw(gpggawin, 3, 10, "%-5.5s", fields[8]);
- (void)mvwprintw(gpggawin, 4, 10, "%-5.5s", fields[11]);
+ getmaxyx(gpgsawin, ymax, xmax);
+ (void)mvwaddnstr(gpgsawin, 2, 7, scr, xmax-2-7);
+ if (strlen(scr) >= (size_t)(xmax-2)) {
+ mvwaddch(gpgsawin, 2, xmax-2-7, (chtype)'.');
+ mvwaddch(gpgsawin, 2, xmax-3-7, (chtype)'.');
+ mvwaddch(gpgsawin, 2, xmax-4-7, (chtype)'.');
}
+ fixframe(gpgsawin);
+ (void)wmove(gpgsawin, 3, 7);
+ (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.hdop);
+ (void)wmove(gpgsawin, 4, 7);
+ (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.vdop);
+ (void)wmove(gpgsawin, 5, 7);
+ (void)wprintw(gpgsawin, "%2.2f", session.gpsdata.pdop);
+ }
+ if (strcmp(newid, "GPGGA") == 0) {
+ char scr[128];
+ /* Fill in the altitude. */
+ if (session.gpsdata.fix.mode == MODE_3D && isnan(session.gpsdata.fix.altitude)==0)
+ (void)snprintf(scr, sizeof(scr), "%.1f meters",session.gpsdata.fix.altitude);
+ else
+ (void)snprintf(scr, sizeof(scr), "n/a");
+ (void)mvwprintw(gpggawin, 1, 11, "%-17s", scr);
+ (void)mvwprintw(gpggawin, 2, 10, "%1.1s", fields[6]);
+ (void)mvwprintw(gpggawin, 2, 19, "%2.2s", fields[7]);
+ (void)mvwprintw(gpggawin, 3, 10, "%-5.5s", fields[8]);
+ (void)mvwprintw(gpggawin, 4, 10, "%-5.5s", fields[11]);
}
}
}
diff --git a/sirfmon.c b/sirfmon.c
index 003e7de8..75a54495 100644
--- a/sirfmon.c
+++ b/sirfmon.c
@@ -277,189 +277,188 @@ static void decode_ecef(double x, double y, double z,
}
/*@ -globstate */
-static void sirf_update(size_t len)
+static void sirf_update(void)
{
- if (len > 0 && session.packet.outbuflen > 0)
+ int i,j,ch,off,cn;
+ unsigned char *buf;
+ size_t len;
+
+ assert(mid27win != NULL);
+ buf = session.packet.outbuffer + 4;
+ len = session.packet.outbuflen - 8;
+ switch (buf[0])
{
- int i,j,ch,off,cn;
- unsigned char *buf;
+ case 0x02: /* Measured Navigation Data */
+ (void)wmove(mid2win, 1,6); /* ECEF position */
+ (void)wprintw(mid2win, "%8d %8d %8d",getbesl(buf, 1),getbesl(buf, 5),getbesl(buf, 9));
+ (void)wmove(mid2win, 2,6); /* ECEF velocity */
+ (void)wprintw(mid2win, "%8.1f %8.1f %8.1f",
+ (double)getbesw(buf, 13)/8,(double)getbesw(buf, 15)/8,(double)getbesw(buf, 17)/8);
+ decode_ecef((double)getbesl(buf, 1),(double)getbesl(buf, 5),(double)getbesl(buf, 9),
+ (double)getbesw(buf, 13)/8,(double)getbesw(buf, 15)/8,(double)getbesw(buf, 17)/8);
+ decode_time((int)getbeuw(buf, 22),getbesl(buf, 24));
+ /* line 4 */
+ (void)wmove(mid2win, 4,49);
+ (void)wprintw(mid2win, "%4.1f",(double)getub(buf, 20)/5); /* HDOP */
+ (void)wmove(mid2win, 4,58);
+ (void)wprintw(mid2win, "%02x",getub(buf, 19)); /* Mode 1 */
+ (void)wmove(mid2win, 4,70);
+ (void)wprintw(mid2win, "%02x",getub(buf, 21)); /* Mode 2 */
+ (void)wmove(mid2win, 5,7);
+ nfix = (int)getub(buf, 28);
+ (void)wprintw(mid2win, "%d = ",nfix); /* SVs in fix */
+ for (i = 0; i < SIRF_CHANNELS; i++) { /* SV list */
+ if (i < nfix)
+ (void)wprintw(mid2win, "%3d",fix[i] = (int)getub(buf, 29+i));
+ else
+ (void)wprintw(mid2win, " ");
+ }
+ (void)wprintw(packetwin, "MND 0x02=");
+ break;
- assert(mid27win != NULL);
- buf = session.packet.outbuffer + 4;
- len = session.packet.outbuflen - 8;
- switch (buf[0])
- {
- case 0x02: /* Measured Navigation Data */
- (void)wmove(mid2win, 1,6); /* ECEF position */
- (void)wprintw(mid2win, "%8d %8d %8d",getbesl(buf, 1),getbesl(buf, 5),getbesl(buf, 9));
- (void)wmove(mid2win, 2,6); /* ECEF velocity */
- (void)wprintw(mid2win, "%8.1f %8.1f %8.1f",
- (double)getbesw(buf, 13)/8,(double)getbesw(buf, 15)/8,(double)getbesw(buf, 17)/8);
- decode_ecef((double)getbesl(buf, 1),(double)getbesl(buf, 5),(double)getbesl(buf, 9),
- (double)getbesw(buf, 13)/8,(double)getbesw(buf, 15)/8,(double)getbesw(buf, 17)/8);
- decode_time((int)getbeuw(buf, 22),getbesl(buf, 24));
- /* line 4 */
- (void)wmove(mid2win, 4,49);
- (void)wprintw(mid2win, "%4.1f",(double)getub(buf, 20)/5); /* HDOP */
- (void)wmove(mid2win, 4,58);
- (void)wprintw(mid2win, "%02x",getub(buf, 19)); /* Mode 1 */
- (void)wmove(mid2win, 4,70);
- (void)wprintw(mid2win, "%02x",getub(buf, 21)); /* Mode 2 */
- (void)wmove(mid2win, 5,7);
- nfix = (int)getub(buf, 28);
- (void)wprintw(mid2win, "%d = ",nfix); /* SVs in fix */
- for (i = 0; i < SIRF_CHANNELS; i++) { /* SV list */
- if (i < nfix)
- (void)wprintw(mid2win, "%3d",fix[i] = (int)getub(buf, 29+i));
- else
- (void)wprintw(mid2win, " ");
- }
- (void)wprintw(packetwin, "MND 0x02=");
- break;
-
- case 0x04: /* Measured Tracking Data */
- decode_time((int)getbeuw(buf, 1),getbesl(buf, 3));
- ch = (int)getub(buf, 7);
- for (i = 0; i < ch; i++) {
- int sv,st;
+ case 0x04: /* Measured Tracking Data */
+ decode_time((int)getbeuw(buf, 1),getbesl(buf, 3));
+ ch = (int)getub(buf, 7);
+ for (i = 0; i < ch; i++) {
+ int sv,st;
- off = 8 + 15 * i;
- (void)wmove(mid4win, i+2, 3);
- sv = (int)getub(buf, off);
- (void)wprintw(mid4win, " %3d",sv);
-
- (void)wprintw(mid4win, " %3d%3d %04x",((int)getub(buf, off+1)*3)/2,(int)getub(buf, off+2)/2,(int)getbesw(buf, off+3));
-
- st = ' ';
- if ((int)getbeuw(buf, off+3) == 0xbf)
- st = 'T';
- for (j = 0; j < nfix; j++)
- if (sv == fix[j]) {
- st = 'N';
- break;
- }
+ off = 8 + 15 * i;
+ (void)wmove(mid4win, i+2, 3);
+ sv = (int)getub(buf, off);
+ (void)wprintw(mid4win, " %3d",sv);
+
+ (void)wprintw(mid4win, " %3d%3d %04x",((int)getub(buf, off+1)*3)/2,(int)getub(buf, off+2)/2,(int)getbesw(buf, off+3));
+
+ st = ' ';
+ if ((int)getbeuw(buf, off+3) == 0xbf)
+ st = 'T';
+ for (j = 0; j < nfix; j++)
+ if (sv == fix[j]) {
+ st = 'N';
+ break;
+ }
- cn = 0;
+ cn = 0;
- for (j = 0; j < 10; j++)
- cn += (int)getub(buf, off+5+j);
+ for (j = 0; j < 10; j++)
+ cn += (int)getub(buf, off+5+j);
- (void)wprintw(mid4win, "%5.1f %c",(double)cn/10,st);
+ (void)wprintw(mid4win, "%5.1f %c",(double)cn/10,st);
- if (sv == 0) /* not tracking? */
- (void)wprintw(mid4win, " "); /* clear other info */
- }
- (void)wprintw(packetwin, "MTD 0x04=");
- break;
+ if (sv == 0) /* not tracking? */
+ (void)wprintw(mid4win, " "); /* clear other info */
+ }
+ (void)wprintw(packetwin, "MTD 0x04=");
+ break;
#ifdef __UNUSED__
- case 0x05: /* raw track data */
- for (off = 1; off < len; off += 51) {
- ch = getbeul(buf, off);
- (void)wmove(mid4win, ch+2, 19);
- cn = 0;
+ case 0x05: /* raw track data */
+ for (off = 1; off < len; off += 51) {
+ ch = getbeul(buf, off);
+ (void)wmove(mid4win, ch+2, 19);
+ cn = 0;
- for (j = 0; j < 10; j++)
- cn += getub(buf, off+34+j);
+ for (j = 0; j < 10; j++)
+ cn += getub(buf, off+34+j);
- printw("%5.1f",(double)cn/10);
+ printw("%5.1f",(double)cn/10);
- printw("%9d%3d%5d",getbeul(buf, off+8),(int)getbeuw(buf, off+12),(int)getbeuw(buf, off+14));
- printw("%8.5f %10.5f",
- (double)getbeul(buf, off+16)/65536,(double)getbeul(buf, off+20)/1024);
- }
- (void)wprintw(packetwin, "RTD 0x05=");
- break;
+ printw("%9d%3d%5d",getbeul(buf, off+8),(int)getbeuw(buf, off+12),(int)getbeuw(buf, off+14));
+ printw("%8.5f %10.5f",
+ (double)getbeul(buf, off+16)/65536,(double)getbeul(buf, off+20)/1024);
+ }
+ (void)wprintw(packetwin, "RTD 0x05=");
+ break;
#endif /* __UNUSED */
- case 0x06: /* firmware version */
- display(mid6win, 1, 10, "%s",buf + 1);
- (void)wprintw(packetwin, "FV 0x06=");
- break;
-
- case 0x07: /* Response - Clock Status Data */
- decode_time((int)getbeuw(buf, 1),getbesl(buf, 3));
- display(mid7win, 1, 5, "%2d", getub(buf, 7)); /* SVs */
- display(mid7win, 1, 16, "%lu", getbeul(buf, 8)); /* Clock drift */
- display(mid7win, 1, 29, "%lu", getbeul(buf, 12)); /* Clock Bias */
- display(mid7win, 2, 21, "%lu", getbeul(buf, 16)); /* Estimated Time */
- (void)wprintw(packetwin, "CSD 0x07=");
- break;
-
- case 0x08: /* 50 BPS data */
- ch = (int)getub(buf, 1);
- display(mid4win, ch+2, 27, "Y");
- (void)wprintw(packetwin, "50B 0x08=");
- subframe_enabled = true;
- break;
-
- case 0x09: /* Throughput */
- display(mid9win, 1, 6, "%.3f",(double)getbeuw(buf, 1)/186); /*SegStatMax*/
- display(mid9win, 1, 18, "%.3f",(double)getbeuw(buf, 3)/186); /*SegStatLat*/
- display(mid9win, 1, 31, "%.3f",(double)getbeuw(buf, 5)/186); /*SegStatTime*/
- display(mid9win, 1, 42, "%3d",(int)getbeuw(buf, 7)); /* Last Millisecond */
- (void)wprintw(packetwin, "THR 0x09=");
- break;
-
- case 0x0b: /* Command Acknowledgement */
- (void)wprintw(packetwin, "ACK 0x0b=");
- break;
-
- case 0x0c: /* Command NAcknowledgement */
- (void)wprintw(packetwin, "NAK 0x0c=");
- break;
-
- case 0x0d: /* Visible List */
- display(mid13win, 1, 6, "%d",getub(buf, 1));
- (void)wmove(mid13win, 1, 10);
- for (i = 0; i < SIRF_CHANNELS; i++) {
- if (i < (int)getub(buf, 1))
- (void)wprintw(mid13win, " %2d",getub(buf, 2 + 5 * i));
- else
- (void)wprintw(mid13win, " ");
+ case 0x06: /* firmware version */
+ display(mid6win, 1, 10, "%s",buf + 1);
+ (void)wprintw(packetwin, "FV 0x06=");
+ break;
- }
- (void)wprintw(packetwin, "VL 0x0d=");
- break;
+ case 0x07: /* Response - Clock Status Data */
+ decode_time((int)getbeuw(buf, 1),getbesl(buf, 3));
+ display(mid7win, 1, 5, "%2d", getub(buf, 7)); /* SVs */
+ display(mid7win, 1, 16, "%lu", getbeul(buf, 8)); /* Clock drift */
+ display(mid7win, 1, 29, "%lu", getbeul(buf, 12)); /* Clock Bias */
+ display(mid7win, 2, 21, "%lu", getbeul(buf, 16)); /* Estimated Time */
+ (void)wprintw(packetwin, "CSD 0x07=");
+ break;
+
+ case 0x08: /* 50 BPS data */
+ ch = (int)getub(buf, 1);
+ display(mid4win, ch+2, 27, "Y");
+ (void)wprintw(packetwin, "50B 0x08=");
+ subframe_enabled = true;
+ break;
+
+ case 0x09: /* Throughput */
+ display(mid9win, 1, 6, "%.3f",(double)getbeuw(buf, 1)/186); /*SegStatMax*/
+ display(mid9win, 1, 18, "%.3f",(double)getbeuw(buf, 3)/186); /*SegStatLat*/
+ display(mid9win, 1, 31, "%.3f",(double)getbeuw(buf, 5)/186); /*SegStatTime*/
+ display(mid9win, 1, 42, "%3d",(int)getbeuw(buf, 7)); /* Last Millisecond */
+ (void)wprintw(packetwin, "THR 0x09=");
+ break;
- case 0x13:
+ case 0x0b: /* Command Acknowledgement */
+ (void)wprintw(packetwin, "ACK 0x0b=");
+ break;
+
+ case 0x0c: /* Command NAcknowledgement */
+ (void)wprintw(packetwin, "NAK 0x0c=");
+ break;
+
+ case 0x0d: /* Visible List */
+ display(mid13win, 1, 6, "%d",getub(buf, 1));
+ (void)wmove(mid13win, 1, 10);
+ for (i = 0; i < SIRF_CHANNELS; i++) {
+ if (i < (int)getub(buf, 1))
+ (void)wprintw(mid13win, " %2d",getub(buf, 2 + 5 * i));
+ else
+ (void)wprintw(mid13win, " ");
+
+ }
+ (void)wprintw(packetwin, "VL 0x0d=");
+ break;
+
+ case 0x13:
#define YESNO(n) (((int)getub(buf, n) != 0)?'Y':'N')
- display(mid19win, 1, 20, "%d", getub(buf, 5)); /* Alt. hold mode */
- display(mid19win, 2, 20, "%d", getub(buf, 6)); /* Alt. hold source*/
- display(mid19win, 3, 20, "%dm", (int)getbeuw(buf, 7)); /* Alt. source input */
- if (getub(buf, 9) != (unsigned char)'\0')
- display(mid19win, 4, 20, "%dsec", getub(buf, 10)); /* Degraded timeout*/
- else
- display(mid19win, 4, 20, "N/A ");
- display(mid19win, 5, 20, "%dsec",getub(buf, 11)); /* DR timeout*/
- display(mid19win, 6, 20, "%c", YESNO(12));/* Track smooth mode*/
- display(mid19win, 7, 20, "%c", YESNO(13)); /* Static Nav.*/
- display(mid19win, 8, 20, "0x%x", getub(buf, 14)); /* 3SV Least Squares*/
- display(mid19win, 9 ,20, "0x%x", getub(buf, 19)); /* DOP Mask mode*/
- display(mid19win, 10,20, "0x%x", (int)getbeuw(buf, 20)); /* Nav. Elev. mask*/
- display(mid19win, 11,20, "0x%x", getub(buf, 22)); /* Nav. Power mask*/
- display(mid19win, 12,20, "0x%x", getub(buf, 27)); /* DGPS Source*/
- display(mid19win, 13,20, "0x%x", getub(buf, 28)); /* DGPS Mode*/
- display(mid19win, 14,20, "%dsec",getub(buf, 29)); /* DGPS Timeout*/
- display(mid19win, 1, 42, "%c", YESNO(34));/* LP Push-to-Fix */
- display(mid19win, 2, 42, "%dms", getbeul(buf, 35)); /* LP On Time */
- display(mid19win, 3, 42, "%d", getbeul(buf, 39)); /* LP Interval */
- display(mid19win, 4, 42, "%c", YESNO(43));/* User Tasks enabled */
- display(mid19win, 5, 42, "%d", getbeul(buf, 44)); /* User Task Interval */
- display(mid19win, 6, 42, "%c", YESNO(48));/* LP Power Cycling Enabled */
- display(mid19win, 7, 42, "%d", getbeul(buf, 49));/* LP Max Acq Search Time */
- display(mid19win, 8, 42, "%d", getbeul(buf, 53));/* LP Max Off Time */
- display(mid19win, 9, 42, "%c", YESNO(57));/* APM Enabled */
- display(mid19win,10, 42, "%d", (int)getbeuw(buf, 58));/* # of fixes */
- display(mid19win,11, 42, "%d", (int)getbeuw(buf, 60));/* Time Between fixes */
- display(mid19win,12, 42, "%d", getub(buf, 62));/* H/V Error Max */
- display(mid19win,13, 42, "%d", getub(buf, 63));/* Response Time Max */
- display(mid19win,14, 42, "%d", getub(buf, 64));/* Time/Accu & Duty Cycle Priority */
+ display(mid19win, 1, 20, "%d", getub(buf, 5)); /* Alt. hold mode */
+ display(mid19win, 2, 20, "%d", getub(buf, 6)); /* Alt. hold source*/
+ display(mid19win, 3, 20, "%dm", (int)getbeuw(buf, 7)); /* Alt. source input */
+ if (getub(buf, 9) != (unsigned char)'\0')
+ display(mid19win, 4, 20, "%dsec", getub(buf, 10)); /* Degraded timeout*/
+ else
+ display(mid19win, 4, 20, "N/A ");
+ display(mid19win, 5, 20, "%dsec",getub(buf, 11)); /* DR timeout*/
+ display(mid19win, 6, 20, "%c", YESNO(12));/* Track smooth mode*/
+ display(mid19win, 7, 20, "%c", YESNO(13)); /* Static Nav.*/
+ display(mid19win, 8, 20, "0x%x", getub(buf, 14)); /* 3SV Least Squares*/
+ display(mid19win, 9 ,20, "0x%x", getub(buf, 19)); /* DOP Mask mode*/
+ display(mid19win, 10,20, "0x%x", (int)getbeuw(buf, 20)); /* Nav. Elev. mask*/
+ display(mid19win, 11,20, "0x%x", getub(buf, 22)); /* Nav. Power mask*/
+ display(mid19win, 12,20, "0x%x", getub(buf, 27)); /* DGPS Source*/
+ display(mid19win, 13,20, "0x%x", getub(buf, 28)); /* DGPS Mode*/
+ display(mid19win, 14,20, "%dsec",getub(buf, 29)); /* DGPS Timeout*/
+ display(mid19win, 1, 42, "%c", YESNO(34));/* LP Push-to-Fix */
+ display(mid19win, 2, 42, "%dms", getbeul(buf, 35)); /* LP On Time */
+ display(mid19win, 3, 42, "%d", getbeul(buf, 39)); /* LP Interval */
+ display(mid19win, 4, 42, "%c", YESNO(43));/* User Tasks enabled */
+ display(mid19win, 5, 42, "%d", getbeul(buf, 44)); /* User Task Interval */
+ display(mid19win, 6, 42, "%c", YESNO(48));/* LP Power Cycling Enabled */
+ display(mid19win, 7, 42, "%d", getbeul(buf, 49));/* LP Max Acq Search Time */
+ display(mid19win, 8, 42, "%d", getbeul(buf, 53));/* LP Max Off Time */
+ display(mid19win, 9, 42, "%c", YESNO(57));/* APM Enabled */
+ display(mid19win,10, 42, "%d", (int)getbeuw(buf, 58));/* # of fixes */
+ display(mid19win,11, 42, "%d", (int)getbeuw(buf, 60));/* Time Between fixes */
+ display(mid19win,12, 42, "%d", getub(buf, 62));/* H/V Error Max */
+ display(mid19win,13, 42, "%d", getub(buf, 63));/* Response Time Max */
+ display(mid19win,14, 42, "%d", getub(buf, 64));/* Time/Accu & Duty Cycle Priority */
#undef YESNO
- break;
+ break;
- case 0x1b:
- /******************************************************************
+ case 0x1b:
+ /******************************************************************
Not actually documented in any published materials.
Here is what Chris Kuethe got from the SiRF folks,
(plus some corrections from the GpsPaSsion forums):
@@ -499,124 +498,123 @@ static void sirf_update(size_t len)
Correction (cm) 2 bytes (signed short)
total 3 x 12 = 36 bytes
- ******************************************************************/
- display(mid27win, 1, 14, "%d (%s)",
- getub(buf, 1), dgpsvec[(int)getub(buf, 1)]);
- /*@ -type @*/
- //(void) wmove(mid27win, 2, 0);
- for (i = j = 0; i < 12; i++) {
- if (getub(buf, 16+3*i) != '\0') {
- //(void)wprintw(mid27win, " %d=%d", getub(buf, 16+3*i), getbesw(buf, 16+3*i+1));
- j++;
- }
+ ******************************************************************/
+ display(mid27win, 1, 14, "%d (%s)",
+ getub(buf, 1), dgpsvec[(int)getub(buf, 1)]);
+ /*@ -type @*/
+ //(void) wmove(mid27win, 2, 0);
+ for (i = j = 0; i < 12; i++) {
+ if (getub(buf, 16+3*i) != '\0') {
+ //(void)wprintw(mid27win, " %d=%d", getub(buf, 16+3*i), getbesw(buf, 16+3*i+1));
+ j++;
}
- /*@ +type @*/
- display(mid27win, 1, 44, "%d", j);
- (void)wprintw(packetwin, "DST 0x1b=");
- break;
-
- case 0x1C: /* NL Measurement Data */
- case 0x1D: /* DGPS Data */
- case 0x1E: /* SV State Data */
- case 0x1F: /* NL Initialized Data */
- subframe_enabled = true;
- break;
- case 0x29: /* Geodetic Navigation Message */
- (void)wprintw(packetwin, "GNM 0x29=");
- break;
- case 0x32: /* SBAS Parameters */
- (void)wprintw(packetwin, "SBP 0x32=");
- break;
- case 0x34: /* PPS Time */
- (void)wprintw(packetwin, "PPS 0x34=");
- break;
+ }
+ /*@ +type @*/
+ display(mid27win, 1, 44, "%d", j);
+ (void)wprintw(packetwin, "DST 0x1b=");
+ break;
+
+ case 0x1C: /* NL Measurement Data */
+ case 0x1D: /* DGPS Data */
+ case 0x1E: /* SV State Data */
+ case 0x1F: /* NL Initialized Data */
+ subframe_enabled = true;
+ break;
+ case 0x29: /* Geodetic Navigation Message */
+ (void)wprintw(packetwin, "GNM 0x29=");
+ break;
+ case 0x32: /* SBAS Parameters */
+ (void)wprintw(packetwin, "SBP 0x32=");
+ break;
+ case 0x34: /* PPS Time */
+ (void)wprintw(packetwin, "PPS 0x34=");
+ break;
#ifdef __UNUSED__
- case 0x62:
- attrset(A_BOLD);
- move(2,40);
- printw("%9.5f %9.5f",(double)(RAD_2_DEG*1e8*getbesl(buf, 1)),
- (double)(RAD_2_DEG*1e8*getbesl(buf, 5)));
- move(2,63);
- printw("%8d",getbesl(buf, 9)/1000);
-
- move(3,63);
-
- printw("%8.1f",(double)getbesl(buf, 17)/1000);
-
- move(4,54);
- if (getbeul(buf, 13) > 50) {
- double heading = RAD_2_DEG*1e8*getbesl(buf, 21);
- if (heading < 0)
- heading += 360;
- printw("%5.1f",heading);
- } else
- printw(" 0.0");
-
- move(4,63);
- printw("%8.1f",(double)getbesl(buf, 13)/1000);
- attrset(A_NORMAL);
-
- move(5,13);
- printw("%04d-%02d-%02d %02d:%02d:%02d.%02d",
- (int)getbeuw(buf, 26),getub(buf, 28),getub(buf, 29),getub(buf, 30),getub(buf, 31),
- (unsigned short)getbeuw(buf, 32)/1000,
- ((unsigned short)getbeuw(buf, 32)%1000)/10);
- {
- struct timeval clk,gps;
- struct tm tm;
-
- gettimeofday(&clk,NULL);
-
- memset(&tm,0,sizeof(tm));
- tm.tm_sec = (unsigned short)getbeuw(buf, 32)/1000;
- tm.tm_min = (int)getub(buf, 31);
- tm.tm_hour = (int)getub(buf, 30);
- tm.tm_mday = (int)getub(buf, 29);
- tm.tm_mon = (int)getub(buf, 28) - 1;
- tm.tm_year = (int)getbeuw(buf, 26) - 1900;
-
- gps.tv_sec = mkgmtime(&tm);
- gps.tv_usec = (((unsigned short)getbeuw(buf, 32)%1000)/10) * 10000;
-
- move(5,2);
- printw(" ");
- move(5,2);
+ case 0x62:
+ attrset(A_BOLD);
+ move(2,40);
+ printw("%9.5f %9.5f",(double)(RAD_2_DEG*1e8*getbesl(buf, 1)),
+ (double)(RAD_2_DEG*1e8*getbesl(buf, 5)));
+ move(2,63);
+ printw("%8d",getbesl(buf, 9)/1000);
+
+ move(3,63);
+
+ printw("%8.1f",(double)getbesl(buf, 17)/1000);
+
+ move(4,54);
+ if (getbeul(buf, 13) > 50) {
+ double heading = RAD_2_DEG*1e8*getbesl(buf, 21);
+ if (heading < 0)
+ heading += 360;
+ printw("%5.1f",heading);
+ } else
+ printw(" 0.0");
+
+ move(4,63);
+ printw("%8.1f",(double)getbesl(buf, 13)/1000);
+ attrset(A_NORMAL);
+
+ move(5,13);
+ printw("%04d-%02d-%02d %02d:%02d:%02d.%02d",
+ (int)getbeuw(buf, 26),getub(buf, 28),getub(buf, 29),getub(buf, 30),getub(buf, 31),
+ (unsigned short)getbeuw(buf, 32)/1000,
+ ((unsigned short)getbeuw(buf, 32)%1000)/10);
+ {
+ struct timeval clk,gps;
+ struct tm tm;
+
+ gettimeofday(&clk,NULL);
+
+ memset(&tm,0,sizeof(tm));
+ tm.tm_sec = (unsigned short)getbeuw(buf, 32)/1000;
+ tm.tm_min = (int)getub(buf, 31);
+ tm.tm_hour = (int)getub(buf, 30);
+ tm.tm_mday = (int)getub(buf, 29);
+ tm.tm_mon = (int)getub(buf, 28) - 1;
+ tm.tm_year = (int)getbeuw(buf, 26) - 1900;
+
+ gps.tv_sec = mkgmtime(&tm);
+ gps.tv_usec = (((unsigned short)getbeuw(buf, 32)%1000)/10) * 10000;
+
+ move(5,2);
+ printw(" ");
+ move(5,2);
#if 1
- printw("%ld",(gps.tv_usec - clk.tv_usec) +
- ((gps.tv_sec - clk.tv_sec) % 3600) * 1000000);
+ printw("%ld",(gps.tv_usec - clk.tv_usec) +
+ ((gps.tv_sec - clk.tv_sec) % 3600) * 1000000);
#else
- printw("%ld %ld %ld %ld",gps.tv_sec % 3600,gps.tv_usec,
- clk.tv_sec % 3600,clk.tv_usec);
+ printw("%ld %ld %ld %ld",gps.tv_sec % 3600,gps.tv_usec,
+ clk.tv_sec % 3600,clk.tv_usec);
#endif
- }
- (void)wprintw(packetwin, "??? 0x62=");
- break;
+ }
+ (void)wprintw(packetwin, "??? 0x62=");
+ break;
#endif /* __UNUSED__ */
- case 0xff: /* Development Data */
- /*@ +ignoresigns @*/
- while (len > 0 && buf[len-1] == '\n')
- len--;
- while (len > 0 && buf[len-1] == ' ')
- len--;
- /*@ -ignoresigns @*/
- buf[len] = '\0';
- j = 1;
- for (i = 0; verbpat[i] != NULL; i++)
- if (strncmp((char *)(buf+1),verbpat[i],strlen(verbpat[i])) == 0) {
- j = 0;
- break;
- }
- if (j != 0)
- (void)wprintw(packetwin, "%s\n",buf+1);
- (void)wprintw(packetwin, "DD 0xff=");
- break;
-
- default:
- (void)wprintw(packetwin, " 0x%02x=", buf[4]);
- break;
- }
+ case 0xff: /* Development Data */
+ /*@ +ignoresigns @*/
+ while (len > 0 && buf[len-1] == '\n')
+ len--;
+ while (len > 0 && buf[len-1] == ' ')
+ len--;
+ /*@ -ignoresigns @*/
+ buf[len] = '\0';
+ j = 1;
+ for (i = 0; verbpat[i] != NULL; i++)
+ if (strncmp((char *)(buf+1),verbpat[i],strlen(verbpat[i])) == 0) {
+ j = 0;
+ break;
+ }
+ if (j != 0)
+ (void)wprintw(packetwin, "%s\n",buf+1);
+ (void)wprintw(packetwin, "DD 0xff=");
+ break;
+
+ default:
+ (void)wprintw(packetwin, " 0x%02x=", buf[4]);
+ break;
}
/* elicit navigation parameters */