summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Arlt <reinhard.arlt@t-online.de>2012-07-21 17:13:01 +0200
committerReinhard Arlt <reinhard.arlt@t-online.de>2012-07-21 17:13:01 +0200
commit484428d0a3454e63bf568c4e962371867322fbb5 (patch)
tree938f4ea1de05ad723b2917334d3be51b766d9f09
parent51da3014a4815cc34fe14be1621fa859a4102567 (diff)
downloadgpsd-484428d0a3454e63bf568c4e962371867322fbb5.tar.gz
Own nmea2000_close as gpsd_close is really a serial_close.
-rw-r--r--driver_nmea2000.c10
-rw-r--r--driver_nmea2000.h2
-rw-r--r--libgpsd_core.c7
3 files changed, 18 insertions, 1 deletions
diff --git a/driver_nmea2000.c b/driver_nmea2000.c
index aaa40f9e..ca87ca6b 100644
--- a/driver_nmea2000.c
+++ b/driver_nmea2000.c
@@ -807,6 +807,16 @@ int nmea2000_open(struct gps_device_t *session)
}
#endif /* of ifndef S_SPLINT_S */
+void nmea2000_close(struct gps_device_t *session)
+{
+ if (session->gpsdata.gps_fd != -1) {
+ gpsd_report(LOG_SPIN, "close(%d) in nmea2000_close(%s)\n",
+ session->gpsdata.gps_fd, session->gpsdata.dev.path);
+ (void)close(session->gpsdata.gps_fd);
+ session->gpsdata.gps_fd = -1;
+ }
+}
+
/* *INDENT-OFF* */
const struct gps_type_t nmea2000 = {
.type_name = "NMEA2000", /* full name of type */
diff --git a/driver_nmea2000.h b/driver_nmea2000.h
index f157d09c..fa498ed9 100644
--- a/driver_nmea2000.h
+++ b/driver_nmea2000.h
@@ -14,6 +14,8 @@
int nmea2000_open(struct gps_device_t *session);
+void nmea2000_close(struct gps_device_t *session);
+
#endif /* of defined(NMEA2000_ENABLE) */
#endif /* of ifndef _DRIVER_NMEA2000_H_ */
diff --git a/libgpsd_core.c b/libgpsd_core.c
index c7747435..da584f4d 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -187,7 +187,12 @@ void gpsd_deactivate(struct gps_device_t *session)
#endif /* RECONFIGURE_ENABLE */
gpsd_report(LOG_INF, "closing GPS=%s (%d)\n",
session->gpsdata.dev.path, session->gpsdata.gps_fd);
- (void)gpsd_close(session);
+#if defined(NMEA2000_ENABLE)
+ if (session->sourcetype == source_can)
+ (void)nmea2000_close(session);
+ else
+#endif /* of defined(NMEA2000_ENABLE) */
+ (void)gpsd_close(session);
gpsd_run_device_hook(session->gpsdata.dev.path, "DEACTIVATE");
}