]> sigrok.org Git - libsigrok.git/commitdiff
ols: remove serial source from session when done
authorBert Vermeulen <redacted>
Thu, 2 Aug 2012 23:05:01 +0000 (01:05 +0200)
committerBert Vermeulen <redacted>
Fri, 3 Aug 2012 09:29:01 +0000 (11:29 +0200)
hardware/openbench-logic-sniffer/ols.c

index 296a59149044aa576341790e54a2fb7a76119415..5a73cfc7a7974c445a496788e44ac097fb045993 100644 (file)
@@ -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;
 }