summaryrefslogtreecommitdiff
path: root/driver_nmea2000.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2015-03-16 10:20:18 -0400
committerEric S. Raymond <esr@thyrsus.com>2015-03-16 20:08:57 -0400
commitac5ab2343e93ac141460ab23954ea53ba66517fb (patch)
treecaa74f0bf39fd99ade39293a29ff4badda11d47b /driver_nmea2000.c
parente8304a299aceb9b1cc7b6136d17f456872250ada (diff)
downloadgpsd-ac5ab2343e93ac141460ab23954ea53ba66517fb.tar.gz
Attempted fix for a close/reopen bug involvinf NMEA2000.
This was reported on gosd-users by Vignesh Krishnan <Krishnan_Vignesh@cat.com>: > For the nmea2000 bug . I connect using gpsd control socket > > ./gpsd -n -F /tmp/control_sock > > Adding source is possible > +nmea2000://can1 > > Removing sourc is also possible with > -nmea2000://can1 > > Readding the source is not possible with > +nmea2000://can1 > > This is because the there is an array which stores the list of nmea > devices. That is not cleared on removed. So adding the second time results > in device exist error when actually device does not exist. To address this, the driver close() method tries to zero the proper array location. All regression tests pass.
Diffstat (limited to 'driver_nmea2000.c')
-rw-r--r--driver_nmea2000.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index 309708b3..5b1e207d 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -1677,6 +1677,21 @@ void nmea2000_close(struct gps_device_t *session)
session->gpsdata.gps_fd, session->gpsdata.dev.path);
(void)close(session->gpsdata.gps_fd);
INVALIDATE_SOCKET(session->gpsdata.gps_fd);
+
+ if (session->driver.nmea2000.unit_valid != 0) {
+ unsigned int l1, l2;
+
+ for (l1=0;l1<NMEA2000_NETS;l1++) {
+ for (l2=0;l2<NMEA2000_UNITS;l2++) {
+ if (session == nmea2000_units[l1][l2]) {
+ session->driver.nmea2000.unit_valid = 0;
+ session->driver.nmea2000.unit = 0;
+ session->driver.nmea2000.can_net = 0;
+ nmea2000_units[l1][l2] = NULL;
+ }
+ }
+ }
+ }
}
}