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.

65 lines
2.2 KiB

  1. From a3dec2cbe5e539b5a270bed86eed78b283c79cdb Mon Sep 17 00:00:00 2001
  2. From: Daniel Golle <daniel@makrotopia.org>
  3. Date: Thu, 27 May 2021 01:18:20 +0200
  4. Subject: [PATCH] add support for Sierra Wireless qcserial NMEA-0183 interface
  5. Sierra Wireless EM 74xx modems come with a serial port outputting
  6. NMEA-0183 GPS sentences. In order to make it work, the magic string
  7. '$GPS_START' needs to be written to the modem, as only then the modem
  8. firmware starts sending NMEA-0183 output.
  9. Add option 'sierragpsstart' which if set to anything else than 0 will
  10. make kplex send the magic string when the device is opened.
  11. ---
  12. serial.c | 13 ++++++++++---
  13. 1 file changed, 10 insertions(+), 3 deletions(-)
  14. --- a/serial.c
  15. +++ b/serial.c
  16. @@ -24,6 +24,7 @@
  17. #include <pwd.h>
  18. #define DEFSERIALQSIZE 32
  19. +#define SIERRA_GPS_START "$GPS_START\n"
  20. struct if_serial {
  21. int fd;
  22. @@ -290,7 +291,8 @@ struct iface *init_serial (struct iface
  23. int ret;
  24. struct kopts *opt;
  25. int qsize=DEFSERIALQSIZE;
  26. -
  27. + int send_gps_start = 0;
  28. +
  29. for(opt=ifa->options;opt;opt=opt->next) {
  30. if (!strcasecmp(opt->var,"filename"))
  31. devname=opt->val;
  32. @@ -324,7 +326,9 @@ struct iface *init_serial (struct iface
  33. logerr(0,"Invalid queue size specified: %s",opt->val);
  34. return(NULL);
  35. }
  36. - } else {
  37. + } else if (!strcasecmp(opt->var, "sierragpsstart")) {
  38. + send_gps_start=atoi(opt->val);
  39. + } else {
  40. logerr(0,"unknown interface option %s",opt->var);
  41. return(NULL);
  42. }
  43. @@ -337,7 +341,7 @@ struct iface *init_serial (struct iface
  44. }
  45. /* Open interface or die */
  46. - if ((ifs->fd=ttyopen(devname,ifa->direction)) < 0) {
  47. + if ((ifs->fd=ttyopen(devname, send_gps_start?BOTH:ifa->direction)) < 0) {
  48. return(NULL);
  49. }
  50. DEBUG(3,"%s: opened serial device %s for %s",ifa->name,devname,
  51. @@ -358,6 +362,9 @@ struct iface *init_serial (struct iface
  52. ifs->saved=1;
  53. ifs->slavename=NULL;
  54. + if (send_gps_start)
  55. + write(ifs->fd, SIERRA_GPS_START, strlen(SIERRA_GPS_START));
  56. +
  57. /* Assign pointers to read, write and cleanup routines */
  58. ifa->read=do_read;
  59. ifa->readbuf=read_serial;