Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

102 lines
2.4 KiB

  1. /*
  2. * This file is Copyright (c) 2010-2018 by the GPSD project
  3. * SPDX-License-Identifier: BSD-2-clause
  4. */
  5. #include "gpsd_config.h" /* must be before all includes */
  6. #include "gpsd.h"
  7. #include "bits.h"
  8. #include "gpsmon.h"
  9. #ifdef SUPERSTAR2_ENABLE
  10. #include "driver_superstar2.h"
  11. extern const struct gps_type_t driver_superstar2;
  12. static WINDOW *satwin;
  13. static bool superstar2_initialize(void)
  14. {
  15. int i;
  16. /* "heavily inspired" by monitor_nmea.c */
  17. if ((satwin = derwin(devicewin, 15, 27, 7, 0)) == NULL)
  18. return false;
  19. (void)wborder(satwin, 0, 0, 0, 0, 0, 0, 0, 0), (void)syncok(satwin, true);
  20. (void)wattrset(satwin, A_BOLD);
  21. (void)mvwprintw(satwin, 1, 1, "Ch PRN Az El S/N Fl U");
  22. for (i = 0; i < 12; i++)
  23. (void)mvwprintw(satwin, (int)(i + 2), 1, "%2d", i);
  24. (void)mvwprintw(satwin, 14, 1, " Satellite Data & Status ");
  25. (void)wattrset(satwin, A_NORMAL);
  26. return true;
  27. }
  28. static void display_superstar2_svinfo(unsigned char *buf, size_t data_len)
  29. {
  30. int i;
  31. if (data_len != 67)
  32. return;
  33. for (i = 0; i < 12; i++) {
  34. /* get info for one channel/satellite */
  35. int off = i * 5 + 5;
  36. unsigned char fl, porn, ss;
  37. char el;
  38. unsigned short az;
  39. if ((porn = (unsigned char)getub(buf, off) & 0x1f) == 0)
  40. porn = ((unsigned char)getub(buf, off + 3) >> 1) + 87;
  41. ss = (unsigned char)getub(buf, off + 4);
  42. el = (char)getsb(buf, off + 1);
  43. az = (unsigned short)(getub(buf, off + 2) +
  44. ((getub(buf, off + 3) & 0x1) << 1));
  45. fl = (unsigned char)getub(buf, off) & 0xe0;
  46. (void)wmove(satwin, i + 2, 4);
  47. (void)wprintw(satwin, "%3u %3d %2d %02d %02x %c",
  48. porn, az, el, ss, fl,
  49. ((fl & 0x60) == 0x60) ? 'Y' : ' ');
  50. }
  51. (void)wnoutrefresh(satwin);
  52. return;
  53. }
  54. static void superstar2_update(void)
  55. {
  56. unsigned char *buf;
  57. size_t len;
  58. unsigned char type;
  59. buf = session.lexer.outbuffer;
  60. len = session.lexer.outbuflen;
  61. type = buf[SUPERSTAR2_TYPE_OFFSET];
  62. switch (type) {
  63. case SUPERSTAR2_SVINFO:
  64. display_superstar2_svinfo(buf, len - 3);
  65. break;
  66. default:
  67. break;
  68. }
  69. }
  70. static int superstar2_command(char line[]UNUSED)
  71. {
  72. return COMMAND_UNKNOWN;
  73. }
  74. static void superstar2_wrap(void)
  75. {
  76. }
  77. const struct monitor_object_t superstar2_mmt = {
  78. .initialize = superstar2_initialize,
  79. .update = superstar2_update,
  80. .command = superstar2_command,
  81. .wrap = superstar2_wrap,
  82. .min_y = 23,.min_x = 80, /* size of the device window */
  83. .driver = &driver_superstar2,
  84. };
  85. #endif