Skip to content

Commit 54e63cd

Browse files
dangowrtutoni
authored andcommitted
kplex: add support for Sierra Wireless Gobi GPS
Sierra Wireless modems need the string '$GPS_START' to be sent to the GPS tty device as only then the modem firmware starts emitting NMEA-0183 sentences. Add an option 'sierragpsstart' to kplex' serial driver to support that quirk as kplex can be very useful to spread GPS data over the network while also supplying 'ugps' using a PTY, allowing for correct system time to be set automatically on boot up from GPS. This patch is also PR'ed at the upstream project: stripydog/kplex#54 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
1 parent dd43d88 commit 54e63cd

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

net/kplex/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
88

99
PKG_NAME:=kplex
1010
PKG_VERSION:=1.4
11-
PKG_RELEASE=2
11+
PKG_RELEASE=3
1212

1313
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tgz
1414
PKG_SOURCE_URL:=http://www.stripydog.com/download
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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+
6+
Sierra Wireless EM 74xx modems come with a serial port outputting
7+
NMEA-0183 GPS sentences. In order to make it work, the magic string
8+
'$GPS_START' needs to be written to the modem, as only then the modem
9+
firmware starts sending NMEA-0183 output.
10+
Add option 'sierragpsstart' which if set to anything else than 0 will
11+
make kplex send the magic string when the device is opened.
12+
---
13+
serial.c | 13 ++++++++++---
14+
1 file changed, 10 insertions(+), 3 deletions(-)
15+
16+
--- a/serial.c
17+
+++ b/serial.c
18+
@@ -24,6 +24,7 @@
19+
#include <pwd.h>
20+
21+
#define DEFSERIALQSIZE 32
22+
+#define SIERRA_GPS_START "$GPS_START\n"
23+
24+
struct if_serial {
25+
int fd;
26+
@@ -290,7 +291,8 @@ struct iface *init_serial (struct iface
27+
int ret;
28+
struct kopts *opt;
29+
int qsize=DEFSERIALQSIZE;
30+
-
31+
+ int send_gps_start = 0;
32+
+
33+
for(opt=ifa->options;opt;opt=opt->next) {
34+
if (!strcasecmp(opt->var,"filename"))
35+
devname=opt->val;
36+
@@ -324,7 +326,9 @@ struct iface *init_serial (struct iface
37+
logerr(0,"Invalid queue size specified: %s",opt->val);
38+
return(NULL);
39+
}
40+
- } else {
41+
+ } else if (!strcasecmp(opt->var, "sierragpsstart")) {
42+
+ send_gps_start=atoi(opt->val);
43+
+ } else {
44+
logerr(0,"unknown interface option %s",opt->var);
45+
return(NULL);
46+
}
47+
@@ -337,7 +341,7 @@ struct iface *init_serial (struct iface
48+
}
49+
50+
/* Open interface or die */
51+
- if ((ifs->fd=ttyopen(devname,ifa->direction)) < 0) {
52+
+ if ((ifs->fd=ttyopen(devname, send_gps_start?BOTH:ifa->direction)) < 0) {
53+
return(NULL);
54+
}
55+
DEBUG(3,"%s: opened serial device %s for %s",ifa->name,devname,
56+
@@ -358,6 +362,9 @@ struct iface *init_serial (struct iface
57+
ifs->saved=1;
58+
ifs->slavename=NULL;
59+
60+
+ if (send_gps_start)
61+
+ write(ifs->fd, SIERRA_GPS_START, strlen(SIERRA_GPS_START));
62+
+
63+
/* Assign pointers to read, write and cleanup routines */
64+
ifa->read=do_read;
65+
ifa->readbuf=read_serial;

0 commit comments

Comments
 (0)