]> sigrok.org Git - libsigrok.git/commitdiff
Add std_serial_dev_close() function.
authorMartin Ling <redacted>
Sat, 7 Dec 2013 18:41:09 +0000 (18:41 +0000)
committerMartin Ling <redacted>
Sat, 7 Dec 2013 19:43:47 +0000 (19:43 +0000)
libsigrok-internal.h
std.c

index b9b92ebb27c0f6a60c465a974b19b4a33e1bb7d9..28ee268589d0596297ebd2f3fa80bebadc383973 100644 (file)
@@ -190,6 +190,7 @@ SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi,
                const char *prefix);
 SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
                std_dev_clear_t clear_private);
+SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi);
 
 /*--- strutil.c -------------------------------------------------------------*/
 
diff --git a/std.c b/std.c
index 7837d35a3c32f95f0bcabbca69c1655d1b67f675..1067c271542c2ff41ce03fdc7fe528a1b63ddbd0 100644 (file)
--- a/std.c
+++ b/std.c
@@ -230,3 +230,16 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver,
 
        return ret;
 }
+
+SR_PRIV int std_serial_close(struct sr_dev_inst *sdi)
+{
+       struct sr_serial_dev_inst *serial;
+
+       serial = sdi->conn;
+       if (serial && serial->fd != -1) {
+               serial_close(serial);
+               sdi->status = SR_ST_INACTIVE;
+       }
+
+       return SR_OK;
+}