diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2009-03-03 20:17:33 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2009-03-03 20:17:33 +0000 |
commit | 556141e0667914625a5910291ab48c4621a58dee (patch) | |
tree | dce84db5675c9586aa855cbf8345bab8426b281e /monitor_superstar2.c | |
parent | 8b980caecabb5f25b6204419368b6ebc9dd294fe (diff) | |
download | gpsd-556141e0667914625a5910291ab48c4621a58dee.tar.gz |
Parse the satellite status
Diffstat (limited to 'monitor_superstar2.c')
-rw-r--r-- | monitor_superstar2.c | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/monitor_superstar2.c b/monitor_superstar2.c index b76d2ffd..baa062b0 100644 --- a/monitor_superstar2.c +++ b/monitor_superstar2.c @@ -23,18 +23,80 @@ #include "gpsmon.h" #ifdef SUPERSTAR2_ENABLE +#include "driver_superstar2.h" extern const struct gps_type_t superstar2_binary; +static WINDOW *satwin; static bool superstar2_initialize(void) { - return true; + int i; + + /* "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 SV 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); + + return true; +} + +void +display_superstar2_svinfo(unsigned char *buf, size_t data_len) +{ + unsigned char 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; + + if ((porn = getub(buf, off) & 0x1f) == 0) + porn = (getub(buf, off+3) >> 1) + 87; + + ss = getub(buf, off+4); + el = getsb(buf, off+1); + az = (unsigned short)getub(buf, off+2) + + ((unsigned short)(getub(buf, off+3) & 0x1) << 1); + fl = getub(buf, off) & 0xe0; + wmove(satwin, i+2, 4); + wprintw(satwin, "%3u %3d %2d %02d %02x %c", + porn, az, el, ss, fl, + ((fl & 0x60) == 0x60)? 'Y' : ' '); + } + 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; + } } -static int superstar2_command(char line[]) +static int superstar2_command(char line[] UNUSED) { return COMMAND_UNKNOWN; } @@ -48,7 +110,7 @@ const struct monitor_object_t superstar2_mmt = { .update = superstar2_update, .command = superstar2_command, .wrap = superstar2_wrap, - .min_y = 20, .min_x = 80, /* size of the device window */ + .min_y = 23, .min_x = 80, /* size of the device window */ .driver = &superstar2_binary, }; #endif |