2 * This file is Copyright (c) 2010 by the GPSD project
3 * BSD terms apply: see the file COPYING in the distribution root for details.
12 #endif /* S_SPLINT_S */
17 #include "gpsd_config.h"
23 #endif /* HAVE_NCURSES_H */
29 #ifdef SUPERSTAR2_ENABLE
30 #include "driver_superstar2.h"
31 extern const struct gps_type_t superstar2_binary;
32 static WINDOW *satwin;
34 static bool superstar2_initialize(void)
39 /* "heavily inspired" by monitor_nmea.c */
40 if ((satwin = derwin(devicewin, 15, 27, 7, 0)) == NULL)
42 (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true);
43 (void)wattrset(satwin, A_BOLD);
44 (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Fl U");
45 for (i = 0; i < 12; i++)
46 (void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i);
47 (void)mvwprintw(satwin, 14, 1, " Satellite Data & Status ");
48 (void)wattrset(satwin, A_NORMAL);
54 static void display_superstar2_svinfo(unsigned char *buf, size_t data_len)
61 for (i = 0; i < 12; i++) {
62 /* get info for one channel/satellite */
64 unsigned char fl, porn, ss;
69 if ((porn = (unsigned char)getub(buf, off) & 0x1f) == 0)
70 porn = ((unsigned char)getub(buf, off + 3) >> 1) + 87;
73 ss = (unsigned char)getub(buf, off + 4);
74 el = getsb(buf, off + 1);
75 az = (unsigned short)(getub(buf, off + 2) +
76 ((getub(buf, off + 3) & 0x1) << 1));
77 fl = (unsigned char)getub(buf, off) & 0xe0;
78 (void)wmove(satwin, i + 2, 4);
80 (void)wprintw(satwin, "%3u %3d %2d %02d %02x %c",
82 ((fl & 0x60) == 0x60) ? 'Y' : ' ');
85 (void)wnoutrefresh(satwin);
89 static void superstar2_update(void)
95 buf = session.packet.outbuffer;
96 len = session.packet.outbuflen;
97 type = buf[SUPERSTAR2_TYPE_OFFSET];
99 case SUPERSTAR2_SVINFO:
100 display_superstar2_svinfo(buf, len - 3);
107 static int superstar2_command(char line[]UNUSED)
109 return COMMAND_UNKNOWN;
112 static void superstar2_wrap(void)
116 const struct monitor_object_t superstar2_mmt = {
117 .initialize = superstar2_initialize,
118 .update = superstar2_update,
119 .command = superstar2_command,
120 .wrap = superstar2_wrap,
121 .min_y = 23,.min_x = 80, /* size of the device window */
122 .driver = &superstar2_binary,