From: Bert Vermeulen Date: Thu, 2 Aug 2012 23:05:01 +0000 (+0200) Subject: ols: remove serial source from session when done X-Git-Tag: dsupstream~738 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=26bf9d56c079889cd493376b341ab75acee795f7;p=libsigrok.git ols: remove serial source from session when done --- diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 296a5914..5a73cfc7 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -702,6 +702,22 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap, return ret; } +static void abort_acquisition(const struct sr_dev_inst *sdi) +{ + struct sr_datafeed_packet packet; + struct dev_context *devc; + + devc = sdi->priv; + sr_source_remove(devc->serial->fd); + + /* Terminate session */ + packet.type = SR_DF_END; + sr_session_send(sdi, &packet); + +} + + + static int receive_data(int fd, int revents, void *cb_data) { struct sr_datafeed_packet packet; @@ -878,8 +894,8 @@ static int receive_data(int fd, int revents, void *cb_data) serial_flush(fd); serial_close(fd); - packet.type = SR_DF_END; - sr_session_send(cb_data, &packet); + + abort_acquisition(sdi); } return TRUE; @@ -1045,13 +1061,11 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi, static int hw_dev_acquisition_stop(const struct sr_dev_inst *sdi, void *cb_data) { - struct sr_datafeed_packet packet; /* Avoid compiler warnings. */ - (void)sdi; + (void)cb_data; - packet.type = SR_DF_END; - sr_session_send(cb_data, &packet); + abort_acquisition(sdi); return SR_OK; }