summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver_nmea2000.c2
-rw-r--r--serial.c15
2 files changed, 14 insertions, 3 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index bab5c52c..0b9caf4f 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -1675,7 +1675,7 @@ int nmea2000_open(struct gps_device_t *session)
}
}
- session->gpsdata.dev.parity = 'n';
+ session->gpsdata.dev.parity = 'N';
session->gpsdata.dev.baudrate = 250000;
session->gpsdata.dev.stopbits = 0;
return session->gpsdata.gps_fd;
diff --git a/serial.c b/serial.c
index 7a030cfa..51e5e19f 100644
--- a/serial.c
+++ b/serial.c
@@ -292,6 +292,19 @@ void gpsd_set_speed(struct gps_device_t *session,
else
rate = B230400;
+ /* backward-compatibility hack */
+ switch (parity) {
+ case (char)2:
+ parity = 'E';
+ break;
+ case (char)1:
+ parity = 'O';
+ break;
+ case (char)0:
+ parity = 'N'; /* without this we might emit malformed JSON */
+ break;
+ }
+
if (rate != cfgetispeed(&session->ttyset)
|| parity != session->gpsdata.dev.parity
|| stopbits != session->gpsdata.dev.stopbits) {
@@ -315,12 +328,10 @@ void gpsd_set_speed(struct gps_device_t *session,
session->ttyset.c_cflag |= (stopbits == 2 ? CS7 | CSTOPB : CS8);
switch (parity) {
case 'E':
- case (char)2:
session->ttyset.c_iflag |= INPCK;
session->ttyset.c_cflag |= PARENB;
break;
case 'O':
- case (char)1:
session->ttyset.c_iflag |= INPCK;
session->ttyset.c_cflag |= PARENB | PARODD;
break;