]> sigrok.org Git - libsigrok.git/blobdiff - std.c
Use sdi->status instead of serial->fd to tell if port needs closing.
[libsigrok.git] / std.c
diff --git a/std.c b/std.c
index ed37abeac641b02a760f6e1d46bad285772c002e..ab151198c07ad79d5ce522d0dcdc24611d9b84ec 100644 (file)
--- a/std.c
+++ b/std.c
@@ -143,7 +143,7 @@ SR_PRIV int std_dev_acquisition_stop_serial(struct sr_dev_inst *sdi,
 
        sr_dbg("%sStopping acquisition.", prefix);
 
-       if ((ret = sr_source_remove(serial->fd)) < 0) {
+       if ((ret = serial_source_remove(serial)) < 0) {
                sr_err("%sFailed to remove source: %d.", prefix, ret);
                return ret;
        }
@@ -230,3 +230,16 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
 
        return ret;
 }
+
+SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi)
+{
+       struct sr_serial_dev_inst *serial;
+
+       serial = sdi->conn;
+       if (serial && sdi->status == SR_ST_ACTIVE) {
+               serial_close(serial);
+               sdi->status = SR_ST_INACTIVE;
+       }
+
+       return SR_OK;
+}