static void monitor_satlist(WINDOW *win, int y, int x) /* display as much as we can of a satlist in a specified window */ { int ymax, xmax; char scr[128]; int i; assert(win != NULL); (void)wmove(win, y, x); (void)wclrtoeol(win); scr[0] = '\0'; for (i = 0; i < MAXCHANNELS; i++) { if (session.gpsdata.skyview[i].used) str_appendf(scr, sizeof(scr), "%d ", session.gpsdata.skyview[i].PRN); } getmaxyx(win, ymax, xmax); assert(ymax != 0); /* suppress compiler warning */ (void)mvwaddnstr(win, y, x, scr, xmax - 2 - x); if (strlen(scr) >= (size_t) (xmax - 2)) { (void)mvwaddch(win, y, xmax - 2 - x, (chtype) '.'); (void)mvwaddch(win, y, xmax - 3 - x, (chtype) '.'); (void)mvwaddch(win, y, xmax - 4 - x, (chtype) '.'); } monitor_fixframe(win); }
static void nmea_update(void) { char **fields; assert(cookedwin != NULL); assert(nmeawin != NULL); assert(gpgsawin != NULL); assert(gpggawin != NULL); assert(gprmcwin != NULL); assert(gpgstwin != NULL); /* can be NULL if packet was overlong */ fields = session.nmea.field; if (session.lexer.outbuffer[0] == (unsigned char)'$' && fields != NULL && fields[0] != NULL) { int ymax, xmax; timestamp_t now; getmaxyx(nmeawin, ymax, xmax); assert(ymax > 0); if (strstr(sentences, fields[0]) == NULL) { char *s_end = sentences + strlen(sentences); if ((int)(strlen(sentences) + strlen(fields[0])) < xmax - 2) { *s_end++ = ' '; (void)strlcpy(s_end, fields[0], NMEA_MAX); } else { *--s_end = '.'; *--s_end = '.'; *--s_end = '.'; } (void)mvwaddstr(nmeawin, SENTENCELINE, 1, sentences); } /* * If the interval between this and last update is * the longest we've seen yet, boldify the corresponding * tag. */ now = timestamp(); if (now > last_tick && (now - last_tick) > tick_interval) { char *findme = strstr(sentences, fields[0]); tick_interval = now - last_tick; if (findme != NULL) { (void)mvwchgat(nmeawin, SENTENCELINE, 1, xmax - 13, A_NORMAL, 0, NULL); (void)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) { int i; 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)wprintw(satwin, " %3d %3d%3d %3.0f", session.gpsdata.skyview[i].PRN, session.gpsdata.skyview[i].azimuth, session.gpsdata.skyview[i].elevation, session.gpsdata.skyview[i].ss); } /* add overflow mark to the display */ if (nsats <= MAXSATS) (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_HLINE); else (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_DARROW); } 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]); (void)mvwprintw(gprmcwin, 3, 12, "%12s %s", fields[5], fields[6]); (void)mvwaddstr(gprmcwin, 4, 12, fields[7]); (void)mvwaddstr(gprmcwin, 5, 12, fields[8]); /* 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]); cooked_pvt(); /* cooked version of TPV */ } if (strcmp(fields[0], "GPGSA") == 0 || strcmp(fields[0], "GNGSA") == 0 || strcmp(fields[0], "GLGSA") == 0) { (void)mvwprintw(gpgsawin, MODE_LINE, 7, "%1s%s", fields[1], fields[2]); monitor_satlist(gpgsawin, SATS_LINE, SATS_COL+6); (void)mvwprintw(gpgsawin, DOP_LINE, 8, "%-5s", fields[16]); (void)mvwprintw(gpgsawin, DOP_LINE, 16, "%-5s", fields[17]); (void)mvwprintw(gpgsawin, DOP_LINE, 24, "%-5s", fields[15]); monitor_fixframe(gpgsawin); } #ifdef NTP_ENABLE toff_update(gpgsawin, TOFF_LINE, 7); #endif /* NTP_ENABLE */ 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]); (void)mvwprintw(gpggawin, 4, 12, "%-17s", fields[9]); (void)mvwprintw(gpggawin, 5, 12, "%1.1s", fields[6]); (void)mvwprintw(gpggawin, 5, 22, "%2.2s", fields[7]); (void)mvwprintw(gpggawin, 6, 12, "%-5.5s", fields[8]); (void)mvwprintw(gpggawin, 7, 12, "%-5.5s", fields[11]); } if (strcmp(fields[0], "GPGST") == 0) { (void)mvwprintw(gpgstwin, 1, 6, "%-10s", fields[1]); (void)mvwprintw(gpgstwin, 1, 21, "%-8s", fields[2]); (void)mvwprintw(gpgstwin, 2, 6, "%-10s", fields[3]); (void)mvwprintw(gpgstwin, 2, 21, "%-8s", fields[4]); (void)mvwprintw(gpgstwin, 3, 6, "%-10s", fields[5]); (void)mvwprintw(gpgstwin, 3, 21, "%-8s", fields[6]); (void)mvwprintw(gpgstwin, 4, 6, "%-10s", fields[7]); (void)mvwprintw(gpgstwin, 4, 21, "%-8s", fields[8]); } } #ifdef PPS_ENABLE pps_update(gpgsawin, PPS_LINE, 6); #endif /* PPS_ENABLE */ }
/*@ -globstate -nullpass (splint is confused) */ static void nmea_update(void) { char **fields; #ifdef PPS_ENABLE struct timedrift_t drift; #endif /* PPS_ENABLE */ assert(cookedwin != NULL); assert(nmeawin != NULL); assert(gpgsawin != NULL); assert(gpggawin != NULL); assert(gprmcwin != NULL); assert(gpgstwin != NULL); /* can be NULL if packet was overlong */ fields = session.driver.nmea.field; if (session.packet.outbuffer[0] == (unsigned char)'$' && fields != NULL && fields[0] != NULL) { int ymax, xmax; timestamp_t now; getmaxyx(nmeawin, ymax, xmax); assert(ymax > 0); if (strstr(sentences, fields[0]) == NULL) { char *s_end = sentences + strlen(sentences); if ((int)(strlen(sentences) + strlen(fields[0])) < xmax - 2) { *s_end++ = ' '; (void)strlcpy(s_end, fields[0], NMEA_MAX); } else { *--s_end = '.'; *--s_end = '.'; *--s_end = '.'; } (void)mvwaddstr(nmeawin, SENTENCELINE, 1, sentences); } /* * If the interval between this and last update is * the longest we've seen yet, boldify the corresponding * tag. */ now = timestamp(); if (now > last_tick && (now - last_tick) > tick_interval) { char *findme = strstr(sentences, fields[0]); tick_interval = now - last_tick; if (findme != NULL) { (void)mvwchgat(nmeawin, SENTENCELINE, 1, xmax - 13, A_NORMAL, 0, NULL); (void)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) { int i; 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)wprintw(satwin, " %3d %3d%3d %3.0f", session.gpsdata.PRN[i], session.gpsdata.azimuth[i], session.gpsdata.elevation[i], session.gpsdata.ss[i]); } /* add overflow mark to the display */ if (nsats <= MAXSATS) (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_HLINE); else (void)mvwaddch(satwin, MAXSATS + 2, 18, ACS_DARROW); } 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]); (void)mvwprintw(gprmcwin, 3, 12, "%12s %s", fields[5], fields[6]); (void)mvwaddstr(gprmcwin, 4, 12, fields[7]); (void)mvwaddstr(gprmcwin, 5, 12, fields[8]); /* 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]); cooked_pvt(); /* cooked version of PVT */ } 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)wmove(gpgsawin, 2, 7); (void)wclrtoeol(gpgsawin); scr[0] = '\0'; for (i = 0; i < session.gpsdata.satellites_used; i++) { (void)snprintf(scr + strlen(scr), sizeof(scr) - strlen(scr), "%d ", session.gpsdata.used[i]); } getmaxyx(gpgsawin, ymax, xmax); (void)mvwaddnstr(gpgsawin, 2, 7, scr, xmax - 2 - 7); if (strlen(scr) >= (size_t) (xmax - 2)) { (void)mvwaddch(gpgsawin, 2, xmax - 2 - 7, (chtype) '.'); (void)mvwaddch(gpgsawin, 2, xmax - 3 - 7, (chtype) '.'); (void)mvwaddch(gpgsawin, 2, xmax - 4 - 7, (chtype) '.'); } monitor_fixframe(gpgsawin); (void)mvwprintw(gpgsawin, 3, 8, "%-5s", fields[16]); (void)mvwprintw(gpgsawin, 3, 16, "%-5s", fields[17]); (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) { (void)mvwprintw(gpggawin, 1, 12, "%-17s", fields[1]); (void)mvwprintw(gpggawin, 2, 12, "%-17s", fields[2]); (void)mvwprintw(gpggawin, 3, 12, "%-17s", fields[4]); (void)mvwprintw(gpggawin, 4, 12, "%-17s", fields[9]); (void)mvwprintw(gpggawin, 5, 12, "%1.1s", fields[6]); (void)mvwprintw(gpggawin, 5, 22, "%2.2s", fields[7]); (void)mvwprintw(gpggawin, 6, 12, "%-5.5s", fields[8]); (void)mvwprintw(gpggawin, 7, 12, "%-5.5s", fields[11]); } if (strcmp(fields[0], "GPGST") == 0) { (void)mvwprintw(gpgstwin, 1, 6, "%-10s", fields[1]); (void)mvwprintw(gpgstwin, 1, 21, "%-8s", fields[2]); (void)mvwprintw(gpgstwin, 2, 6, "%-10s", fields[3]); (void)mvwprintw(gpgstwin, 2, 21, "%-8s", fields[4]); (void)mvwprintw(gpgstwin, 3, 6, "%-10s", fields[5]); (void)mvwprintw(gpgstwin, 3, 21, "%-8s", fields[6]); (void)mvwprintw(gpgstwin, 4, 6, "%-10s", fields[7]); (void)mvwprintw(gpgstwin, 4, 21, "%-8s", fields[8]); } } #ifdef PPS_ENABLE /*@-compdef@*/ /*@-type@*/ /* splint is confused about struct timespec */ if (pps_thread_lastpps(&session, &drift) > 0) { double timedelta = timespec_diff_ns(drift.real, drift.clock) * 1e-9; (void)mvwprintw(gpgsawin, 4, 13, "%.9f", timedelta); (void)wnoutrefresh(gpgsawin); } /*@+type@*/ /*@+compdef@*/ #endif /* PPS_ENABLE */ }