diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-04-14 00:41:24 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-04-14 00:41:24 -0400 |
commit | 2daef1ab8aafd0afe69cf80866a0dd390a269370 (patch) | |
tree | 9e0ddfd73edd5d18b7306127bcaf01b2a96096b3 | |
parent | b54cbc920bac03a3c01412f5379c3473aff52c1d (diff) | |
download | gpsd-2daef1ab8aafd0afe69cf80866a0dd390a269370.tar.gz |
Reindent monitor mdules. Live test of gpsmon works.
-rw-r--r-- | monitor_italk.c | 391 | ||||
-rw-r--r-- | monitor_nmea.c | 177 | ||||
-rw-r--r-- | monitor_oncore.c | 476 | ||||
-rw-r--r-- | monitor_sirf.c | 487 | ||||
-rw-r--r-- | monitor_superstar2.c | 125 | ||||
-rw-r--r-- | monitor_tnt.c | 40 | ||||
-rw-r--r-- | monitor_ubx.c | 380 |
7 files changed, 1048 insertions, 1028 deletions
diff --git a/monitor_italk.c b/monitor_italk.c index 26a683c7..a945bdd4 100644 --- a/monitor_italk.c +++ b/monitor_italk.c @@ -35,229 +35,230 @@ static WINDOW *satwin, *navfixwin; #define display (void)mvwprintw static bool italk_initialize(void) { - int i; - - /*@ -onlytrans @*/ - /* "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), + int i; + + /*@ -onlytrans @*/ + /* "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; - /*@ +onlytrans @*/ + (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; + /*@ +onlytrans @*/ } -static void display_itk_navfix(unsigned char *buf, size_t len) { +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; + 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; + if (len != 296) + return; - flags = (ushort)getleuw(buf, 7 + 4); - cflags = (ushort)getleuw(buf, 7 + 6); - pflags = (ushort)getleuw(buf, 7 + 8); + flags = (ushort) getleuw(buf, 7 + 4); + cflags = (ushort) getleuw(buf, 7 + 6); + pflags = (ushort) getleuw(buf, 7 + 8); #define MAX(a,b) (((a) > (b)) ? (a) : (b)) - nsv = (ushort)MAX(getleuw(buf, 7 + 12), getleuw(buf, 7 + 14)); - svlist = (ushort)getleul(buf, 7 + 16) | getleul(buf, 7 + 24); - - hour = (ushort)getleuw(buf, 7 + 66); - min = (ushort)getleuw(buf, 7 + 68); - sec = (ushort)getleuw(buf, 7 + 70); - nsec = (ushort)getleul(buf, 7 + 72); - year = (ushort)getleuw(buf, 7 + 76); - mon = (ushort)getleuw(buf, 7 + 78); - day = (ushort)getleuw(buf, 7 + 80); - gps_week = (ushort)getlesw(buf, 7 + 82); - tow = (ushort)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 = (unsigned short)tod % 60; - min = (unsigned short)(tod / 60) % 60; - hour = (unsigned short)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)) { - (void)snprintf(prn, 4, "%u ", i+1); - (void)strlcat(satlist, prn, 38); - } - } - (void)wprintw(navfixwin, "%02d = %-38s", nsv, satlist); + nsv = (ushort) MAX(getleuw(buf, 7 + 12), getleuw(buf, 7 + 14)); + svlist = (ushort) getleul(buf, 7 + 16) | getleul(buf, 7 + 24); + + hour = (ushort) getleuw(buf, 7 + 66); + min = (ushort) getleuw(buf, 7 + 68); + sec = (ushort) getleuw(buf, 7 + 70); + nsec = (ushort) getleul(buf, 7 + 72); + year = (ushort) getleuw(buf, 7 + 76); + mon = (ushort) getleuw(buf, 7 + 78); + day = (ushort) getleuw(buf, 7 + 80); + gps_week = (ushort) getlesw(buf, 7 + 82); + tow = (ushort) 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 = (unsigned short)tod % 60; + min = (unsigned short)(tod / 60) % 60; + hour = (unsigned short)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)) { + (void)snprintf(prn, 4, "%u ", i + 1); + (void)strlcat(satlist, prn, 38); + } } - (void)wnoutrefresh(navfixwin); + (void)wprintw(navfixwin, "%02d = %-38s", nsv, satlist); + } + (void)wnoutrefresh(navfixwin); } static void display_itk_prnstatus(unsigned char *buf, size_t len) { - int i, nchan; - if (len < 62) - return; - - nchan = (int)getleuw(buf, 7 +50); - if (nchan > MAX_NR_VISIBLE_PRNS) - nchan = MAX_NR_VISIBLE_PRNS; - for (i = 0; i < nchan; i++) { - int off = 7+ 52 + 10 * i; - unsigned short fl; - unsigned char ss, prn, el, az; - - fl = (unsigned short)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); + int i, nchan; + if (len < 62) return; + + nchan = (int)getleuw(buf, 7 + 50); + if (nchan > MAX_NR_VISIBLE_PRNS) + nchan = MAX_NR_VISIBLE_PRNS; + for (i = 0; i < nchan; i++) { + int off = 7 + 52 + 10 * i; + unsigned short fl; + unsigned char ss, prn, el, az; + + fl = (unsigned short)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 = (unsigned char)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; - } + unsigned char *buf; + size_t len; + unsigned char type; + + buf = session.packet.outbuffer; + len = session.packet.outbuflen; + type = (unsigned char)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) +static int italk_command(char line[]UNUSED) { - return COMMAND_UNKNOWN; + return COMMAND_UNKNOWN; } static void italk_wrap(void) { - (void)delwin(satwin); - return; + (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, + .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 diff --git a/monitor_nmea.c b/monitor_nmea.c index 87cd6921..184c524e 100644 --- a/monitor_nmea.c +++ b/monitor_nmea.c @@ -51,7 +51,7 @@ static bool nmea_initialize(void) int i; /*@ -onlytrans @*/ - cookedwin = derwin(devicewin, 3, 80, 0, 0); + cookedwin = derwin(devicewin, 3, 80, 0, 0); (void)wborder(cookedwin, 0, 0, 0, 0, 0, 0, 0, 0); (void)syncok(cookedwin, true); wattrset(cookedwin, A_BOLD); @@ -61,26 +61,25 @@ static bool nmea_initialize(void) mvwaddstr(cookedwin, 2, 34, " Cooked PVT "); wattrset(cookedwin, A_NORMAL); - nmeawin = derwin(devicewin, 3, 80, 3, 0); + nmeawin = derwin(devicewin, 3, 80, 3, 0); (void)wborder(nmeawin, 0, 0, 0, 0, 0, 0, 0, 0); (void)syncok(nmeawin, true); wattrset(nmeawin, A_BOLD); mvwaddstr(nmeawin, 2, 34, " Sentences "); wattrset(nmeawin, A_NORMAL); - satwin = derwin(devicewin, MAXSATS+3, 20, 6, 0); - (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(satwin, true); + satwin = derwin(devicewin, MAXSATS + 3, 20, 6, 0); + (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true); (void)wattrset(satwin, A_BOLD); (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N"); for (i = 0; i < MAXSATS; i++) - (void)mvwprintw(satwin, (int)(i+2), 1, "%2d",i); + (void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i); (void)mvwprintw(satwin, 14, 7, " GSV "); (void)wattrset(satwin, A_NORMAL); - gprmcwin = derwin(devicewin, 9, 30, 6, 20); + gprmcwin = derwin(devicewin, 9, 30, 6, 20); (void)wborder(gprmcwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(gprmcwin, true); + (void)syncok(gprmcwin, true); (void)wattrset(gprmcwin, A_BOLD); (void)mvwprintw(gprmcwin, 1, 1, "Time: "); (void)mvwprintw(gprmcwin, 2, 1, "Latitude: "); @@ -92,9 +91,9 @@ static bool nmea_initialize(void) (void)mvwprintw(gprmcwin, 8, 12, " RMC "); (void)wattrset(gprmcwin, A_NORMAL); - gpgsawin = derwin(devicewin, 5, 30, 15, 20); + gpgsawin = derwin(devicewin, 5, 30, 15, 20); (void)wborder(gpgsawin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(gpgsawin, true); + (void)syncok(gpgsawin, true); (void)wattrset(gpgsawin, A_BOLD); (void)mvwprintw(gpgsawin, 1, 1, "Mode: "); (void)mvwprintw(gpgsawin, 2, 1, "Sats: "); @@ -102,9 +101,9 @@ static bool nmea_initialize(void) (void)mvwprintw(gpgsawin, 4, 12, " GSA "); (void)wattrset(gpgsawin, A_NORMAL); - gpggawin = derwin(devicewin, 9, 30, 6, 50); + gpggawin = derwin(devicewin, 9, 30, 6, 50); (void)wborder(gpggawin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(gpggawin, true); + (void)syncok(gpggawin, true); (void)wattrset(gpggawin, A_BOLD); (void)mvwprintw(gpggawin, 1, 1, "Time: "); (void)mvwprintw(gpggawin, 2, 1, "Latitude: "); @@ -126,39 +125,46 @@ static void cooked_pvt(void) { char scr[128]; - if (isnan(session.gpsdata.fix.time)==0) { + 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)mvwprintw(cookedwin, 1, 7, "%-22s", scr); - if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.latitude)==0) { + 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)), + 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(cookedwin, 1, 36, "%-17s", scr); - if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.longitude)==0) { + 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)), + 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(cookedwin, 1, 60, "%-17s", scr); #if 0 - if (isnan(session.gpsdata.fix.track)==0) - (void)snprintf(scr, sizeof(scr), "%.1f meters/sec", session.gpsdata.fix.speed); + if (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(cookedwin, 1, 33, "%-17s", scr); /* fill in the course */ - if (session.gpsdata.fix.mode >= MODE_2D && isnan(session.gpsdata.fix.track)==0) - (void)snprintf(scr, sizeof(scr), "%.1f deg", session.gpsdata.fix.track); + 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(cookedwin, 5, 11, "%-17s", scr); @@ -172,11 +178,11 @@ static void nmea_update(void) static char sentences[NMEA_MAX]; char **fields; - assert(cookedwin!=NULL); - assert(nmeawin!=NULL); - assert(gpgsawin!=NULL); - assert(gpggawin!=NULL); - assert(gprmcwin!=NULL); + assert(cookedwin != NULL); + assert(nmeawin != NULL); + assert(gpgsawin != NULL); + assert(gpggawin != NULL); + assert(gprmcwin != NULL); fields = session.driver.nmea.field; @@ -186,7 +192,7 @@ static void nmea_update(void) getmaxyx(nmeawin, ymax, xmax); if (strstr(sentences, fields[0]) == NULL) { char *s_end = sentences + strlen(sentences); - if ((int)(strlen(sentences) + strlen(fields[0])) < xmax-2) { + if ((int)(strlen(sentences) + strlen(fields[0])) < xmax - 2) { *s_end++ = ' '; (void)strlcpy(s_end, fields[0], NMEA_MAX); } else { @@ -203,29 +209,29 @@ static void nmea_update(void) * tag. */ now = timestamp(); - if (now > last_tick && (now - last_tick) > tick_interval) - { + if (now > last_tick && (now - last_tick) > tick_interval) { char *findme = strstr(sentences, fields[0]); 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(fields[0]), - A_BOLD, 0, NULL); + mvwchgat(nmeawin, SENTENCELINE, 1, xmax - 13, A_NORMAL, 0, + NULL); + mvwchgat(nmeawin, SENTENCELINE, 1 + (findme - sentences), + (int)strlen(fields[0]), A_BOLD, 0, NULL); } } last_tick = now; - if (strcmp(fields[0], "GPGSV") == 0 - || strcmp(fields[0], "GNGSV") == 0 - || strcmp(fields[0], "GLGSV") == 0) { + if (strcmp(fields[0], "GPGSV") == 0 + || strcmp(fields[0], "GNGSV") == 0 + || strcmp(fields[0], "GLGSV") == 0) { int i; - int nsats = (session.gpsdata.satellites_visible < MAXSATS) ? session.gpsdata.satellites_visible : MAXSATS; + int nsats = + (session.gpsdata.satellites_visible < + MAXSATS) ? session.gpsdata.satellites_visible : MAXSATS; for (i = 0; i < nsats; i++) { - (void)wmove(satwin, i+2, 3); + (void)wmove(satwin, i + 2, 3); (void)wprintw(satwin, " %3d %3d%3d %3.0f", session.gpsdata.PRN[i], session.gpsdata.azimuth[i], @@ -234,14 +240,14 @@ static void nmea_update(void) } /* add overflow mark to the display */ if (nsats <= MAXSATS) - (void)mvwaddch(satwin, MAXSATS+2, 18, ACS_HLINE); + (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_HLINE); else - (void)mvwaddch(satwin, MAXSATS+2, 18, ACS_DARROW); + (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_DARROW); } - if (strcmp(fields[0], "GPRMC") == 0 - || strcmp(fields[0], "GNRMC") == 0 - || strcmp(fields[0], "GLRMC") == 0) { + if (strcmp(fields[0], "GPRMC") == 0 + || strcmp(fields[0], "GNRMC") == 0 + || strcmp(fields[0], "GLRMC") == 0) { /* time, lat, lon, course, speed */ (void)mvwaddstr(gprmcwin, 1, 12, fields[1]); (void)mvwprintw(gprmcwin, 2, 12, "%12s %s", fields[3], fields[4]); @@ -251,30 +257,31 @@ static void nmea_update(void) /* the status field, FAA code, and magnetic variation */ (void)mvwaddstr(gprmcwin, 6, 12, fields[2]); (void)mvwaddstr(gprmcwin, 6, 25, fields[12]); - (void)mvwprintw(gprmcwin, 7, 12, "%-5s%s", fields[10],fields[11]); + (void)mvwprintw(gprmcwin, 7, 12, "%-5s%s", fields[10], + fields[11]); cooked_pvt(); /* cooked version of PVT */ } - if (strcmp(fields[0], "GPGSA") == 0 - || strcmp(fields[0], "GNGSA") == 0 - || strcmp(fields[0], "GLGSA") == 0) { + if (strcmp(fields[0], "GPGSA") == 0 + || strcmp(fields[0], "GNGSA") == 0 + || strcmp(fields[0], "GLGSA") == 0) { char scr[128]; int i; - (void)mvwprintw(gpgsawin, 1,7, "%1s %s", fields[1], fields[2]); + (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), + (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)'.'); + (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) '.'); } monitor_fixframe(gpgsawin); (void)mvwprintw(gpgsawin, 3, 8, "%-5s", fields[16]); @@ -282,9 +289,9 @@ static void nmea_update(void) (void)mvwprintw(gpgsawin, 3, 24, "%-5s", fields[15]); monitor_fixframe(gpgsawin); } - if (strcmp(fields[0], "GPGGA") == 0 - || strcmp(fields[0], "GNGGA") == 0 - || strcmp(fields[0], "GLGGA") == 0) { + if (strcmp(fields[0], "GPGGA") == 0 + || strcmp(fields[0], "GNGGA") == 0 + || strcmp(fields[0], "GLGGA") == 0) { (void)mvwprintw(gpggawin, 1, 12, "%-17s", fields[1]); (void)mvwprintw(gpggawin, 2, 12, "%-17s", fields[2]); (void)mvwprintw(gpggawin, 3, 12, "%-17s", fields[4]); @@ -296,6 +303,7 @@ static void nmea_update(void) } } } + /*@ +globstate +nullpass */ #undef SENTENCELINE @@ -313,7 +321,7 @@ const struct monitor_object_t nmea_mmt = { .update = nmea_update, .command = NULL, .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &nmea, }; @@ -324,13 +332,13 @@ const struct monitor_object_t nmea_mmt = { *****************************************************************************/ #ifdef ALLOW_CONTROLSEND -static void monitor_nmea_send(const char *fmt, ... ) +static void monitor_nmea_send(const char *fmt, ...) { char buf[BUFSIZ]; va_list ap; - va_start(ap, fmt) ; - (void)vsnprintf(buf, sizeof(buf)-5, fmt, ap); + va_start(ap, fmt); + (void)vsnprintf(buf, sizeof(buf) - 5, fmt, ap); va_end(ap); (void)monitor_control_send((unsigned char *)buf, strlen(buf)); } @@ -353,7 +361,7 @@ const struct monitor_object_t garmin_mmt = { .update = nmea_update, .command = NULL, .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &garmin, }; #endif /* GARMIN_ENABLE && NMEA_ENABLE */ @@ -367,10 +375,9 @@ extern const struct gps_type_t ashtech; #ifdef ALLOW_CONTROLSEND static int ashtech_command(char line[]) { - switch (line[0]) - { - case 'N': /* normal = 9600, GGA+GSA+GSV+RMC+ZDA */ - monitor_nmea_send("$PASHS,NME,ALL,A,OFF"); /* silence outbound chatter */ + switch (line[0]) { + case 'N': /* normal = 9600, GGA+GSA+GSV+RMC+ZDA */ + monitor_nmea_send("$PASHS,NME,ALL,A,OFF"); /* silence outbound chatter */ monitor_nmea_send("$PASHS,NME,ALL,B,OFF"); monitor_nmea_send("$PASHS,NME,GGA,A,ON"); monitor_nmea_send("$PASHS,NME,GSA,A,ON"); @@ -379,13 +386,13 @@ static int ashtech_command(char line[]) monitor_nmea_send("$PASHS,NME,ZDA,A,ON"); monitor_nmea_send("$PASHS,INI,%d,%d,,,0,", - ASHTECH_SPEED_9600, ASHTECH_SPEED_9600); - (void)sleep(6); /* it takes 4-6 sec for the receiver to reboot */ - monitor_nmea_send("$PASHS,WAS,ON"); /* enable WAAS */ + ASHTECH_SPEED_9600, ASHTECH_SPEED_9600); + (void)sleep(6); /* it takes 4-6 sec for the receiver to reboot */ + monitor_nmea_send("$PASHS,WAS,ON"); /* enable WAAS */ break; - case 'R': /* raw = 57600, normal+XPG+POS+SAT+MCA+PBN+SNV */ - monitor_nmea_send("$PASHS,NME,ALL,A,OFF"); /* silence outbound chatter */ + case 'R': /* raw = 57600, normal+XPG+POS+SAT+MCA+PBN+SNV */ + monitor_nmea_send("$PASHS,NME,ALL,A,OFF"); /* silence outbound chatter */ monitor_nmea_send("$PASHS,NME,ALL,B,OFF"); monitor_nmea_send("$PASHS,NME,GGA,A,ON"); monitor_nmea_send("$PASHS,NME,GSA,A,ON"); @@ -394,17 +401,17 @@ static int ashtech_command(char line[]) monitor_nmea_send("$PASHS,NME,ZDA,A,ON"); monitor_nmea_send("$PASHS,INI,%d,%d,,,0,", - ASHTECH_SPEED_57600, ASHTECH_SPEED_9600); - (void)sleep(6); /* it takes 4-6 sec for the receiver to reboot */ - monitor_nmea_send("$PASHS,WAS,ON"); /* enable WAAS */ + ASHTECH_SPEED_57600, ASHTECH_SPEED_9600); + (void)sleep(6); /* it takes 4-6 sec for the receiver to reboot */ + monitor_nmea_send("$PASHS,WAS,ON"); /* enable WAAS */ - monitor_nmea_send("$PASHS,NME,POS,A,ON"); /* Ashtech PVT solution */ - monitor_nmea_send("$PASHS,NME,SAT,A,ON"); /* Ashtech Satellite status */ - monitor_nmea_send("$PASHS,NME,MCA,A,ON"); /* MCA measurements */ - monitor_nmea_send("$PASHS,NME,PBN,A,ON"); /* ECEF PVT solution */ - monitor_nmea_send("$PASHS,NME,SNV,A,ON,10"); /* Almanac data */ + monitor_nmea_send("$PASHS,NME,POS,A,ON"); /* Ashtech PVT solution */ + monitor_nmea_send("$PASHS,NME,SAT,A,ON"); /* Ashtech Satellite status */ + monitor_nmea_send("$PASHS,NME,MCA,A,ON"); /* MCA measurements */ + monitor_nmea_send("$PASHS,NME,PBN,A,ON"); /* ECEF PVT solution */ + monitor_nmea_send("$PASHS,NME,SNV,A,ON,10"); /* Almanac data */ - monitor_nmea_send("$PASHS,NME,XMG,A,ON"); /* exception messages */ + monitor_nmea_send("$PASHS,NME,XMG,A,ON"); /* exception messages */ break; default: @@ -424,7 +431,7 @@ const struct monitor_object_t ashtech_mmt = { .command = NULL, #endif /* ALLOW_CONTROLSEND */ .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &ashtech, }; #endif /* ASHTECH_ENABLE */ @@ -437,7 +444,7 @@ const struct monitor_object_t fv18_mmt = { .update = nmea_update, .command = NULL, .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &fv18, }; #endif /* FV18_ENABLE */ @@ -450,7 +457,7 @@ const struct monitor_object_t gpsclock_mmt = { .update = nmea_update, .command = NULL, .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &gpsclock, }; #endif /* GPSCLOCK_ENABLE */ @@ -463,7 +470,7 @@ const struct monitor_object_t mtk3301_mmt = { .update = nmea_update, .command = NULL, .wrap = nmea_wrap, - .min_y = 21, .min_x = 80, + .min_y = 21,.min_x = 80, .driver = &mtk3301, }; #endif /* MTK3301_ENABLE */ diff --git a/monitor_oncore.c b/monitor_oncore.c index 6cb81527..719773a5 100644 --- a/monitor_oncore.c +++ b/monitor_oncore.c @@ -34,16 +34,14 @@ extern const struct gps_type_t oncore_binary; static WINDOW *Ea1win, *Eawin, *Bbwin, *Enwin, *Bowin, *Aywin, *Aswin, *Atwin; static unsigned char EaSVlines[8]; -static const char *antenna[] = -{ +static const char *antenna[] = { "OK (conn)", "OC (short)", "UC (open)", "OU (short)" }; -static const char *sv_mode[] = -{ +static const char *sv_mode[] = { "srch", "acq", "AGCs", @@ -55,36 +53,31 @@ static const char *sv_mode[] = "avl" }; -static const char *pps_ctrl[] = -{ +static const char *pps_ctrl[] = { "off", "on", "on if >= 1 SV", "on if TRAIM ok" }; -static const char *pps_sync[] = -{ +static const char *pps_sync[] = { "UTC", "GPS" }; -static const char *traim_sol[] = -{ +static const char *traim_sol[] = { "OK", "ALARM", "UNKNOWN" }; -static const char *traim_status[] = -{ +static const char *traim_status[] = { "detect & isolate", "detect", "insufficient" }; -static const char *pos_hold_mode[] = -{ +static const char *pos_hold_mode[] = { "off", "on", "survey" @@ -100,21 +93,21 @@ static bool oncore_initialize(void) unsigned int i; /*@ -onlytrans @*/ - Ea1win = subwin(devicewin, 5, 80, 1, 0); - Eawin = subwin(devicewin, MAXTRACKSATS+3, 27, 6, 0); - Bbwin = subwin(devicewin, MAXVISSATS+3, 22, 6, 28); - Enwin = subwin(devicewin, 10, 29, 6, 51); - Bowin = subwin(devicewin, 4, 11, 17, 0); - Aywin = subwin(devicewin, 4, 15, 17, 12); - Atwin = subwin(devicewin, 5, 9, 16, 51); - Aswin = subwin(devicewin, 5, 19, 16, 61); + Ea1win = subwin(devicewin, 5, 80, 1, 0); + Eawin = subwin(devicewin, MAXTRACKSATS + 3, 27, 6, 0); + Bbwin = subwin(devicewin, MAXVISSATS + 3, 22, 6, 28); + Enwin = subwin(devicewin, 10, 29, 6, 51); + Bowin = subwin(devicewin, 4, 11, 17, 0); + Aywin = subwin(devicewin, 4, 15, 17, 12); + Atwin = subwin(devicewin, 5, 9, 16, 51); + Aswin = subwin(devicewin, 5, 19, 16, 61); /*@ +onlytrans @*/ - if (Ea1win==NULL || Eawin==NULL || Bbwin==NULL || Enwin==NULL - || Bowin==NULL ||Aswin==NULL || Atwin==NULL) + if (Ea1win == NULL || Eawin == NULL || Bbwin == NULL || Enwin == NULL + || Bowin == NULL || Aswin == NULL || Atwin == NULL) return false; - (void)syncok(Ea1win,true); + (void)syncok(Ea1win, true); (void)syncok(Eawin, true); (void)syncok(Bbwin, true); (void)syncok(Enwin, true); @@ -124,30 +117,33 @@ static bool oncore_initialize(void) (void)syncok(Atwin, true); (void)wborder(Ea1win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Ea1win, A_BOLD); - (void)mvwaddstr(Ea1win, 1, 1, "Time: Lat: Lon:"); - (void)mvwaddstr(Ea1win, 2, 1, "Antenna: DOP: Speed: Course:"); - (void)mvwaddstr(Ea1win, 3, 1, "SV/vis: Status: Alt:"); + (void)wattrset(Ea1win, A_BOLD); + (void)mvwaddstr(Ea1win, 1, 1, + "Time: Lat: Lon:"); + (void)mvwaddstr(Ea1win, 2, 1, + "Antenna: DOP: Speed: Course:"); + (void)mvwaddstr(Ea1win, 3, 1, + "SV/vis: Status: Alt:"); (void)mvwprintw(Ea1win, 4, 4, " @@Ea (pos) "); (void)wattrset(Ea1win, A_NORMAL); (void)wborder(Eawin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Eawin, A_BOLD); + (void)wattrset(Eawin, A_BOLD); (void)mvwprintw(Eawin, 1, 1, "Ch PRN mode S/N ????????"); (void)mvwprintw(Eawin, 10, 4, " @@Ea (sat) "); for (i = 0; i < 8; i++) { - (void)mvwprintw(Eawin, (int)(i+2), 1, "%2d",i); + (void)mvwprintw(Eawin, (int)(i + 2), 1, "%2d", i); } (void)wattrset(Eawin, A_NORMAL); (void)wborder(Bbwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Bbwin, A_BOLD); + (void)wattrset(Bbwin, A_BOLD); (void)mvwprintw(Bbwin, 1, 1, "PRN Az El doppl ??"); (void)mvwprintw(Bbwin, 14, 4, " @@Bb "); (void)wattrset(Bbwin, A_NORMAL); (void)wborder(Enwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Enwin, A_BOLD); + (void)wattrset(Enwin, A_BOLD); (void)mvwprintw(Enwin, 1, 1, "Time RAIM: "); (void)mvwprintw(Enwin, 2, 1, "Alarm limit:"); (void)mvwprintw(Enwin, 3, 1, "PPS ctrl:"); @@ -160,25 +156,25 @@ static bool oncore_initialize(void) (void)wattrset(Enwin, A_NORMAL); (void)wborder(Bowin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Bowin, A_BOLD); + (void)wattrset(Bowin, A_BOLD); (void)mvwprintw(Bowin, 1, 1, "UTC:"); (void)mvwprintw(Bowin, 3, 2, " @@Bo "); (void)wattrset(Bowin, A_NORMAL); (void)wborder(Aywin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Aywin, A_BOLD); + (void)wattrset(Aywin, A_BOLD); (void)mvwprintw(Aywin, 1, 1, "PPS delay:"); (void)mvwprintw(Aywin, 3, 4, " @@Ay "); (void)wattrset(Aywin, A_NORMAL); (void)wborder(Atwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Atwin, A_BOLD); + (void)wattrset(Atwin, A_BOLD); (void)mvwprintw(Atwin, 1, 1, "PHold:"); (void)mvwprintw(Atwin, 4, 1, " @@At "); (void)wattrset(Atwin, A_NORMAL); (void)wborder(Aswin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(Aswin, A_BOLD); + (void)wattrset(Aswin, A_BOLD); (void)mvwprintw(Aswin, 1, 1, "Lat:"); (void)mvwprintw(Aswin, 2, 1, "Lon:"); (void)mvwprintw(Aswin, 3, 1, "Alt:"); @@ -198,257 +194,251 @@ static void oncore_update(void) assert(Eawin != NULL); buf = session.packet.outbuffer; - type = ONCTYPE(buf[2],buf[3]); - switch (type) + type = ONCTYPE(buf[2], buf[3]); + switch (type) { + case ONCTYPE('E', 'a'): { - case ONCTYPE('E','a'): - { - double lat, lon, alt; - float speed, track; - float dop; - unsigned short year; - unsigned char mon, day, hour, min, sec; - unsigned int nsec; - unsigned char dopt, nvis, nsat, status; - char statusbuf[64]; /* 6+9+3+3+10+5+7+12+1=56 */ - - mon = (unsigned char)getub(buf, 4); - day = (unsigned char)getub(buf, 5); - year = (unsigned short)getbeuw(buf, 6); - hour = (unsigned char)getub(buf, 8); - min = (unsigned char)getub(buf, 9); - sec = (unsigned char)getub(buf, 10); - nsec = (unsigned int)getbeul(buf, 11); - - lat = getbesl(buf, 15) / 3600000.0; - lon = getbesl(buf, 19) / 3600000.0; - alt = getbesl(buf, 23) / 100.0; - speed = (float)(getbeuw(buf, 31) / 100.0); - track = (float)(getbeuw(buf, 33) / 10.0); - dop = (float)(getbeuw(buf, 35) / 10.0); - dopt = (unsigned char)getub(buf, 37); - nvis = (unsigned char)getub(buf, 38); - nsat = (unsigned char)getub(buf, 39); - status = (unsigned char)getub(buf, 72); - - (void)mvwprintw(Ea1win, 1, 7, "%04d-%02d-%02d %02d:%02d:%02d.%09d", - year,mon,day,hour,min,sec,nsec); - (void)mvwprintw(Ea1win, 1, 47, "%10.6lf %c", - fabs(lat),lat < 0 ? 'S' : lat > 0 ? 'N' : ' '); - (void)mvwprintw(Ea1win, 1, 66, "%10.6lf %c", - fabs(lon),lat < 0 ? 'W' : lon > 0 ? 'E' : ' '); - - (void)mvwprintw(Ea1win, 2, 50, "%6.2f m/s",speed); - (void)mvwprintw(Ea1win, 2, 70, "%5.1f",track); - (void)mvwprintw(Ea1win, 3, 68, "%8.2f m",alt); - - /*@ -predboolothers @*/ - (void)snprintf (statusbuf, sizeof (statusbuf), "%s%s%s%s%s%s%s%s", - status & 0x80 ? "PProp " : "", - status & 0x40 ? "PoorGeom " : "", - status & 0x20 ? "3D " : "", - status & 0x10 ? "2D " : "", - status & 0x08 ? "Acq/PHold " : "", - status & 0x04 ? "Diff " : "", - status & 0x02 ? "Ins (<3 SV) " : "", - status & 0x01 ? "BadAlm " : ""); - /*@ +predboolothers @*/ - - (void)mvwprintw(Ea1win, 3, 24, "%-37s",statusbuf); - - (void)mvwprintw(Ea1win, 2, 10, "%-10s",antenna[dopt >> 6]); - - /*@ -predboolothers @*/ - (void)mvwprintw(Ea1win, 2, 27, "%s %4.1f", - dopt & 1 ? "hdop" : "pdop", - dop); - /*@ +predboolothers @*/ - - (void)mvwprintw(Ea1win, 3, 10, "%d/%d ",nsat,nvis); - } + double lat, lon, alt; + float speed, track; + float dop; + unsigned short year; + unsigned char mon, day, hour, min, sec; + unsigned int nsec; + unsigned char dopt, nvis, nsat, status; + char statusbuf[64]; /* 6+9+3+3+10+5+7+12+1=56 */ + + mon = (unsigned char)getub(buf, 4); + day = (unsigned char)getub(buf, 5); + year = (unsigned short)getbeuw(buf, 6); + hour = (unsigned char)getub(buf, 8); + min = (unsigned char)getub(buf, 9); + sec = (unsigned char)getub(buf, 10); + nsec = (unsigned int)getbeul(buf, 11); + + lat = getbesl(buf, 15) / 3600000.0; + lon = getbesl(buf, 19) / 3600000.0; + alt = getbesl(buf, 23) / 100.0; + speed = (float)(getbeuw(buf, 31) / 100.0); + track = (float)(getbeuw(buf, 33) / 10.0); + dop = (float)(getbeuw(buf, 35) / 10.0); + dopt = (unsigned char)getub(buf, 37); + nvis = (unsigned char)getub(buf, 38); + nsat = (unsigned char)getub(buf, 39); + status = (unsigned char)getub(buf, 72); + + (void)mvwprintw(Ea1win, 1, 7, "%04d-%02d-%02d %02d:%02d:%02d.%09d", + year, mon, day, hour, min, sec, nsec); + (void)mvwprintw(Ea1win, 1, 47, "%10.6lf %c", + fabs(lat), lat < 0 ? 'S' : lat > 0 ? 'N' : ' '); + (void)mvwprintw(Ea1win, 1, 66, "%10.6lf %c", + fabs(lon), lat < 0 ? 'W' : lon > 0 ? 'E' : ' '); + + (void)mvwprintw(Ea1win, 2, 50, "%6.2f m/s", speed); + (void)mvwprintw(Ea1win, 2, 70, "%5.1f", track); + (void)mvwprintw(Ea1win, 3, 68, "%8.2f m", alt); + + /*@ -predboolothers @*/ + (void)snprintf(statusbuf, sizeof(statusbuf), "%s%s%s%s%s%s%s%s", + status & 0x80 ? "PProp " : "", + status & 0x40 ? "PoorGeom " : "", + status & 0x20 ? "3D " : "", + status & 0x10 ? "2D " : "", + status & 0x08 ? "Acq/PHold " : "", + status & 0x04 ? "Diff " : "", + status & 0x02 ? "Ins (<3 SV) " : "", + status & 0x01 ? "BadAlm " : ""); + /*@ +predboolothers @*/ + + (void)mvwprintw(Ea1win, 3, 24, "%-37s", statusbuf); + + (void)mvwprintw(Ea1win, 2, 10, "%-10s", antenna[dopt >> 6]); + + /*@ -predboolothers @*/ + (void)mvwprintw(Ea1win, 2, 27, "%s %4.1f", + dopt & 1 ? "hdop" : "pdop", dop); + /*@ +predboolothers @*/ + + (void)mvwprintw(Ea1win, 3, 10, "%d/%d ", nsat, nvis); + } for (i = 0; i < 8; i++) { unsigned char sv, mode, sn, status; off = 40 + 4 * i; - sv = (unsigned char)getub(buf, off); - mode = (unsigned char)getub(buf, off+1); - sn = (unsigned char)getub(buf, off+2); - status = (unsigned char)getub(buf, off+3); - (void)wmove(Eawin, (int)(i+2), 3); - (void)wprintw(Eawin, " %3d",sv); + sv = (unsigned char)getub(buf, off); + mode = (unsigned char)getub(buf, off + 1); + sn = (unsigned char)getub(buf, off + 2); + status = (unsigned char)getub(buf, off + 3); + (void)wmove(Eawin, (int)(i + 2), 3); + (void)wprintw(Eawin, " %3d", sv); EaSVlines[i] = sv; - if (mode <= (unsigned char) 8) - (void)wprintw(Eawin, " %4s",sv_mode[mode]); + if (mode <= (unsigned char)8) + (void)wprintw(Eawin, " %4s", sv_mode[mode]); else - (void)wprintw(Eawin, " -"); - (void)wprintw(Eawin, " %3d",sn); + (void)wprintw(Eawin, " -"); + (void)wprintw(Eawin, " %3d", sn); /*@ -predboolothers @*/ - (void)wprintw(Eawin, " %c%c%c%c%c%c%c%c", - (status & 0x80) ? 'p' : ' ', /* used for pos fix */ - (status & 0x40) ? 'M' : ' ', /* momentum alert */ - (status & 0x20) ? 's' : ' ', /* anti-spoof */ - (status & 0x10) ? 'U' : ' ', /* unhealthy */ - (status & 0x08) ? 'I' : ' ', /* inaccurate */ - (status & 0x04) ? 'S' : ' ', /* spare */ - (status & 0x02) ? 't' : ' ', /* used for time sol */ - (status & 0x01) ? 'P' : ' '); /* parity error */ + (void)wprintw(Eawin, " %c%c%c%c%c%c%c%c", (status & 0x80) ? 'p' : ' ', /* used for pos fix */ + (status & 0x40) ? 'M' : ' ', /* momentum alert */ + (status & 0x20) ? 's' : ' ', /* anti-spoof */ + (status & 0x10) ? 'U' : ' ', /* unhealthy */ + (status & 0x08) ? 'I' : ' ', /* inaccurate */ + (status & 0x04) ? 'S' : ' ', /* spare */ + (status & 0x02) ? 't' : ' ', /* used for time sol */ + (status & 0x01) ? 'P' : ' '); /* parity error */ /*@ +predboolothers @*/ } monitor_log("Ea ="); break; - case ONCTYPE('B','b'): - { - unsigned int Bblines[12]; - unsigned int Bblines_mask; - unsigned int next_line; - unsigned char sv; - unsigned int ch; - - ch = (unsigned int)getub(buf, 4); - if (ch > 12) - ch = 12; - /* Try to align the entries for each SV of the Bb message at - * the same lines as in the Ea message. - */ - memset(Bblines, 0, sizeof(Bblines)); - Bblines_mask = 0; - for (i = 0; i < ch; i++) { - off = 5 + 7 * i; - sv = (unsigned char)getub(buf, off); - /*@ -boolops @*/ - for (j = 0; j < 8; j++) - if (EaSVlines[j] == sv && - !(Bblines_mask & (1 << (j+2)))) { - Bblines[i] = j+2; - Bblines_mask |= 1 << Bblines[i]; - } - /*@ +boolops @*/ - } - /* SVs not seen in Ea fill lines left over. */ - next_line = 2; - for (i = 0; i < ch; i++) { - if (Bblines[i] == 0) { - while (Bblines_mask & (1 << next_line)) - next_line++; - Bblines[i] = next_line++; + case ONCTYPE('B', 'b'): + { + unsigned int Bblines[12]; + unsigned int Bblines_mask; + unsigned int next_line; + unsigned char sv; + unsigned int ch; + + ch = (unsigned int)getub(buf, 4); + if (ch > 12) + ch = 12; + /* Try to align the entries for each SV of the Bb message at + * the same lines as in the Ea message. + */ + memset(Bblines, 0, sizeof(Bblines)); + Bblines_mask = 0; + for (i = 0; i < ch; i++) { + off = 5 + 7 * i; + sv = (unsigned char)getub(buf, off); + /*@ -boolops @*/ + for (j = 0; j < 8; j++) + if (EaSVlines[j] == sv && !(Bblines_mask & (1 << (j + 2)))) { + Bblines[i] = j + 2; Bblines_mask |= 1 << Bblines[i]; } + /*@ +boolops @*/ + } + /* SVs not seen in Ea fill lines left over. */ + next_line = 2; + for (i = 0; i < ch; i++) { + if (Bblines[i] == 0) { + while (Bblines_mask & (1 << next_line)) + next_line++; + Bblines[i] = next_line++; + Bblines_mask |= 1 << Bblines[i]; } - /* Ready to print on precalculated lines. */ - for (i = 0; i < ch; i++) { - int doppl, el, az, health; - - off = 5 + 7 * i; - sv = (unsigned char)getub(buf, off); - doppl = (int)getbesw(buf, off+1); - el = (int)getub(buf, off+3); - az = (int)getbeuw(buf, off+4); - health = (int)getub(buf, off+5); - - (void)wmove(Bbwin, (int)Bblines[i], 1); - (void)wprintw(Bbwin, "%3d %3d %2d %5d %c%c", - sv,az,el,doppl, - (health & 0x02) ? 'U' : ' ', /* unhealthy */ - (health & 0x01) ? 'R' : ' '); /* removed */ - } - - for (i = 2; i < 14; i++) - /*@ -boolops @*/ - if (!(Bblines_mask & (1 << i))) { - (void)wmove(Bbwin, (int)i, 1); - (void)wprintw(Bbwin, " "); - } - /*@ +boolops @*/ } + /* Ready to print on precalculated lines. */ + for (i = 0; i < ch; i++) { + int doppl, el, az, health; + + off = 5 + 7 * i; + sv = (unsigned char)getub(buf, off); + doppl = (int)getbesw(buf, off + 1); + el = (int)getub(buf, off + 3); + az = (int)getbeuw(buf, off + 4); + health = (int)getub(buf, off + 5); + + (void)wmove(Bbwin, (int)Bblines[i], 1); + (void)wprintw(Bbwin, "%3d %3d %2d %5d %c%c", sv, az, el, doppl, (health & 0x02) ? 'U' : ' ', /* unhealthy */ + (health & 0x01) ? 'R' : ' '); /* removed */ + } + + for (i = 2; i < 14; i++) + /*@ -boolops @*/ + if (!(Bblines_mask & (1 << i))) { + (void)wmove(Bbwin, (int)i, 1); + (void)wprintw(Bbwin, " "); + } + /*@ +boolops @*/ + } monitor_log("Bb ="); break; - case ONCTYPE('E','n'): - { - unsigned char traim, ctrl, pulse, sync, sol_stat, status; - float alarm, sigma; - - traim = (unsigned char)getub(buf, 5); - alarm = (float)(getbeuw(buf, 6) / 10.); - ctrl = (unsigned char)getub(buf, 8); - pulse = (unsigned char)getub(buf, 9); - sync = (unsigned char)getub(buf, 10); - sol_stat = (unsigned char)getub(buf, 11); - status = (unsigned char)getub(buf, 12); - sigma = (float)(getbeuw(buf, 13)); - - /*@ -predboolothers @*/ - (void)mvwprintw(Enwin, 1, 24, "%3s",traim ? "on" : "off"); - (void)mvwprintw(Enwin, 2, 18, "%6.1f us",alarm); - (void)mvwprintw(Enwin, 3, 13, "%14s",pps_ctrl[ctrl]); - (void)mvwprintw(Enwin, 4, 24, "%3s",pulse ? "on" : "off"); - (void)mvwprintw(Enwin, 5, 24, "%3s",pps_sync[sync]); - (void)mvwprintw(Enwin, 6, 20, "%7s",traim_sol[sol_stat]); - (void)mvwprintw(Enwin, 7, 11, "%16s",traim_status[status]); - (void)mvwprintw(Enwin, 8, 18, "%6.3f us",sigma); - /*@ +predboolothers @*/ - } + case ONCTYPE('E', 'n'): + { + unsigned char traim, ctrl, pulse, sync, sol_stat, status; + float alarm, sigma; + + traim = (unsigned char)getub(buf, 5); + alarm = (float)(getbeuw(buf, 6) / 10.); + ctrl = (unsigned char)getub(buf, 8); + pulse = (unsigned char)getub(buf, 9); + sync = (unsigned char)getub(buf, 10); + sol_stat = (unsigned char)getub(buf, 11); + status = (unsigned char)getub(buf, 12); + sigma = (float)(getbeuw(buf, 13)); + + /*@ -predboolothers @*/ + (void)mvwprintw(Enwin, 1, 24, "%3s", traim ? "on" : "off"); + (void)mvwprintw(Enwin, 2, 18, "%6.1f us", alarm); + (void)mvwprintw(Enwin, 3, 13, "%14s", pps_ctrl[ctrl]); + (void)mvwprintw(Enwin, 4, 24, "%3s", pulse ? "on" : "off"); + (void)mvwprintw(Enwin, 5, 24, "%3s", pps_sync[sync]); + (void)mvwprintw(Enwin, 6, 20, "%7s", traim_sol[sol_stat]); + (void)mvwprintw(Enwin, 7, 11, "%16s", traim_status[status]); + (void)mvwprintw(Enwin, 8, 18, "%6.3f us", sigma); + /*@ +predboolothers @*/ + } monitor_log("En ="); break; - case ONCTYPE('B','o'): - { - unsigned char utc_offset; + case ONCTYPE('B', 'o'): + { + unsigned char utc_offset; - utc_offset = (unsigned char)getub(buf, 4); + utc_offset = (unsigned char)getub(buf, 4); - if (utc_offset != (unsigned char) 0) - (void)mvwprintw(Bowin, 2, 2, "GPS%+4d",utc_offset); - else - (void)mvwprintw(Bowin, 2, 2, "unknown",utc_offset); - } + if (utc_offset != (unsigned char)0) + (void)mvwprintw(Bowin, 2, 2, "GPS%+4d", utc_offset); + else + (void)mvwprintw(Bowin, 2, 2, "unknown", utc_offset); + } monitor_log("Bo ="); break; - case ONCTYPE('A','y'): - { - double pps_delay; + case ONCTYPE('A', 'y'): + { + double pps_delay; - pps_delay = getbesl(buf, 4) / 1000000.0; + pps_delay = getbesl(buf, 4) / 1000000.0; - (void)mvwprintw(Aywin, 2, 2, " %7.3f ms",pps_delay); - } + (void)mvwprintw(Aywin, 2, 2, " %7.3f ms", pps_delay); + } monitor_log("Ay ="); break; - case ONCTYPE('A','t'): - { - unsigned char mode; + case ONCTYPE('A', 't'): + { + unsigned char mode; - mode = (unsigned char)getub(buf, 4); + mode = (unsigned char)getub(buf, 4); - (void)mvwprintw(Atwin, 2, 1, "%6s",pos_hold_mode[mode]); - } + (void)mvwprintw(Atwin, 2, 1, "%6s", pos_hold_mode[mode]); + } monitor_log("At ="); break; - case ONCTYPE('A','s'): - { - double lat, lon, alt; + case ONCTYPE('A', 's'): + { + double lat, lon, alt; - lat = getbesl(buf, 4) / 3600000.0; - lon = getbesl(buf, 8) / 3600000.0; - alt = getbesl(buf, 12) / 100.0; + lat = getbesl(buf, 4) / 3600000.0; + lon = getbesl(buf, 8) / 3600000.0; + alt = getbesl(buf, 12) / 100.0; - (void)mvwprintw(Aswin, 1, 5, "%10.6lf %c", - fabs(lat),lat < 0 ? 'S' : lat > 0 ? 'N' : ' '); - (void)mvwprintw(Aswin, 2, 5, "%10.6lf %c", - fabs(lon),lat < 0 ? 'W' : lon > 0 ? 'E' : ' '); - (void)mvwprintw(Aswin, 3, 7, "%8.2f m",alt); - } + (void)mvwprintw(Aswin, 1, 5, "%10.6lf %c", + fabs(lat), lat < 0 ? 'S' : lat > 0 ? 'N' : ' '); + (void)mvwprintw(Aswin, 2, 5, "%10.6lf %c", + fabs(lon), lat < 0 ? 'W' : lon > 0 ? 'E' : ' '); + (void)mvwprintw(Aswin, 3, 7, "%8.2f m", alt); + } monitor_log("As ="); break; @@ -459,7 +449,7 @@ static void oncore_update(void) } } -static int oncore_command(char line[] UNUSED) +static int oncore_command(char line[]UNUSED) { return COMMAND_UNKNOWN; } @@ -481,7 +471,7 @@ const struct monitor_object_t oncore_mmt = { .update = oncore_update, .command = oncore_command, .wrap = oncore_wrap, - .min_y = 20, .min_x = 80, /* size of the device window */ + .min_y = 20,.min_x = 80, /* size of the device window */ .driver = &oncore_binary, }; diff --git a/monitor_sirf.c b/monitor_sirf.c index d342a95e..7a0430fc 100644 --- a/monitor_sirf.c +++ b/monitor_sirf.c @@ -35,11 +35,10 @@ extern const struct gps_type_t sirf_binary; static WINDOW *mid2win, *mid4win, *mid6win, *mid7win, *mid9win, *mid13win; static WINDOW *mid19win, *mid27win; static bool dispmode = false, subframe_enabled = false; -static int nfix,fix[20]; +static int nfix, fix[20]; /*@ -nullassign @*/ -static char *verbpat[] = -{ +static char *verbpat[] = { "#Time:", "@R Time:", "CSTD: New almanac for", @@ -49,10 +48,10 @@ static char *verbpat[] = "rtcaj tow ", NULL }; + /*@ +nullassign @*/ -static char *dgpsvec[] = -{ +static char *dgpsvec[] = { "None", "SBAS", "Serial", @@ -75,16 +74,17 @@ static bool sirf_initialize(void) unsigned int i; /*@ -onlytrans @*/ - mid2win = subwin(devicewin, 7, 80, 1, 0); - mid4win = subwin(devicewin, MAXSATS+3, 30, 8, 0); - mid6win = subwin(devicewin, 3, 50, 8, 30); - mid7win = subwin(devicewin, 4, 50, 11, 30); - mid9win = subwin(devicewin, 3, 50, 15, 30); - mid13win = subwin(devicewin, 3, 50, 18, 30); - mid19win = newwin(16, 50, 8, 30); - mid27win = subwin(devicewin, 3, 50, 21, 30); - if (mid2win==NULL || mid4win==NULL || mid6win==NULL || mid9win==NULL - || mid13win==NULL || mid19win==NULL || mid27win==NULL) + mid2win = subwin(devicewin, 7, 80, 1, 0); + mid4win = subwin(devicewin, MAXSATS + 3, 30, 8, 0); + mid6win = subwin(devicewin, 3, 50, 8, 30); + mid7win = subwin(devicewin, 4, 50, 11, 30); + mid9win = subwin(devicewin, 3, 50, 15, 30); + mid13win = subwin(devicewin, 3, 50, 18, 30); + mid19win = newwin(16, 50, 8, 30); + mid27win = subwin(devicewin, 3, 50, 21, 30); + if (mid2win == NULL || mid4win == NULL || mid6win == NULL + || mid9win == NULL || mid13win == NULL || mid19win == NULL + || mid27win == NULL) return false; (void)syncok(mid2win, true); @@ -97,39 +97,43 @@ static bool sirf_initialize(void) /*@ -nullpass @*/ (void)wborder(mid2win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid2win, A_BOLD); - (void)wmove(mid2win, 0,1); - display(mid2win, 0, 12, " X "); - display(mid2win, 0, 21, " Y "); - display(mid2win, 0, 30, " Z "); - display(mid2win, 0, 43, " North "); - display(mid2win, 0, 54, " East "); - display(mid2win, 0, 65, " Alt "); - - (void)wmove(mid2win, 1,1); - (void)wprintw(mid2win, "Pos: m m"); - (void)wmove(mid2win, 2,1); - (void)wprintw(mid2win, "Vel: m/s climb m/s"); - (void)wmove(mid2win, 3,1); - (void)wprintw(mid2win, "Week+TOW: Day: Heading: speed m/s"); - (void)wmove(mid2win, 4,1); - (void)wprintw(mid2win, "Skew: TZ: HDOP: M1: M2: "); - (void)wmove(mid2win, 5,1); + (void)wattrset(mid2win, A_BOLD); + (void)wmove(mid2win, 0, 1); + display(mid2win, 0, 12, " X "); + display(mid2win, 0, 21, " Y "); + display(mid2win, 0, 30, " Z "); + display(mid2win, 0, 43, " North "); + display(mid2win, 0, 54, " East "); + display(mid2win, 0, 65, " Alt "); + + (void)wmove(mid2win, 1, 1); + (void)wprintw(mid2win, + "Pos: m m"); + (void)wmove(mid2win, 2, 1); + (void)wprintw(mid2win, + "Vel: m/s climb m/s"); + (void)wmove(mid2win, 3, 1); + (void)wprintw(mid2win, + "Week+TOW: Day: Heading: speed m/s"); + (void)wmove(mid2win, 4, 1); + (void)wprintw(mid2win, + "Skew: TZ: HDOP: M1: M2: "); + (void)wmove(mid2win, 5, 1); (void)wprintw(mid2win, "Fix:"); display(mid2win, 6, 24, " Packet type 2 (0x02) "); (void)wattrset(mid2win, A_NORMAL); (void)wborder(mid4win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid4win, A_BOLD); + (void)wattrset(mid4win, A_BOLD); display(mid4win, 1, 1, "Ch PRN Az El Stat C/N ? A"); for (i = 0; i < MAXSATS; i++) { - display(mid4win, (int)(i+2), 1, "%2d",i); + display(mid4win, (int)(i + 2), 1, "%2d", i); } display(mid4win, 14, 4, " Packet Type 4 (0x04) "); (void)wattrset(mid4win, A_NORMAL); (void)wborder(mid19win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid19win, A_BOLD); + (void)wattrset(mid19win, A_BOLD); display(mid19win, 1, 1, "Alt. hold mode:"); display(mid19win, 2, 1, "Alt. hold source:"); display(mid19win, 3, 1, "Alt. source input:"); @@ -138,48 +142,48 @@ static bool sirf_initialize(void) display(mid19win, 6, 1, "Track smooth mode:"); display(mid19win, 7, 1, "Static Navigation:"); display(mid19win, 8, 1, "3SV Least Squares:"); - display(mid19win, 9 ,1, "DOP Mask mode:"); - display(mid19win, 10,1, "Nav. Elev. mask:"); - display(mid19win, 11,1, "Nav. Power mask:"); - display(mid19win, 12,1, "DGPS Source:"); - display(mid19win, 13,1, "DGPS Mode:"); - display(mid19win, 14,1, "DGPS Timeout:"); - display(mid19win, 1, 26,"LP Push-to-Fix:"); - display(mid19win, 2, 26,"LP On Time:"); - display(mid19win, 3, 26,"LP Interval:"); - display(mid19win, 4, 26,"U. Tasks Enab.:"); - display(mid19win, 5, 26,"U. Task Inter.:"); - display(mid19win, 6, 26,"LP Pwr Cyc En:"); - display(mid19win, 7, 26,"LP Max Acq Srch:"); - display(mid19win, 8, 26,"LP Max Off Time:"); - display(mid19win, 9, 26,"APM enabled:"); - display(mid19win,10, 26,"# of Fixes:"); - display(mid19win,11, 26,"Time btw Fixes:"); - display(mid19win,12, 26,"H/V Error Max:"); - display(mid19win,13, 26,"Rsp Time Max:"); - display(mid19win,14, 26,"Time/Accu:"); + display(mid19win, 9, 1, "DOP Mask mode:"); + display(mid19win, 10, 1, "Nav. Elev. mask:"); + display(mid19win, 11, 1, "Nav. Power mask:"); + display(mid19win, 12, 1, "DGPS Source:"); + display(mid19win, 13, 1, "DGPS Mode:"); + display(mid19win, 14, 1, "DGPS Timeout:"); + display(mid19win, 1, 26, "LP Push-to-Fix:"); + display(mid19win, 2, 26, "LP On Time:"); + display(mid19win, 3, 26, "LP Interval:"); + display(mid19win, 4, 26, "U. Tasks Enab.:"); + display(mid19win, 5, 26, "U. Task Inter.:"); + display(mid19win, 6, 26, "LP Pwr Cyc En:"); + display(mid19win, 7, 26, "LP Max Acq Srch:"); + display(mid19win, 8, 26, "LP Max Off Time:"); + display(mid19win, 9, 26, "APM enabled:"); + display(mid19win, 10, 26, "# of Fixes:"); + display(mid19win, 11, 26, "Time btw Fixes:"); + display(mid19win, 12, 26, "H/V Error Max:"); + display(mid19win, 13, 26, "Rsp Time Max:"); + display(mid19win, 14, 26, "Time/Accu:"); display(mid19win, 15, 8, " Packet type 19 (0x13) "); (void)wattrset(mid19win, A_NORMAL); (void)wborder(mid6win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid6win, A_BOLD); + (void)wattrset(mid6win, A_BOLD); display(mid6win, 1, 1, "Version:"); display(mid6win, 2, 8, " Packet Type 6 (0x06) "); (void)wattrset(mid6win, A_NORMAL); (void)wborder(mid7win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid7win, A_BOLD); - display(mid7win, 1, 1, "SVs: "); - display(mid7win, 1, 9, "Drift: "); + (void)wattrset(mid7win, A_BOLD); + display(mid7win, 1, 1, "SVs: "); + display(mid7win, 1, 9, "Drift: "); display(mid7win, 1, 23, "Bias: "); - display(mid7win, 2, 1, "Estimated GPS Time: "); + display(mid7win, 2, 1, "Estimated GPS Time: "); display(mid7win, 3, 8, " Packet type 7 (0x07) "); (void)wattrset(mid7win, A_NORMAL); (void)wborder(mid9win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid9win, A_BOLD); - display(mid9win, 1, 1, "Max: "); + (void)wattrset(mid9win, A_BOLD); + display(mid9win, 1, 1, "Max: "); display(mid9win, 1, 13, "Lat: "); display(mid9win, 1, 25, "Time: "); display(mid9win, 1, 39, "MS: "); @@ -187,14 +191,14 @@ static bool sirf_initialize(void) (void)wattrset(mid9win, A_NORMAL); (void)wborder(mid13win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid13win, A_BOLD); + (void)wattrset(mid13win, A_BOLD); display(mid13win, 1, 1, "SVs: "); display(mid13win, 1, 9, "="); display(mid13win, 2, 8, " Packet type 13 (0x0D) "); (void)wattrset(mid13win, A_NORMAL); (void)wborder(mid27win, 0, 0, 0, 0, 0, 0, 0, 0), - (void)wattrset(mid27win, A_BOLD); + (void)wattrset(mid27win, A_BOLD); display(mid27win, 1, 1, "DGPS source: "); display(mid27win, 1, 31, "Corrections: "); display(mid27win, 2, 8, " Packet type 27 (0x1B) "); @@ -222,13 +226,14 @@ static void decode_time(int week, int tow) m = (m - s) / 6000; - (void)wmove(mid2win, 3,10); - (void)wprintw(mid2win, "%4d+%9.2f", week, (double)tow/100); + (void)wmove(mid2win, 3, 10); + (void)wprintw(mid2win, "%4d+%9.2f", week, (double)tow / 100); (void)wmove(mid2win, 3, 30); - (void)wprintw(mid2win, "%d %02d:%02d:%05.2f", day, h,m,(double)s/100); + (void)wprintw(mid2win, "%d %02d:%02d:%05.2f", day, h, m, (double)s / 100); (void)wmove(mid2win, 4, 8); (void)wattrset(mid2win, A_UNDERLINE); - (void)wprintw(mid2win, "%f", timestamp()-gpstime_to_unix(week,tow/100.0)); + (void)wprintw(mid2win, "%f", + timestamp() - gpstime_to_unix(week, tow / 100.0)); (void)wmove(mid2win, 4, 29); (void)wprintw(mid2win, "%d", gmt_offset); (void)wattrset(mid2win, A_NORMAL); @@ -239,104 +244,120 @@ static void decode_ecef(double x, double y, double z, { const double a = WGS84A; const double b = WGS84B; - const double e2 = (a*a - b*b) / (a*a); - const double e_2 = (a*a - b*b) / (b*b); - double lambda,p,theta,phi,n,h,vnorth,veast,vup,speed,heading; + const double e2 = (a * a - b * b) / (a * a); + const double e_2 = (a * a - b * b) / (b * b); + double lambda, p, theta, phi, n, h, vnorth, veast, vup, speed, heading; - lambda = atan2(y,x); + lambda = atan2(y, x); /*@ -evalorder @*/ - p = sqrt(pow(x,2) + pow(y,2)); - theta = atan2(z*a,p*b); - phi = atan2(z + e_2*b*pow(sin(theta),3),p - e2*a*pow(cos(theta),3)); - n = a / sqrt(1.0 - e2*pow(sin(phi),2)); + p = sqrt(pow(x, 2) + pow(y, 2)); + theta = atan2(z * a, p * b); + phi = + atan2(z + e_2 * b * pow(sin(theta), 3), + p - e2 * a * pow(cos(theta), 3)); + n = a / sqrt(1.0 - e2 * pow(sin(phi), 2)); h = p / cos(phi) - n; - h -= wgs84_separation((double)(RAD_2_DEG*phi),(double)(RAD_2_DEG*lambda)); - vnorth = -vx*sin(phi)*cos(lambda)-vy*sin(phi)*sin(lambda)+vz*cos(phi); - veast = -vx*sin(lambda)+vy*cos(lambda); - vup = vx*cos(phi)*cos(lambda)+vy*cos(phi)*sin(lambda)+vz*sin(phi); - speed = sqrt(pow(vnorth,2) + pow(veast,2)); - heading = atan2(veast,vnorth); + h -= wgs84_separation((double)(RAD_2_DEG * phi), + (double)(RAD_2_DEG * lambda)); + vnorth = + -vx * sin(phi) * cos(lambda) - vy * sin(phi) * sin(lambda) + + vz * cos(phi); + veast = -vx * sin(lambda) + vy * cos(lambda); + vup = + vx * cos(phi) * cos(lambda) + vy * cos(phi) * sin(lambda) + + vz * sin(phi); + speed = sqrt(pow(vnorth, 2) + pow(veast, 2)); + heading = atan2(veast, vnorth); /*@ +evalorder @*/ if (heading < 0) heading += 2 * GPS_PI; (void)wattrset(mid2win, A_UNDERLINE); - (void)wmove(mid2win, 1,40); - (void)wprintw(mid2win, "%9.5f %9.5f",(double)(RAD_2_DEG*phi), - (double)(RAD_2_DEG*lambda)); + (void)wmove(mid2win, 1, 40); + (void)wprintw(mid2win, "%9.5f %9.5f", (double)(RAD_2_DEG * phi), + (double)(RAD_2_DEG * lambda)); (void)mvwaddch(mid2win, 1, 49, ACS_DEGREE); (void)mvwaddch(mid2win, 1, 59, ACS_DEGREE); - (void)wmove(mid2win, 1,61); - (void)wprintw(mid2win, "%8d",(int)h); + (void)wmove(mid2win, 1, 61); + (void)wprintw(mid2win, "%8d", (int)h); - (void)wmove(mid2win, 2,40); - (void)wprintw(mid2win, "%9.1f %9.1f",vnorth,veast); - (void)wmove(mid2win, 2,61); - (void)wprintw(mid2win, "%8.1f",vup); + (void)wmove(mid2win, 2, 40); + (void)wprintw(mid2win, "%9.1f %9.1f", vnorth, veast); + (void)wmove(mid2win, 2, 61); + (void)wprintw(mid2win, "%8.1f", vup); - (void)wmove(mid2win, 3,54); - (void)wprintw(mid2win, "%5.1f",(double)(RAD_2_DEG*heading)); + (void)wmove(mid2win, 3, 54); + (void)wprintw(mid2win, "%5.1f", (double)(RAD_2_DEG * heading)); (void)mvwaddch(mid2win, 3, 59, ACS_DEGREE); - (void)wmove(mid2win, 3,61); - (void)wprintw(mid2win, "%8.1f",speed); + (void)wmove(mid2win, 3, 61); + (void)wprintw(mid2win, "%8.1f", speed); (void)wattrset(mid2win, A_NORMAL); } /*@ -globstate */ static void sirf_update(void) { - int i,j,ch,off,cn; + 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]) - { - 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 */ + 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)); + (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); + (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 */ + (void)wprintw(mid2win, "%d = ", nfix); /* SVs in fix */ for (i = 0; i < MAXSATS; i++) { /* SV list */ if (i < nfix) - (void)wprintw(mid2win, "%3d",fix[i] = (int)getub(buf, 29+i)); + (void)wprintw(mid2win, "%3d", fix[i] = + (int)getub(buf, 29 + i)); else (void)wprintw(mid2win, " "); } monitor_log("MND 0x02="); break; - case 0x04: /* Measured Tracking Data */ - decode_time((int)getbeuw(buf, 1),getbesl(buf, 3)); + 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; - + int sv, st; + off = 8 + 15 * i; - (void)wmove(mid4win, i+2, 3); + (void)wmove(mid4win, i + 2, 3); sv = (int)getub(buf, off); - (void)wprintw(mid4win, " %3d",sv); + (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)); + (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) + if ((int)getbeuw(buf, off + 3) == 0xbf) st = 'T'; for (j = 0; j < nfix; j++) if (sv == fix[j]) { @@ -347,79 +368,80 @@ static void sirf_update(void) cn = 0; for (j = 0; j < 10; j++) - cn += (int)getub(buf, off+5+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? */ + if (sv == 0) /* not tracking? */ (void)wprintw(mid4win, " "); /* clear other info */ } monitor_log("MTD 0x04="); break; #ifdef __UNUSED__ - case 0x05: /* raw track data */ + case 0x05: /* raw track data */ for (off = 1; off < len; off += 51) { ch = getbeul(buf, off); - (void)wmove(mid4win, ch+2, 19); + (void)wmove(mid4win, ch + 2, 19); cn = 0; for (j = 0; j < 10; j++) - cn += getub(buf, off+34+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); + 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); } monitor_log("RTD 0x05="); break; #endif /* __UNUSED */ - case 0x06: /* firmware version */ - display(mid6win, 1, 10, "%s",buf + 1); + case 0x06: /* firmware version */ + display(mid6win, 1, 10, "%s", buf + 1); monitor_log("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 */ + 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 */ monitor_log("CSD 0x07="); break; - case 0x08: /* 50 BPS data */ + case 0x08: /* 50 BPS data */ ch = (int)getub(buf, 1); - display(mid4win, ch+2, 27, "Y"); + display(mid4win, ch + 2, 27, "Y"); monitor_log("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 */ + 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 */ monitor_log("THR 0x09="); break; - case 0x0b: /* Command Acknowledgement */ + case 0x0b: /* Command Acknowledgement */ monitor_log("ACK 0x0b="); break; - case 0x0c: /* Command NAcknowledgement */ + case 0x0c: /* Command NAcknowledgement */ monitor_log("NAK 0x0c="); break; - case 0x0d: /* Visible List */ - display(mid13win, 1, 6, "%02d",getub(buf, 1)); + case 0x0d: /* Visible List */ + display(mid13win, 1, 6, "%02d", getub(buf, 1)); (void)wmove(mid13win, 1, 10); for (i = 0; i < MAXSATS; i++) { if (i < (int)getub(buf, 1)) - (void)wprintw(mid13win, " %2d",getub(buf, 2 + 5 * i)); + (void)wprintw(mid13win, " %2d", getub(buf, 2 + 5 * i)); else (void)wprintw(mid13win, " "); } @@ -429,38 +451,38 @@ static void sirf_update(void) 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) != (uint8_t)'\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, 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) != (uint8_t) '\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: /****************************************************************** @@ -504,12 +526,12 @@ static void sirf_update(void) total 3 x 12 = 36 bytes ******************************************************************/ - display(mid27win, 1, 14, "%d (%s)", + 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') { + if (getub(buf, 16 + 3 * i) != '\0') { //(void)wprintw(mid27win, " %d=%d", getub(buf, 16+3*i), getbesw(buf, 16+3*i+1)); j++; } @@ -519,61 +541,62 @@ static void sirf_update(void) monitor_log("DST 0x1b="); break; - case 0x1C: /* NL Measurement Data */ - case 0x1D: /* DGPS Data */ - case 0x1E: /* SV State Data */ - case 0x1F: /* NL Initialized Data */ + 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 */ + case 0x29: /* Geodetic Navigation Message */ monitor_log("GNM 0x29="); break; - case 0x32: /* SBAS Parameters */ + case 0x32: /* SBAS Parameters */ monitor_log("SBP 0x32="); break; - case 0x34: /* PPS Time */ + case 0x34: /* PPS Time */ monitor_log("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(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); + move(3, 63); - printw("%8.1f",(double)getbesl(buf, 17)/1000); + printw("%8.1f", (double)getbesl(buf, 17) / 1000); - move(4,54); + move(4, 54); if (getbeul(buf, 13) > 50) { - double heading = RAD_2_DEG*1e8*getbesl(buf, 21); + double heading = RAD_2_DEG * 1e8 * getbesl(buf, 21); if (heading < 0) heading += 360; - printw("%5.1f",heading); + printw("%5.1f", heading); } else printw(" 0.0"); - move(4,63); - printw("%8.1f",(double)getbesl(buf, 13)/1000); + move(4, 63); + printw("%8.1f", (double)getbesl(buf, 13) / 1000); attrset(A_NORMAL); - move(5,13); + 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); + (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 timeval clk, gps; struct tm tm; - gettimeofday(&clk,NULL); + gettimeofday(&clk, NULL); - memset(&tm,0,sizeof(tm)); - tm.tm_sec = (unsigned short)getbeuw(buf, 32)/1000; + 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); @@ -581,39 +604,41 @@ static void sirf_update(void) tm.tm_year = (int)getbeuw(buf, 26) - 1900; gps.tv_sec = mkgmtime(&tm); - gps.tv_usec = (((unsigned short)getbeuw(buf, 32)%1000)/10) * 10000; + gps.tv_usec = + (((unsigned short)getbeuw(buf, 32) % 1000) / 10) * 10000; - move(5,2); + move(5, 2); printw(" "); - move(5,2); -#if 1 - printw("%ld",(gps.tv_usec - clk.tv_usec) + + move(5, 2); +#if 1 + 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 } monitor_log("??? 0x62="); break; #endif /* __UNUSED__ */ - case 0xff: /* Development Data */ + case 0xff: /* Development Data */ /*@ +ignoresigns @*/ - while (len > 0 && buf[len-1] == '\n') + while (len > 0 && buf[len - 1] == '\n') len--; - while (len > 0 && buf[len-1] == ' ') + 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) { + if (strncmp((char *)(buf + 1), verbpat[i], strlen(verbpat[i])) == + 0) { j = 0; break; } if (j != 0) - monitor_log("%s\n",buf+1); + monitor_log("%s\n", buf + 1); monitor_log("DD 0xff="); break; @@ -636,6 +661,7 @@ static void sirf_update(void) } /*@ +nullpass -nullderef @*/ } + /*@ +globstate */ #ifdef ALLOW_CONTROLSEND @@ -644,8 +670,7 @@ static int sirf_command(char line[]) unsigned char buf[BUFSIZ]; int v; - switch (line[0]) - { + switch (line[0]) { case 'A': /* toggle 50bps subframe data */ (void)memset(buf, '\0', sizeof(buf)); putbyte(buf, 0, 0x80); @@ -655,17 +680,17 @@ static int sirf_command(char line[]) return COMMAND_MATCH; case 'M': /* static navigation */ - putbyte(buf, 0,0x8f); /* id */ - putbyte(buf, 1, atoi(line+1)); + putbyte(buf, 0, 0x8f); /* id */ + putbyte(buf, 1, atoi(line + 1)); (void)monitor_control_send(buf, 2); return COMMAND_MATCH; case 'D': /* MID 4 rate change (undocumented) */ - v = atoi(line+1); + v = atoi(line + 1); if (v > 30) return COMMAND_MATCH; - putbyte(buf, 0,0xa6); - putbyte(buf, 1,0); + putbyte(buf, 0, 0xa6); + putbyte(buf, 1, 0); putbyte(buf, 2, 4); /* satellite picture */ putbyte(buf, 3, v); putbyte(buf, 4, 0); @@ -705,7 +730,7 @@ const struct monitor_object_t sirf_mmt = { .command = NULL, #endif /* ALLOW_CONTROLSEND */ .wrap = sirf_wrap, - .min_y = 23, .min_x = 80, + .min_y = 23,.min_x = 80, .driver = &sirf_binary, }; #endif /* defined(SIRF_ENABLE) && defined(BINARY_ENABLE) */ diff --git a/monitor_superstar2.c b/monitor_superstar2.c index 725e271d..340f59f8 100644 --- a/monitor_superstar2.c +++ b/monitor_superstar2.c @@ -33,79 +33,78 @@ static WINDOW *satwin; static bool superstar2_initialize(void) { - int i; - - /*@ -onlytrans @*/ - /* "heavily inspired" by monitor_nmea.c */ - if ((satwin = derwin(devicewin, 15, 27, 7, 0)) == NULL) - return false; - (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(satwin, true); - (void)wattrset(satwin, A_BOLD); - (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Fl U"); - for (i = 0; i < 12; i++) - (void)mvwprintw(satwin, (int)(i+2), 1, "%2d",i); - (void)mvwprintw(satwin, 14, 1, " Satellite Data & Status "); - (void)wattrset(satwin, A_NORMAL); - /*@ +onlytrans @*/ - - return true; + int i; + + /*@ -onlytrans @*/ + /* "heavily inspired" by monitor_nmea.c */ + if ((satwin = derwin(devicewin, 15, 27, 7, 0)) == NULL) + return false; + (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true); + (void)wattrset(satwin, A_BOLD); + (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Fl U"); + for (i = 0; i < 12; i++) + (void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i); + (void)mvwprintw(satwin, 14, 1, " Satellite Data & Status "); + (void)wattrset(satwin, A_NORMAL); + /*@ +onlytrans @*/ + + return true; } static void display_superstar2_svinfo(unsigned char *buf, size_t data_len) { - int i; - - if (data_len != 67) - return; - - for (i = 0; i < 12; i++) { - /* get info for one channel/satellite */ - int off = i*5 + 5; - unsigned char fl, porn, ss; - char el; - unsigned short az; - - /*@ +charint */ - if ((porn = (unsigned char)getub(buf, off) & 0x1f) == 0) - porn = ((unsigned char)getub(buf, off+3) >> 1) + 87; - /*@ -charint */ - - ss = (unsigned char)getub(buf, off+4); - el = getsb(buf, off+1); - az = (unsigned short)(getub(buf, off+2) + - ((getub(buf, off+3) & 0x1) << 1)); - fl = (unsigned char)getub(buf, off) & 0xe0; - (void)wmove(satwin, i+2, 4); - /*@ +charint */ - (void)wprintw(satwin, "%3u %3d %2d %02d %02x %c", - porn, az, el, ss, fl, - ((fl & 0x60) == 0x60)? 'Y' : ' '); - /*@ -charint */ - } - (void)wnoutrefresh(satwin); + int i; + + if (data_len != 67) return; + + for (i = 0; i < 12; i++) { + /* get info for one channel/satellite */ + int off = i * 5 + 5; + unsigned char fl, porn, ss; + char el; + unsigned short az; + + /*@ +charint */ + if ((porn = (unsigned char)getub(buf, off) & 0x1f) == 0) + porn = ((unsigned char)getub(buf, off + 3) >> 1) + 87; + /*@ -charint */ + + ss = (unsigned char)getub(buf, off + 4); + el = getsb(buf, off + 1); + az = (unsigned short)(getub(buf, off + 2) + + ((getub(buf, off + 3) & 0x1) << 1)); + fl = (unsigned char)getub(buf, off) & 0xe0; + (void)wmove(satwin, i + 2, 4); + /*@ +charint */ + (void)wprintw(satwin, "%3u %3d %2d %02d %02x %c", + porn, az, el, ss, fl, + ((fl & 0x60) == 0x60) ? 'Y' : ' '); + /*@ -charint */ + } + (void)wnoutrefresh(satwin); + return; } static void superstar2_update(void) { - unsigned char *buf; - size_t len; - unsigned char type; - - buf = session.packet.outbuffer; - len = session.packet.outbuflen; - type = buf[SUPERSTAR2_TYPE_OFFSET]; - switch (type) { - case SUPERSTAR2_SVINFO: - display_superstar2_svinfo(buf, len-3); - break; - default: - break; - } + unsigned char *buf; + size_t len; + unsigned char type; + + buf = session.packet.outbuffer; + len = session.packet.outbuflen; + type = buf[SUPERSTAR2_TYPE_OFFSET]; + switch (type) { + case SUPERSTAR2_SVINFO: + display_superstar2_svinfo(buf, len - 3); + break; + default: + break; + } } -static int superstar2_command(char line[] UNUSED) +static int superstar2_command(char line[]UNUSED) { return COMMAND_UNKNOWN; } @@ -119,7 +118,7 @@ const struct monitor_object_t superstar2_mmt = { .update = superstar2_update, .command = superstar2_command, .wrap = superstar2_wrap, - .min_y = 23, .min_x = 80, /* size of the device window */ + .min_y = 23,.min_x = 80, /* size of the device window */ .driver = &superstar2_binary, }; #endif diff --git a/monitor_tnt.c b/monitor_tnt.c index 7b1aa505..a7fe523a 100644 --- a/monitor_tnt.c +++ b/monitor_tnt.c @@ -36,20 +36,20 @@ static WINDOW *thtmwin; static bool tnt_initialize(void) { /*@ -onlytrans @*/ - thtmwin = derwin(devicewin, 6, 80, 0, 0); + thtmwin = derwin(devicewin, 6, 80, 0, 0); (void)wborder(thtmwin, 0, 0, 0, 0, 0, 0, 0, 0), - (void)syncok(thtmwin, true); + (void)syncok(thtmwin, true); (void)wattrset(thtmwin, A_BOLD); - (void)mvwaddstr(thtmwin, 0, 35, " PTNTHTM "); - (void)mvwaddstr(thtmwin, 1, 1, "Heading: "); - (void)mvwaddstr(thtmwin, 2, 1, "Pitch: "); - (void)mvwaddstr(thtmwin, 3, 1, "Roll: "); - (void)mvwaddstr(thtmwin, 4, 1, "Dip: "); + (void)mvwaddstr(thtmwin, 0, 35, " PTNTHTM "); + (void)mvwaddstr(thtmwin, 1, 1, "Heading: "); + (void)mvwaddstr(thtmwin, 2, 1, "Pitch: "); + (void)mvwaddstr(thtmwin, 3, 1, "Roll: "); + (void)mvwaddstr(thtmwin, 4, 1, "Dip: "); - (void)mvwaddstr(thtmwin, 1, 40, "Magnetometer Status: "); - (void)mvwaddstr(thtmwin, 2, 40, "Pitch Status: "); - (void)mvwaddstr(thtmwin, 3, 40, "Roll Status "); - (void)mvwaddstr(thtmwin, 4, 40, "Horizontal Field: "); + (void)mvwaddstr(thtmwin, 1, 40, "Magnetometer Status: "); + (void)mvwaddstr(thtmwin, 2, 40, "Pitch Status: "); + (void)mvwaddstr(thtmwin, 3, 40, "Roll Status "); + (void)mvwaddstr(thtmwin, 4, 40, "Horizontal Field: "); (void)wattrset(thtmwin, A_NORMAL); /*@ +onlytrans @*/ return true; @@ -63,15 +63,15 @@ static void tnt_update(void) */ (void)nmea_parse((char *)session.packet.outbuffer, &session); - (void)mvwaddstr(thtmwin, 1, 19, session.driver.nmea.field[1]); - (void)mvwaddstr(thtmwin, 2, 19, session.driver.nmea.field[3]); - (void)mvwaddstr(thtmwin, 3, 19, session.driver.nmea.field[5]); - (void)mvwaddstr(thtmwin, 4, 19, session.driver.nmea.field[7]); + (void)mvwaddstr(thtmwin, 1, 19, session.driver.nmea.field[1]); + (void)mvwaddstr(thtmwin, 2, 19, session.driver.nmea.field[3]); + (void)mvwaddstr(thtmwin, 3, 19, session.driver.nmea.field[5]); + (void)mvwaddstr(thtmwin, 4, 19, session.driver.nmea.field[7]); - (void)mvwaddstr(thtmwin, 1, 61, session.driver.nmea.field[2]); - (void)mvwaddstr(thtmwin, 2, 61, session.driver.nmea.field[4]); - (void)mvwaddstr(thtmwin, 3, 61, session.driver.nmea.field[6]); - (void)mvwaddstr(thtmwin, 4, 61, session.driver.nmea.field[8]); + (void)mvwaddstr(thtmwin, 1, 61, session.driver.nmea.field[2]); + (void)mvwaddstr(thtmwin, 2, 61, session.driver.nmea.field[4]); + (void)mvwaddstr(thtmwin, 3, 61, session.driver.nmea.field[6]); + (void)mvwaddstr(thtmwin, 4, 61, session.driver.nmea.field[8]); } static int tnt_command(char line[]) @@ -116,7 +116,7 @@ const struct monitor_object_t tnt_mmt = { .update = tnt_update, .command = tnt_command, .wrap = tnt_wrap, - .min_y = 6, .min_x = 80, /* size of the device window */ + .min_y = 6,.min_x = 80, /* size of the device window */ .driver = &trueNorth, }; #endif /* TNT_ENABLE */ diff --git a/monitor_ubx.c b/monitor_ubx.c index 88fa7430..1d461228 100644 --- a/monitor_ubx.c +++ b/monitor_ubx.c @@ -34,226 +34,224 @@ static WINDOW *satwin, *navsolwin, *dopwin; #define display (void)mvwprintw static bool ubx_initialize(void) { - int i; - - /*@ -onlytrans @*/ - /* "heavily inspired" by monitor_nmea.c */ - if ((satwin = derwin(devicewin, 19, 28, 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); - (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Flag U"); - for (i = 0; i < 16; i++) - (void)mvwprintw(satwin, (int)(i+2), 1, "%2d",i); - (void)mvwprintw(satwin, 18, 7, " NAV_SVINFO "); - (void)wattrset(satwin, A_NORMAL); - /*@ -onlytrans @*/ - - /* "heavily inspired" by monitor_nmea.c */ - if ((navsolwin = derwin(devicewin, 13, 51, 0, 28)) == NULL) - return false; - (void)wborder(navsolwin, 0, 0, 0, 0, 0, 0, 0, 0), + int i; + + /*@ -onlytrans @*/ + /* "heavily inspired" by monitor_nmea.c */ + if ((satwin = derwin(devicewin, 19, 28, 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); + (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Flag U"); + for (i = 0; i < 16; i++) + (void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i); + (void)mvwprintw(satwin, 18, 7, " NAV_SVINFO "); + (void)wattrset(satwin, A_NORMAL); + /*@ -onlytrans @*/ + + /* "heavily inspired" by monitor_nmea.c */ + if ((navsolwin = derwin(devicewin, 13, 51, 0, 28)) == NULL) + return false; + (void)wborder(navsolwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)wattrset(navsolwin, A_BOLD); - (void)wmove(navsolwin, 1,1); - (void)wprintw(navsolwin, "ECEF Pos:"); - (void)wmove(navsolwin, 2,1); - (void)wprintw(navsolwin, "ECEF Vel:"); - - (void)wmove(navsolwin, 4,1); - (void)wprintw(navsolwin, "LTP Pos:"); - (void)wmove(navsolwin, 5,1); - (void)wprintw(navsolwin, "LTP Vel:"); - - (void)wmove(navsolwin, 7,1); - (void)wprintw(navsolwin, "Time UTC:"); - (void)wmove(navsolwin, 8,1); - (void)wprintw(navsolwin, "Time GPS: Day:"); - - (void)wmove(navsolwin, 10,1); - (void)wprintw(navsolwin, "Est Pos Err m Est Vel Err m/s"); - (void)wmove(navsolwin, 11,1); - (void)wprintw(navsolwin, "PRNs: ## PDOP: xx.x Fix 0x.. Flags 0x.."); - - display(navsolwin, 12, 20, " NAV_SOL "); - (void)wattrset(navsolwin, A_NORMAL); - - if ((dopwin = derwin(devicewin, 3, 51, 13, 28)) == NULL) - return false; - (void)wborder(dopwin, 0, 0, 0, 0, 0, 0, 0, 0), + (void)wmove(navsolwin, 1, 1); + (void)wprintw(navsolwin, "ECEF Pos:"); + (void)wmove(navsolwin, 2, 1); + (void)wprintw(navsolwin, "ECEF Vel:"); + + (void)wmove(navsolwin, 4, 1); + (void)wprintw(navsolwin, "LTP Pos:"); + (void)wmove(navsolwin, 5, 1); + (void)wprintw(navsolwin, "LTP Vel:"); + + (void)wmove(navsolwin, 7, 1); + (void)wprintw(navsolwin, "Time UTC:"); + (void)wmove(navsolwin, 8, 1); + (void)wprintw(navsolwin, "Time GPS: Day:"); + + (void)wmove(navsolwin, 10, 1); + (void)wprintw(navsolwin, "Est Pos Err m Est Vel Err m/s"); + (void)wmove(navsolwin, 11, 1); + (void)wprintw(navsolwin, "PRNs: ## PDOP: xx.x Fix 0x.. Flags 0x.."); + + display(navsolwin, 12, 20, " NAV_SOL "); + (void)wattrset(navsolwin, A_NORMAL); + + if ((dopwin = derwin(devicewin, 3, 51, 13, 28)) == NULL) + return false; + (void)wborder(dopwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)wattrset(dopwin, A_BOLD); - (void)wmove(dopwin, 1,1); - (void)wprintw(dopwin, "DOP [H] [V] [P] [T] [G]"); - display(dopwin, 2, 20, " NAV_DOP "); - (void)wattrset(dopwin, A_NORMAL); + (void)wmove(dopwin, 1, 1); + (void)wprintw(dopwin, "DOP [H] [V] [P] [T] [G]"); + display(dopwin, 2, 20, " NAV_DOP "); + (void)wattrset(dopwin, A_NORMAL); - return true; + return true; } static void display_nav_svinfo(unsigned char *buf, size_t data_len) { - int i, nchan; - - if (data_len < 152 ) - return; - - nchan = (int)getub(buf, 4); - if (nchan > 16) - nchan = 16; - - for (i = 0; i < nchan; i++) { - int off = 8 + 12 * i; - unsigned char ss, prn; - char el; - short az; - unsigned short fl; - - prn = (unsigned char)getub(buf, off+1); - fl = (unsigned short)getleuw(buf, off+2); - ss = (unsigned char)getub(buf, off+4); - el = getsb(buf, off+5); - az = getlesw(buf, off+6); - (void)wmove(satwin, (int)(i+2), 4); - (void)wprintw(satwin, "%3d %3d %3d %2d %04x %c", - prn, az, el, ss, fl, - (fl & UBX_SAT_USED)? 'Y' : ' '); - } - (void)wnoutrefresh(satwin); + int i, nchan; + + if (data_len < 152) return; + + nchan = (int)getub(buf, 4); + if (nchan > 16) + nchan = 16; + + for (i = 0; i < nchan; i++) { + int off = 8 + 12 * i; + unsigned char ss, prn; + char el; + short az; + unsigned short fl; + + prn = (unsigned char)getub(buf, off + 1); + fl = (unsigned short)getleuw(buf, off + 2); + ss = (unsigned char)getub(buf, off + 4); + el = getsb(buf, off + 5); + az = getlesw(buf, off + 6); + (void)wmove(satwin, (int)(i + 2), 4); + (void)wprintw(satwin, "%3d %3d %3d %2d %04x %c", + prn, az, el, ss, fl, (fl & UBX_SAT_USED) ? 'Y' : ' '); + } + (void)wnoutrefresh(satwin); + return; } /*@ -mustfreeonly -compdestroy @*/ static void display_nav_sol(unsigned char *buf, size_t data_len) { - unsigned short gw = 0; - unsigned int tow = 0, flags; - double epx, epy, epz, evx, evy, evz; - unsigned char navmode; - double t; - time_t tt; - struct gps_data_t g; - double separation; - - if (data_len != 52) - return; - - navmode = (unsigned char)getub(buf, 10); - flags = (unsigned int)getub(buf, 11); - - if ((flags & (UBX_SOL_VALID_WEEK |UBX_SOL_VALID_TIME)) != 0) { - tow = (unsigned int)getleul(buf, 0); - gw = (unsigned short)getlesw(buf, 8); - t = gpstime_to_unix((int)gw, tow/1000.0); - tt = (time_t)trunc(t); - } - - epx = (double)(getlesl(buf, 12)/100.0); - epy = (double)(getlesl(buf, 16)/100.0); - epz = (double)(getlesl(buf, 20)/100.0); - evx = (double)(getlesl(buf, 28)/100.0); - evy = (double)(getlesl(buf, 32)/100.0); - evz = (double)(getlesl(buf, 36)/100.0); - ecef_to_wgs84fix(&g.fix, &separation, - epx, epy, epz, evx, evy, evz); - g.fix.epx = g.fix.epy = (double)(getlesl(buf, 24)/100.0); - g.fix.eps = (double)(getlesl(buf, 40)/100.0); - g.dop.pdop = (double)(getleuw(buf, 44)/100.0); - g.satellites_used = (int)getub(buf, 47); - - (void)wmove(navsolwin, 1, 11); - (void)wprintw(navsolwin, "%+10.2fm %+10.2fm %+10.2fm", epx, epy, epz); - (void)wmove(navsolwin, 2, 11); - (void)wprintw(navsolwin, "%+9.2fm/s %+9.2fm/s %+9.2fm/s", evx, evy, evz); - - (void)wmove(navsolwin, 4, 11); - (void)wprintw(navsolwin, "%12.9f %13.9f %8.2fm", - g.fix.latitude, g.fix.longitude, g.fix.altitude); - (void)mvwaddch(navsolwin, 4, 23, ACS_DEGREE); - (void)mvwaddch(navsolwin, 4, 39, ACS_DEGREE); - (void)wmove(navsolwin, 5, 11); - (void)wprintw(navsolwin, "%6.2fm/s %5.1fo %6.2fm/s", - g.fix.speed, g.fix.track, g.fix.climb); - (void)mvwaddch(navsolwin, 5, 26, ACS_DEGREE); - - (void)wmove(navsolwin, 7, 11); - /*@ -compdef @*/ - (void)wprintw(navsolwin, "%s", ctime(&tt)); - /*@ +compdef @*/ - (void)wmove(navsolwin, 8, 11); - if ((flags & (UBX_SOL_VALID_WEEK |UBX_SOL_VALID_TIME)) != 0) { - (void)wprintw(navsolwin, "%d+%10.3lf", gw, (double)(tow/1000.0)); - (void)wmove(navsolwin, 8, 36); - (void)wprintw(navsolwin, "%d", (tow/86400000) ); - } - - /* relies on the fact that expx and epy are aet to same value */ - (void)wmove(navsolwin, 10, 12); - (void)wprintw(navsolwin, "%7.2f", g.fix.epx); - (void)wmove(navsolwin, 10, 33); - (void)wprintw(navsolwin, "%6.2f", g.fix.epv); - (void)wmove(navsolwin, 11, 7); - (void)wprintw(navsolwin, "%2d", g.satellites_used); - (void)wmove(navsolwin, 11, 15); - (void)wprintw(navsolwin, "%5.1f", g.dop.pdop); - (void)wmove(navsolwin, 11, 25); - (void)wprintw(navsolwin, "0x%02x", navmode); - (void)wmove(navsolwin, 11, 36); - (void)wprintw(navsolwin, "0x%02x", flags); - (void)wnoutrefresh(navsolwin); + unsigned short gw = 0; + unsigned int tow = 0, flags; + double epx, epy, epz, evx, evy, evz; + unsigned char navmode; + double t; + time_t tt; + struct gps_data_t g; + double separation; + + if (data_len != 52) + return; + + navmode = (unsigned char)getub(buf, 10); + flags = (unsigned int)getub(buf, 11); + + if ((flags & (UBX_SOL_VALID_WEEK | UBX_SOL_VALID_TIME)) != 0) { + tow = (unsigned int)getleul(buf, 0); + gw = (unsigned short)getlesw(buf, 8); + t = gpstime_to_unix((int)gw, tow / 1000.0); + tt = (time_t) trunc(t); + } + + epx = (double)(getlesl(buf, 12) / 100.0); + epy = (double)(getlesl(buf, 16) / 100.0); + epz = (double)(getlesl(buf, 20) / 100.0); + evx = (double)(getlesl(buf, 28) / 100.0); + evy = (double)(getlesl(buf, 32) / 100.0); + evz = (double)(getlesl(buf, 36) / 100.0); + ecef_to_wgs84fix(&g.fix, &separation, epx, epy, epz, evx, evy, evz); + g.fix.epx = g.fix.epy = (double)(getlesl(buf, 24) / 100.0); + g.fix.eps = (double)(getlesl(buf, 40) / 100.0); + g.dop.pdop = (double)(getleuw(buf, 44) / 100.0); + g.satellites_used = (int)getub(buf, 47); + + (void)wmove(navsolwin, 1, 11); + (void)wprintw(navsolwin, "%+10.2fm %+10.2fm %+10.2fm", epx, epy, epz); + (void)wmove(navsolwin, 2, 11); + (void)wprintw(navsolwin, "%+9.2fm/s %+9.2fm/s %+9.2fm/s", evx, evy, evz); + + (void)wmove(navsolwin, 4, 11); + (void)wprintw(navsolwin, "%12.9f %13.9f %8.2fm", + g.fix.latitude, g.fix.longitude, g.fix.altitude); + (void)mvwaddch(navsolwin, 4, 23, ACS_DEGREE); + (void)mvwaddch(navsolwin, 4, 39, ACS_DEGREE); + (void)wmove(navsolwin, 5, 11); + (void)wprintw(navsolwin, "%6.2fm/s %5.1fo %6.2fm/s", + g.fix.speed, g.fix.track, g.fix.climb); + (void)mvwaddch(navsolwin, 5, 26, ACS_DEGREE); + + (void)wmove(navsolwin, 7, 11); + /*@ -compdef @*/ + (void)wprintw(navsolwin, "%s", ctime(&tt)); + /*@ +compdef @*/ + (void)wmove(navsolwin, 8, 11); + if ((flags & (UBX_SOL_VALID_WEEK | UBX_SOL_VALID_TIME)) != 0) { + (void)wprintw(navsolwin, "%d+%10.3lf", gw, (double)(tow / 1000.0)); + (void)wmove(navsolwin, 8, 36); + (void)wprintw(navsolwin, "%d", (tow / 86400000)); + } + + /* relies on the fact that expx and epy are aet to same value */ + (void)wmove(navsolwin, 10, 12); + (void)wprintw(navsolwin, "%7.2f", g.fix.epx); + (void)wmove(navsolwin, 10, 33); + (void)wprintw(navsolwin, "%6.2f", g.fix.epv); + (void)wmove(navsolwin, 11, 7); + (void)wprintw(navsolwin, "%2d", g.satellites_used); + (void)wmove(navsolwin, 11, 15); + (void)wprintw(navsolwin, "%5.1f", g.dop.pdop); + (void)wmove(navsolwin, 11, 25); + (void)wprintw(navsolwin, "0x%02x", navmode); + (void)wmove(navsolwin, 11, 36); + (void)wprintw(navsolwin, "0x%02x", flags); + (void)wnoutrefresh(navsolwin); } + /*@ +mustfreeonly +compdestroy @*/ static void display_nav_dop(unsigned char *buf, size_t data_len) { - if (data_len != 18) - return; - (void)wmove(dopwin, 1,9); - (void)wprintw(dopwin, "%4.1f", getleuw(buf, 12)/100.0); - (void)wmove(dopwin, 1,18); - (void)wprintw(dopwin, "%4.1f", getleuw(buf, 10)/100.0); - (void)wmove(dopwin, 1,27); - (void)wprintw(dopwin, "%4.1f", getleuw(buf, 6)/100.0); - (void)wmove(dopwin, 1,36); - (void)wprintw(dopwin, "%4.1f", getleuw(buf, 8)/100.0); - (void)wmove(dopwin, 1,45); - (void)wprintw(dopwin, "%4.1f", getleuw(buf, 4)/100.0); - (void)wnoutrefresh(dopwin); + if (data_len != 18) + return; + (void)wmove(dopwin, 1, 9); + (void)wprintw(dopwin, "%4.1f", getleuw(buf, 12) / 100.0); + (void)wmove(dopwin, 1, 18); + (void)wprintw(dopwin, "%4.1f", getleuw(buf, 10) / 100.0); + (void)wmove(dopwin, 1, 27); + (void)wprintw(dopwin, "%4.1f", getleuw(buf, 6) / 100.0); + (void)wmove(dopwin, 1, 36); + (void)wprintw(dopwin, "%4.1f", getleuw(buf, 8) / 100.0); + (void)wmove(dopwin, 1, 45); + (void)wprintw(dopwin, "%4.1f", getleuw(buf, 4) / 100.0); + (void)wnoutrefresh(dopwin); } static void ubx_update(void) { - unsigned char *buf; - size_t data_len; - unsigned short msgid; - - buf = session.packet.outbuffer; - msgid = (unsigned short)((buf[2] << 8) | buf[3]); - data_len = (size_t)getlesw(buf, 4); - switch (msgid) { - case UBX_NAV_SVINFO: - display_nav_svinfo(&buf[6], data_len); - break; - case UBX_NAV_DOP: - display_nav_dop(&buf[6], data_len); - break; - case UBX_NAV_SOL: - display_nav_sol(&buf[6], data_len); - break; - default: - break; - } + unsigned char *buf; + size_t data_len; + unsigned short msgid; + + buf = session.packet.outbuffer; + msgid = (unsigned short)((buf[2] << 8) | buf[3]); + data_len = (size_t) getlesw(buf, 4); + switch (msgid) { + case UBX_NAV_SVINFO: + display_nav_svinfo(&buf[6], data_len); + break; + case UBX_NAV_DOP: + display_nav_dop(&buf[6], data_len); + break; + case UBX_NAV_SOL: + display_nav_sol(&buf[6], data_len); + break; + default: + break; + } } -static int ubx_command(char line[] UNUSED) +static int ubx_command(char line[]UNUSED) { - return COMMAND_UNKNOWN; + return COMMAND_UNKNOWN; } static void ubx_wrap(void) { - (void)delwin(satwin); - return; + (void)delwin(satwin); + return; } const struct monitor_object_t ubx_mmt = { @@ -261,7 +259,7 @@ const struct monitor_object_t ubx_mmt = { .update = ubx_update, .command = ubx_command, .wrap = ubx_wrap, - .min_y = 23, .min_x = 80, /* size of the device window */ + .min_y = 23,.min_x = 80, /* size of the device window */ .driver = &ubx_binary, }; #endif |