From: Martin Ling Date: Sat, 7 Dec 2013 18:41:09 +0000 (+0000) Subject: Add std_serial_dev_close() function. X-Git-Tag: libsigrok-0.3.0~460 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=043e899a5155dcdc353abc20006424973d8e2ed0;p=libsigrok.git Add std_serial_dev_close() function. --- diff --git a/libsigrok-internal.h b/libsigrok-internal.h index b9b92ebb..28ee2685 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -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 7837d35a..1067c271 100644 --- 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; +}