]> sigrok.org Git - libsigrok.git/commitdiff
Add sr_dev_acquisition_stop(), factor out SR_ERR_DEV_CLOSED check.
authorUwe Hermann <redacted>
Wed, 5 Jul 2017 17:33:38 +0000 (19:33 +0200)
committerUwe Hermann <redacted>
Fri, 7 Jul 2017 19:51:10 +0000 (21:51 +0200)
This ensures consistent checks and log messages across all drivers
and reduces the per-driver boilerplate.

78 files changed:
src/hardware/agilent-dmm/protocol.c
src/hardware/appa-55ii/protocol.c
src/hardware/arachnid-labs-re-load-pro/protocol.c
src/hardware/asix-sigma/protocol.c
src/hardware/atten-pps3xxx/api.c
src/hardware/baylibre-acme/api.c
src/hardware/baylibre-acme/protocol.c
src/hardware/beaglelogic/api.c
src/hardware/brymen-bm86x/api.c
src/hardware/brymen-bm86x/protocol.c
src/hardware/brymen-dmm/protocol.c
src/hardware/cem-dt-885x/protocol.c
src/hardware/center-3xx/protocol.c
src/hardware/chronovu-la/api.c
src/hardware/colead-slm/protocol.c
src/hardware/conrad-digi-35-cpu/api.c
src/hardware/demo/api.c
src/hardware/demo/protocol.c
src/hardware/fluke-dmm/protocol.c
src/hardware/ftdi-la/api.c
src/hardware/ftdi-la/protocol.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/gwinstek-gds-800/api.c
src/hardware/gwinstek-gds-800/protocol.c
src/hardware/hameg-hmo/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/hantek-6xxx/api.c
src/hardware/hantek-dso/api.c
src/hardware/hp-3457a/protocol.c
src/hardware/hung-chang-dso-2100/api.c
src/hardware/hung-chang-dso-2100/protocol.c
src/hardware/hung-chang-dso-2100/protocol.h
src/hardware/ikalogic-scanalogic2/api.c
src/hardware/ikalogic-scanaplus/api.c
src/hardware/ikalogic-scanaplus/protocol.c
src/hardware/kecheng-kc-330b/api.c
src/hardware/kecheng-kc-330b/protocol.c
src/hardware/kern-scale/protocol.c
src/hardware/korad-kaxxxxp/protocol.c
src/hardware/lascar-el-usb/api.c
src/hardware/lascar-el-usb/protocol.c
src/hardware/lascar-el-usb/protocol.h
src/hardware/lecroy-logicstudio/api.c
src/hardware/lecroy-xstream/api.c
src/hardware/lecroy-xstream/protocol.c
src/hardware/link-mso19/protocol.c
src/hardware/manson-hcs-3xxx/protocol.c
src/hardware/maynuo-m97/api.c
src/hardware/maynuo-m97/protocol.c
src/hardware/mic-985xx/protocol.c
src/hardware/motech-lps-30x/protocol.c
src/hardware/norma-dmm/protocol.c
src/hardware/pce-322a/protocol.c
src/hardware/pipistrello-ols/api.c
src/hardware/pipistrello-ols/protocol.c
src/hardware/rigol-ds/api.c
src/hardware/rigol-ds/protocol.c
src/hardware/saleae-logic-pro/api.c
src/hardware/saleae-logic16/api.c
src/hardware/scpi-pps/api.c
src/hardware/serial-dmm/protocol.c
src/hardware/sysclk-lwla/api.c
src/hardware/teleinfo/protocol.c
src/hardware/testo/api.c
src/hardware/testo/protocol.c
src/hardware/tondaj-sl-814/protocol.c
src/hardware/uni-t-dmm/api.c
src/hardware/uni-t-dmm/protocol.c
src/hardware/uni-t-ut32x/api.c
src/hardware/uni-t-ut32x/protocol.c
src/hardware/victor-dmm/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/yokogawa-dlm/protocol.c
src/hwdriver.c
src/lcr/es51919.c
src/libsigrok-internal.h
src/session.c
src/std.c

index 439cbd00ec621f5a70d8cb1860ce832a80272adc..8778c711c427ca9d07badd27017f0b54c4d302b4 100644 (file)
@@ -200,7 +200,7 @@ SR_PRIV int agdmm_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits) || stop)
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        else
                dispatch(sdi);
 
index c22ede50fcef1179fb6c499f07386d4591521e96..f31b08b806b9199669467d5bec567c9b16c260db 100644 (file)
@@ -224,7 +224,7 @@ static void appa_55ii_log_end(struct sr_dev_inst *sdi)
        if (devc->data_source != DATA_SOURCE_MEMORY)
                return;
 
-       sdi->driver->dev_acquisition_stop(sdi);
+       sr_dev_acquisition_stop(sdi);
 }
 
 static const uint8_t *appa_55ii_parse_data(struct sr_dev_inst *sdi,
@@ -309,7 +309,7 @@ SR_PRIV int appa_55ii_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index dd0ad409508ffc37a4376e8d3d890f49d77c028e..47cc8af115c0447a00593cdf8b94d02d4771783d 100644 (file)
@@ -263,7 +263,7 @@ SR_PRIV int reloadpro_receive_data(int fd, int revents, void *cb_data)
        handle_new_data(sdi);
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 4d1b1cceb694a304b77cbc45d8cc7ef9a717e512..cc742d10bd646578cb22ee5ddf4466a1ced988ce 100644 (file)
@@ -1114,7 +1114,7 @@ static int download_capture(struct sr_dev_inst *sdi)
 
        std_session_send_df_end(sdi);
 
-       sdi->driver->dev_acquisition_stop(sdi);
+       sr_dev_acquisition_stop(sdi);
 
        g_free(dram_line);
 
index 01c0d369a490adb6a8983d3f3f5f5a69913a050e..1768f842969c5d072a8fd0c04133b8402c167cdd 100644 (file)
@@ -466,9 +466,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
        devc->acquisition_running = FALSE;
 
index a1b860e3621fb91a1655d97fda085a66fb339e08..8e0af46df9bfc3147f5759fe9ab3cf9f71e2bf0a 100644 (file)
@@ -360,9 +360,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        dev_acquisition_close(sdi);
        sr_session_source_remove_channel(sdi->session, devc->channel);
        g_io_channel_shutdown(devc->channel, FALSE, NULL);
index 4f62a9e9ecc2ac7650cc206ebd9b6dac21cf69ed..0311f68e2db843fb0a305b186b941979012a9226 100644 (file)
@@ -793,7 +793,7 @@ SR_PRIV int bl_acme_receive_data(int fd, int revents, void *cb_data)
        sr_sw_limits_update_samples_read(&devc->limits, 1);
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index 34b09f211fb26f2b54e464a7f973c2ce0a51ee3e..c8e43730a3fb6ddf11a3e1ab3afad5f95fd63370 100644 (file)
@@ -332,9 +332,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        /* Execute a stop on BeagleLogic */
        beaglelogic_stop(devc);
 
index fb9f2807efd87496a18e346a8597d7a319c61cbe..484e1476707da7f1a1556140d80e455f3bbbbd29 100644 (file)
@@ -227,9 +227,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        std_session_send_df_end(sdi);
 
        sr_session_source_remove(sdi->session, -1);
index 3181fef081c85cbf4380af54c774099b1d9e43af..f9b2bde1b4b1e024cf3d0773bd3dd8e43db70a39 100644 (file)
@@ -344,7 +344,7 @@ SR_PRIV int brymen_bm86x_receive_data(int fd, int revents, void *cb_data)
                return FALSE;
 
        if (sr_sw_limits_check(&devc->sw_limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 5a7f2252a7e701639278207d2ad880de30942a49..3dd8dd3137a3074ea2bbb397963f09cb1e991874 100644 (file)
@@ -143,7 +143,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->sw_limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 88fa8b7fbc68dfa26b8e1bbf6d67919143ac31eb..092d16542aa2aa1e0f3ff75c7049dac726228cc8 100644 (file)
@@ -147,7 +147,7 @@ static void process_mset(const struct sr_dev_inst *sdi)
 
                devc->num_samples++;
                if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
-                       sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+                       sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
                break;
        case TOKEN_RECORDING_ON:
                devc->recording = TRUE;
@@ -208,7 +208,7 @@ static void send_data(const struct sr_dev_inst *sdi, unsigned char *data,
 
        devc->num_samples += analog.num_samples;
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
-               sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+               sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
 
        return;
 }
@@ -321,7 +321,7 @@ static void process_byte(const struct sr_dev_inst *sdi, const unsigned char c,
                         * records. Otherwise the frontend would have no
                         * way to tell where stored data ends and live
                         * measurements begin. */
-                       sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+                       sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
                } else if (c == RECORD_DATA) {
                        devc->buf_len = 0;
                        devc->state = ST_GET_LOG_RECORD_DATA;
index ca1ae3b59821f14d8622ada038acaca0fbae846f..2a02b68e50c6890e3602cec85cb0943bf6f9a2b7 100644 (file)
@@ -243,7 +243,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->sw_limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 11721ebe6bbc72d0a6933ff8c880cd7eefa5f865..3ccac06b8e9ef30cc7f91c007ee9756e539a6a0f 100644 (file)
@@ -43,8 +43,6 @@ static const int32_t trigger_matches[] = {
        SR_TRIGGER_FALLING,
 };
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static void clear_helper(void *priv)
 {
        struct dev_context *devc;
@@ -452,7 +450,7 @@ static int receive_data(int fd, int revents, void *cb_data)
        /* Get one block of data. */
        if ((ret = cv_read_block(devc)) < 0) {
                sr_err("Failed to read data block: %d.", ret);
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return FALSE;
        }
 
@@ -475,7 +473,7 @@ static int receive_data(int fd, int revents, void *cb_data)
        for (i = 0; i < NUM_BLOCKS; i++)
                cv_send_block_to_session_bus(sdi, i);
 
-       dev_acquisition_stop(sdi);
+       sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
@@ -552,7 +550,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       sr_dbg("Stopping acquisition.");
        sr_session_source_remove(sdi->session, -1);
        std_session_send_df_end(sdi);
 
index 2f6957abe2d0170770eb86694812abcc566090f2..b577f236c0ac85de0ba475a9338660ba63379b78 100644 (file)
@@ -177,7 +177,7 @@ static void process_packet(const struct sr_dev_inst *sdi)
        sr_sw_limits_update_samples_read(&devc->limits, 1);
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+               sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
 }
 
 SR_PRIV int colead_slm_receive_data(int fd, int revents, void *cb_data)
index cfa503d52a125d86a010d476f2b5398ab04cab98..022e53304a2b5cdcb0cbf689d4f62bf53128bbcb 100644 (file)
@@ -171,8 +171,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
+       (void)sdi;
 
        return SR_OK;
 }
index f1a97eb4e5519f8a47f97c0e12290cf239c23b5a..5ab1f4afdfe9dc213e0d6b1de1d68d7ce30cc1ee 100644 (file)
@@ -532,7 +532,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       sr_dbg("Stopping acquisition.");
        sr_session_source_remove(sdi->session, -1);
        std_session_send_df_end(sdi);
 
index 470003026a1f47172bafae45ca543555d995bfe6..38943e43044b2a842e83652299d217ce296e2d3b 100644 (file)
@@ -446,7 +446,7 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
        if (devc->cur_samplerate <= 0
                        || (devc->num_logic_channels <= 0
                        && devc->num_analog_channels <= 0)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return G_SOURCE_CONTINUE;
        }
 
@@ -539,7 +539,7 @@ SR_PRIV int demo_prepare_data(int fd, int revents, void *cb_data)
                        }
                }
                sr_dbg("Requested number of samples reached.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        }
 
        return G_SOURCE_CONTINUE;
index 7500ab3116c35edbefdeb76d7b75f1b677943e46..af4fd56c62d129d6ecdf3bc5d83caf24219ef934 100644 (file)
@@ -526,7 +526,7 @@ SR_PRIV int fluke_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index 0927d3a274387d14d1fe1dd34a1377f72a73ee23..240aa7ad2597eed0a81145c24bf901b7e5ee6f4f 100644 (file)
@@ -462,10 +462,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
-       sr_dbg("Stopping acquisition.");
        sr_session_source_remove(sdi->session, -1);
 
        std_session_send_df_end(sdi);
index 8d81d87752e6d91829d55f781c4738b31f3d4c27..264b4f222eb5714a56a86b909be5a660bc77f9c0 100644 (file)
@@ -79,7 +79,7 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
        if (bytes_read < 0) {
                sr_err("Failed to read FTDI data (%d): %s.",
                       bytes_read, ftdi_get_error_string(devc->ftdic));
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return FALSE;
        }
        if (bytes_read == 0) {
@@ -94,7 +94,7 @@ SR_PRIV int ftdi_la_receive_data(int fd, int revents, void *cb_data)
        if (devc->limit_samples && (n >= devc->limit_samples)) {
                send_samples(sdi, devc->limit_samples - devc->samples_sent);
                sr_info("Requested number of samples reached.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        } else {
                send_samples(sdi, devc->bytes_received);
index 10fe9c09e102b6505a96e047fb1cf3c829bcf2c9..2911b82f8ae91e34dc343cc00578f87a5ad4de44 100644 (file)
@@ -1175,7 +1175,7 @@ SR_PRIV int gmc_mh_1x_2x_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
@@ -1218,7 +1218,7 @@ SR_PRIV int gmc_mh_2x_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        /* Request next data set, if required */
        if (sdi->status == SR_ST_ACTIVE) {
index 99c29a3e5ccc466167b310b4b1d80f5571964d96..7e947466b784276f61d528a43fa8e8b7b0405768 100644 (file)
@@ -220,11 +220,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        scpi = sdi->conn;
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device inactive, can't stop acquisition.");
-               return SR_ERR;
-       }
-
        if (devc->df_started) {
                packet.type = SR_DF_FRAME_END;
                sr_session_send(sdi, &packet);
index 604ec54f9d0a881465f0da3b63c64cf54dec8cf0..962bfe05467222431049bbcb178bc47318d5c5e0 100644 (file)
@@ -35,7 +35,7 @@ static int read_data(struct sr_dev_inst *sdi,
                data_size - devc->cur_rcv_buffer_position);
        if (len < 0) {
                sr_err("Read data error.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                devc->cur_rcv_buffer_position = 0;
                return SR_ERR;
        }
@@ -55,7 +55,7 @@ static int read_data(struct sr_dev_inst *sdi,
                return SR_OK;
        } else {
                sr_err("Too many bytes read.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                devc->cur_rcv_buffer_position = 0;
                return SR_ERR;
        }
@@ -96,17 +96,17 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
        case START_ACQUISITION:
                if (sr_scpi_send(scpi, ":TRIG:MOD 3") != SR_OK) {
                        sr_err("Failed to set trigger mode to SINGLE.");
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return TRUE;
                }
                if (sr_scpi_send(scpi, ":STOP") != SR_OK) {
                        sr_err("Failed to put the trigger system into STOP state.");
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return TRUE;
                }
                if (sr_scpi_send(scpi, ":RUN") != SR_OK) {
                        sr_err("Failed to put the trigger system into RUN state.");
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return TRUE;
                }
 
@@ -117,12 +117,12 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                if (((struct sr_channel *)g_slist_nth_data(sdi->channels, devc->cur_acq_channel))->enabled) {
                        if (sr_scpi_send(scpi, ":ACQ%d:MEM?", devc->cur_acq_channel+1) != SR_OK) {
                                sr_err("Failed to acquire memory.");
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        }
                        if (sr_scpi_read_begin(scpi) != SR_OK) {
                                sr_err("Could not begin reading SCPI response.");
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        }
                        devc->state = WAIT_FOR_TRANSFER_OF_BEGIN_TRANSMISSION_COMPLETE;
@@ -136,7 +136,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                                        /* All frames accquired. */
                                        sr_spew("All frames acquired.");
 
-                                       sdi->driver->dev_acquisition_stop(sdi);
+                                       sr_dev_acquisition_stop(sdi);
                                        return TRUE;
                                } else {
                                        /* Start acquiring next frame. */
@@ -170,7 +170,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                                devc->rcv_buffer[0] != '6') {
                                sr_err("Data size digits is not 4, 5 or 6 but "
                                       "'%c'.", devc->rcv_buffer[0]);
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        } else {
                                devc->data_size_digits = devc->rcv_buffer[0] - '0';
@@ -183,7 +183,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                        devc->rcv_buffer[devc->data_size_digits] = 0;
                        if (sr_atoi(devc->rcv_buffer, &devc->data_size) != SR_OK) {
                                sr_err("Could not parse data size '%s'", devc->rcv_buffer);
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        } else
                                devc->state = WAIT_FOR_TRANSFER_OF_SAMPLE_RATE_COMPLETE;
@@ -224,7 +224,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                                        devc->cur_acq_channel + 1);
                        if (sr_scpi_get_string(scpi, command, &response) != SR_OK) {
                                sr_err("Failed to get volts per division.");
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        }
                        volts_per_division = g_ascii_strtod(response, &end_ptr);
@@ -264,7 +264,7 @@ SR_PRIV int gwinstek_gds_800_receive_data(int fd, int revents, void *cb_data)
                                if (devc->cur_acq_frame == devc->frame_limit - 1) {
                                        /* All frames acquired. */
                                        sr_spew("All frames acquired.");
-                                       sdi->driver->dev_acquisition_stop(sdi);
+                                       sr_dev_acquisition_stop(sdi);
                                        return TRUE;
                                } else {
                                        /* Start acquiring next frame. */
index 89042da7a4b5adda5c399ed78ca0046f8c04508c..8a4212af096d7610209f7419de1a36135405dee2 100644 (file)
@@ -811,9 +811,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        std_session_send_df_end(sdi);
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        devc->num_frames = 0;
index f44db1a272bb4eb31e73c7802ecd246891419a06..12e79c47393ec342cd0719fa8634cfd6aea3f911 100644 (file)
@@ -1018,7 +1018,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
         * the first enabled channel.
         */
        if (++devc->num_frames == devc->frame_limit) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                hmo_cleanup_logic_data(devc);
        } else {
                devc->current_channel = devc->enabled_channels;
index a6aa68543775bc3644abc62ccde6c2f475f084a3..025695e1df41cf1b913664be95e5e38e85752545 100644 (file)
@@ -88,8 +88,6 @@ static const uint64_t vdivs[][2] = {
 
 static int read_channel(const struct sr_dev_inst *sdi, uint32_t amount);
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static struct sr_dev_inst *hantek_6xxx_dev_new(const struct hantek_6xxx_profile *prof)
 {
        struct sr_dev_inst *sdi;
@@ -709,7 +707,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
                        PRIu64 " <= %" PRIu64, devc->limit_samples,
                        devc->samp_received);
                send_data(sdi, devc->sample_buf, devc->limit_samples);
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else if (devc->limit_msec && (g_get_monotonic_time() -
                        devc->aq_started) / 1000 >= devc->limit_msec) {
                sr_info("Requested time limit reached, stopping. %d <= %d",
@@ -718,7 +716,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
                send_data(sdi, devc->sample_buf, devc->samp_received);
                g_free(devc->sample_buf);
                devc->sample_buf = NULL;
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else {
                read_channel(sdi, data_amount(sdi));
        }
@@ -818,9 +816,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR;
-
        devc = sdi->priv;
        devc->dev_state = STOPPING;
 
index 6a6aa09dc5e76068e3be6021386fb8e7024d2a24..f5e7383d9c439d97297c855d85c9396eb60a01f5 100644 (file)
@@ -161,8 +161,6 @@ static const char *coupling[] = {
        "GND",
 };
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static struct sr_dev_inst *dso_dev_new(const struct dso_profile *prof)
 {
        struct sr_dev_inst *sdi;
@@ -984,9 +982,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR;
-
        devc = sdi->priv;
        devc->dev_state = STOPPING;
 
index dd8d6f8fdbeb75df1f3873fe5e68d5f27036a156..aa8ab5284bc3664feaa8cffee781221eb633d683 100644 (file)
@@ -435,7 +435,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
                ret = sr_scpi_get_double(scpi, NULL, &devc->last_channel_sync);
                if (ret != SR_OK) {
                        sr_err("Cannot check channel synchronization.");
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return FALSE;
                }
                devc->acq_state = ACQ_GOT_CHANNEL_SYNC;
@@ -456,7 +456,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
                        sr_err("Expected channel %u, but device says %u",
                               chanc->index,
                               (unsigned int)devc->last_channel_sync);
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return FALSE;
                }
                /* All is good. Back to business. */
@@ -464,7 +464,7 @@ SR_PRIV int hp_3457a_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return FALSE;
        }
 
index bad92c00b8f7344517866da9573d28cc72e8815f..0ed7995962f4bb8aa87f6288db08458ec43ab3b1 100644 (file)
@@ -692,11 +692,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        std_session_send_df_end(sdi);
        sr_session_source_remove(sdi->session, -1);
        hung_chang_dso_2100_move_to(sdi, 1);
@@ -704,11 +701,6 @@ SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *s
        return SR_OK;
 }
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi)
-{
-       return hung_chang_dso_2100_dev_acquisition_stop(sdi);
-}
-
 static struct sr_dev_driver hung_chang_dso_2100_driver_info = {
        .name = "hung-chang-dso-2100",
        .longname = "Hung-Chang DSO-2100",
index 160e5a0c63f1de492d9b45eb3b86f5c1837f51d9..69efb14d3c332b125334490b4ebc901ed25794be 100644 (file)
@@ -420,7 +420,7 @@ static int read_subframe(const struct sr_dev_inst *sdi, uint8_t *buf)
 SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
 {
        struct sr_datafeed_packet packet = { .type = SR_DF_FRAME_BEGIN };
-       const struct sr_dev_inst *sdi;
+       struct sr_dev_inst *sdi;
        struct dev_context *devc;
        uint8_t state, buf[1000];
 
@@ -464,7 +464,7 @@ SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data)
        sr_session_send(sdi, &packet);
 
        if (++devc->frame >= devc->frame_limit)
-               hung_chang_dso_2100_dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        else
                hung_chang_dso_2100_move_to(sdi, 0x21);
 
index f210b650a3d6e1bea2e9f6327016e2abab3e9962..7168bd69ff9c0491e57d960ef838304240c7715e 100644 (file)
@@ -63,6 +63,5 @@ SR_PRIV void hung_chang_dso_2100_write_mbox(struct parport *port, uint8_t val);
 SR_PRIV uint8_t hung_chang_dso_2100_read_mbox(struct parport *port, float timeout);
 SR_PRIV int hung_chang_dso_2100_move_to(const struct sr_dev_inst *sdi, uint8_t target);
 SR_PRIV int hung_chang_dso_2100_poll(int fd, int revents, void *cb_data);
-SR_PRIV int hung_chang_dso_2100_dev_acquisition_stop(const struct sr_dev_inst *sdi);
 
 #endif
index c82422a553ed38dc1a6bf7c810130e6812727643..9ffd60da8672ca81ee009ebf8563b2ff2fbc843d 100644 (file)
@@ -443,11 +443,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
-       sr_dbg("Stopping acquisition.");
-
        sdi->status = SR_ST_STOPPING;
 
        return SR_OK;
index 4a9491b896ce2719f3d5f16f33c782958ac48d0a..439116cc69dc757c9b69cf1fee0c0ed6087ccef9 100644 (file)
@@ -43,8 +43,6 @@ static const char *channel_names[] = {
 /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */
 static const uint64_t samplerates[1] = { SR_MHZ(100) };
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static void clear_helper(void *priv)
 {
        struct dev_context *devc;
@@ -358,7 +356,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       sr_dbg("Stopping acquisition.");
        sr_session_source_remove(sdi->session, -1);
        std_session_send_df_end(sdi);
 
index 39dcfa2cd46ec7f16c37f908d25942dbfb4d23e1..c0e253626a67370b72afa060b6aa025946911bdb 100644 (file)
@@ -319,7 +319,7 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
        if (bytes_read < 0) {
                sr_err("Failed to read FTDI data (%d): %s.",
                       bytes_read, ftdi_get_error_string(devc->ftdic));
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return FALSE;
        }
        if (bytes_read == 0) {
@@ -358,12 +358,12 @@ SR_PRIV int scanaplus_receive_data(int fd, int revents, void *cb_data)
        if (devc->limit_samples && (n >= devc->limit_samples)) {
                send_samples(sdi, devc->limit_samples - devc->samples_sent);
                sr_info("Requested number of samples reached.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        } else if (devc->limit_msec && (n >= max)) {
                send_samples(sdi, max - devc->samples_sent);
                sr_info("Requested time limit reached.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        } else {
                send_samples(sdi, devc->bytes_received / 2);
index 30bb1b2a578bb05996817dae2655cedcaf61253b..2d1f97df79725a2f844d067696c889db0fc054fa 100644 (file)
@@ -478,9 +478,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct dev_context *devc;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        /* Signal USB transfer handler to clean up and stop. */
        sdi->status = SR_ST_STOPPING;
 
index 886be6f742c013e4bab8922179aa409288812ec6..1ee5c5e2f43bca66d3d2f22b0d7d32bcc98c3bd2 100644 (file)
@@ -67,7 +67,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
                        if (ret != 0 || len != 1) {
                                sr_dbg("Failed to request new acquisition: %s",
                                                libusb_error_name(ret));
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        }
                        libusb_submit_transfer(devc->xfer);
@@ -88,7 +88,7 @@ SR_PRIV int kecheng_kc_330b_handle_events(int fd, int revents, void *cb_data)
                if (ret != 0 || len != 4) {
                        sr_dbg("Failed to request next chunk: %s",
                                        libusb_error_name(ret));
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return TRUE;
                }
                libusb_submit_transfer(devc->xfer);
@@ -135,7 +135,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
        switch (transfer->status) {
        case LIBUSB_TRANSFER_NO_DEVICE:
                /* USB device was unplugged. */
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return;
        case LIBUSB_TRANSFER_COMPLETED:
        case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
@@ -156,7 +156,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
                        send_data(sdi, fvalue, 1);
                        devc->num_samples++;
                        if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                        } else {
                                /* let USB event handler fire off another
                                 * request when the time is right. */
@@ -176,7 +176,7 @@ SR_PRIV void LIBUSB_CALL kecheng_kc_330b_receive_transfer(struct libusb_transfer
                        send_data(sdi, fvalue, 1);
                        devc->num_samples += num_samples;
                        if (devc->num_samples >= devc->stored_samples) {
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                        } else {
                                /* let USB event handler fire off another
                                 * request when the time is right. */
index 97b557f9fdbd5cfafc826826a72adedcffb0a5a3..5d3541df46d7414a04d2984f64deff2c65794cd1 100644 (file)
@@ -125,7 +125,7 @@ SR_PRIV int kern_scale_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 4705403fb2c7e8d50ecc6974d9cdf041aa24b091..4aacd7cd1868270b926dac075b5e7366aec14901 100644 (file)
@@ -387,7 +387,7 @@ SR_PRIV int korad_kaxxxxp_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index 96ed3616f1b40c235bc849f17d73d9879b87f0e0..5ee1d22a838db6874be5d27b569d4f3caa1b8588 100644 (file)
@@ -395,13 +395,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
-SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi)
+static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device inactive, can't stop acquisition.");
-               return SR_ERR;
-       }
-
        sdi->status = SR_ST_STOPPING;
        /* TODO: free ongoing transfers? */
 
index fc24fbe77cd81780201ea786afdbc61d33a526f7..03fbf25210f5d91da339f52e2af054875a6229e0 100644 (file)
@@ -528,7 +528,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
        switch (transfer->status) {
        case LIBUSB_TRANSFER_NO_DEVICE:
                /* USB device was unplugged. */
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return;
        case LIBUSB_TRANSFER_COMPLETED:
        case LIBUSB_TRANSFER_TIMED_OUT: /* We may have received some data though */
@@ -547,7 +547,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
                                devc->rcvd_bytes, devc->log_size,
                                devc->rcvd_samples, devc->logged_samples);
                if (devc->rcvd_bytes >= devc->log_size)
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
        }
 
        if (sdi->status == SR_ST_ACTIVE) {
@@ -557,7 +557,7 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
                               libusb_error_name(ret));
                        g_free(transfer->buffer);
                        libusb_free_transfer(transfer);
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
        } else {
                /* This was the last transfer we're going to receive, so
index c4eec74b629288f844ece0ab8406456990b8a6d8..9e7b716783f94ea5a8d45158eac1c43ac2ca7764 100644 (file)
@@ -79,6 +79,5 @@ SR_PRIV void LIBUSB_CALL lascar_el_usb_receive_transfer(struct libusb_transfer *
 SR_PRIV int lascar_start_logging(const struct sr_dev_inst *sdi);
 SR_PRIV int lascar_stop_logging(const struct sr_dev_inst *sdi);
 SR_PRIV int lascar_is_logging(const struct sr_dev_inst *sdi);
-SR_PRIV int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
 #endif
index db423e4b749c29f01b2e7639bb3bf2308d4f571f..95c044f1f3de52ebfe33f4948cf81027600ca6ff 100644 (file)
@@ -488,9 +488,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        return lls_stop_acquisition(sdi);
 }
 
index 9dfb0b643f3f1325fb14e93a578ce7117e842ecd..2d4acf97485f6a16533691b90a76945c2355e2ab 100644 (file)
@@ -616,9 +616,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        std_session_send_df_end(sdi);
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        devc->num_frames = 0;
index ec7e958c932c871e79fbff32d03747cf0da41fdb..18c02061d4bf020a22e334475f52f361fb906b56 100644 (file)
@@ -662,7 +662,7 @@ SR_PRIV int lecroy_xstream_receive_data(int fd, int revents, void *cb_data)
         * the first enabled channel.
         */
        if (++devc->num_frames == devc->frame_limit) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else {
                devc->current_channel = devc->enabled_channels;
                lecroy_xstream_request_data(sdi);
index 29aacbdab0642b33b32df487f343df5b4cf9aa53..b0cb2d8a7ecb120d00260a2ebadd46dcbfb97644 100644 (file)
@@ -405,7 +405,7 @@ SR_PRIV int mso_receive_data(int fd, int revents, void *cb_data)
 
        if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
                sr_info("Requested number of samples reached.");
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        }
 
        return TRUE;
index d36e25042ccc93e2a9e59a7801ae3f3f48e6b1a4..19d581802582fe169ec442c3c3e00074347b4a09 100644 (file)
@@ -236,7 +236,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index 3ded72e9f49acabacc825dcff98bbb024dc2c9d3..127830cd634367261c3135c7be88f6fdec766b52 100644 (file)
@@ -455,9 +455,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        struct sr_modbus_dev_inst *modbus;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        std_session_send_df_end(sdi);
 
        modbus = sdi->conn;
index 04fa294835c564916c0ee8d9e18541e3ed21b01e..c369fa6ceab689532a253239ebc784a3257c2a8a 100644 (file)
@@ -196,7 +196,7 @@ SR_PRIV int maynuo_m97_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
index 65490537609f03f936f261f8ad12065e2621cfe9..af567ebd0987a993cebca585ee09d2ebe8025766 100644 (file)
@@ -210,7 +210,7 @@ static int receive_data(int fd, int revents, int idx, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 4de6f0e9d4b5fb7546fa85a17c172ffd943b602a..867cbb45197fca719b7c5d553548e9fc19446d81 100644 (file)
@@ -193,7 +193,7 @@ SR_PRIV int motech_lps_30x_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        /* Only request the next packet if required. */
        if (!((sdi->status == SR_ST_ACTIVE) && (devc->acq_running)))
index de31828a706bcdc1f96f5b7155347ee5526ae564..804fc36e37b77c5474bfd39467e38d4cb9267a4c 100644 (file)
@@ -417,7 +417,7 @@ SR_PRIV int norma_dmm_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits)) {
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else {
                /* Request next package. */
                if (devc->last_req_pending) {
index 6dc9deeb7da8c746f8fc19188f60cf6e4b3e9598..90c1986b69e1b9a18dadbaa02fe509fe3f400038 100644 (file)
@@ -82,7 +82,7 @@ static void send_data(const struct sr_dev_inst *sdi, float sample)
        devc->num_samples++;
        /* Limiting number of samples is only supported for live data. */
        if (devc->cur_data_source == DATA_SOURCE_LIVE && devc->limit_samples && devc->num_samples >= devc->limit_samples)
-               sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+               sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
 }
 
 static void process_measurement(const struct sr_dev_inst *sdi)
index 269b99f7c2c8287ac6173d81c37dbbd86169019b..bf7436065254ddd6564e4279373b120d33723a52 100644 (file)
@@ -682,7 +682,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       sr_dbg("Stopping acquisition.");
        write_shortcommand(devc, CMD_RESET);
        write_shortcommand(devc, CMD_RESET);
        write_shortcommand(devc, CMD_RESET);
index 9948944d2681703ceedac4306d49740bbbbc6c30..8276a9ed46f83aee4fb7ec4231ecc2a671a2e13f 100644 (file)
@@ -424,7 +424,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data)
                if (bytes_read < 0) {
                        sr_err("Failed to read FTDI data (%d): %s.",
                               bytes_read, ftdi_get_error_string(devc->ftdic));
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return FALSE;
                }
                if (bytes_read == 0) {
@@ -672,7 +672,7 @@ SR_PRIV int p_ols_receive_data(int fd, int revents, void *cb_data)
                }
                g_free(devc->raw_sample_buf);
 
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        }
 
        return TRUE;
index f58d150d02694cc0d32a6cb2c0cdbe2f29861a87..296d86776fc9295d991d9c2493fa34cae98f9911 100644 (file)
@@ -1119,11 +1119,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device inactive, can't stop acquisition.");
-               return SR_ERR;
-       }
-
        std_session_send_df_end(sdi);
 
        g_slist_free(devc->enabled_channels);
index 39462c280ba1830ec208ac5390cebaa1b64e9621..833104e890ddac4c74645a474b1a9077a011ffee 100644 (file)
@@ -634,7 +634,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                                sr_err("Read error, aborting capture.");
                                packet.type = SR_DF_FRAME_END;
                                sr_session_send(sdi, &packet);
-                               sdi->driver->dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                                return TRUE;
                        }
                        /* At slow timebases in live capture the DS2072
@@ -667,7 +667,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                sr_err("Read error, aborting capture.");
                packet.type = SR_DF_FRAME_END;
                sr_session_send(sdi, &packet);
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        }
 
@@ -727,7 +727,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
                        sr_err("Read should have been completed");
                        packet.type = SR_DF_FRAME_END;
                        sr_session_send(sdi, &packet);
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                        return TRUE;
                }
                devc->num_block_read = 0;
@@ -765,7 +765,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
 
                if (++devc->num_frames == devc->limit_frames) {
                        /* Last frame, stop capture. */
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                } else {
                        /* Get the next frame, starting with the first channel. */
                        devc->channel_entry = devc->enabled_channels;
index 8be8fb5066591a2c18857d8e16048ebfd669680f..1648c95268ba7441426b284d4fb67ac85f5be216 100644 (file)
@@ -399,9 +399,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        struct dev_context *devc = sdi->priv;
        struct drv_context *drvc = sdi->driver->context;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        saleae_logic_pro_stop(sdi);
 
        std_session_send_df_end(sdi);
index e6b752d1fcb3f7bc18d8a2425bdec5ba02b12e9c..f7430c212aec28e036a105f0f7a3783f41b6f88f 100644 (file)
@@ -775,9 +775,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
        int ret;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        ret = logic16_abort_acquisition(sdi);
 
        abort_acquisition(sdi->priv);
index 57bdcb81b7df9339c033e787ce1c95958c797fb3..c6bd3e591925d87d0dc117e944b5829e7091751e 100644 (file)
@@ -678,9 +678,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
        struct sr_scpi_dev_inst *scpi;
        float f;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        scpi = sdi->conn;
 
        /*
index 1d1ca4823208c5aaa86c1ac8495d6806d44779a2..39bd965bac1c7c8538fea893a76a31b19bfef7cb 100644 (file)
@@ -188,7 +188,7 @@ int receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 2b20db838e99cf5441f0bb40d415b63e94c9abce..1da4b00eb86698e4707996e0695a816f85701064 100644 (file)
@@ -759,12 +759,9 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        devc = sdi->priv;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        if (devc->state != STATE_IDLE && !devc->cancel_requested) {
                devc->cancel_requested = TRUE;
-               sr_dbg("Stopping acquisition.");
+               sr_dbg("Requesting cancel.");
        }
 
        return SR_OK;
index 88fbfac36838280303eaa2e2b2afa4c4d10276c2..d42da22b5621466418e3ae66f4f3df0e58757bfd 100644 (file)
@@ -221,7 +221,7 @@ SR_PRIV int teleinfo_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->sw_limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 90f589d73ecc019b77dd0bc0a4cd0d990e957d99..d04cce6f3ca8b87a8b6289d664e1466ece80d600 100644 (file)
@@ -22,7 +22,6 @@
 #include "protocol.h"
 
 #define SERIALCOMM "115200/8n1"
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
 
 static const uint32_t scanopts[] = {
        SR_CONF_CONN,
@@ -285,7 +284,7 @@ static void receive_data(struct sr_dev_inst *sdi, unsigned char *data, int len)
 
        devc->reply_size = 0;
        if (sr_sw_limits_check(&devc->sw_limits))
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        else
                testo_request_packet(sdi);
 
@@ -305,7 +304,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
 
        if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) {
                /* USB device was unplugged. */
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
                /* First two bytes in any transfer are FTDI status bytes. */
                if (transfer->actual_length > 2)
@@ -320,7 +319,7 @@ SR_PRIV void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
                               libusb_error_name(ret));
                        g_free(transfer->buffer);
                        libusb_free_transfer(transfer);
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
        } else {
                /* This was the last transfer we're going to receive, so
@@ -347,7 +346,7 @@ static int handle_events(int fd, int revents, void *cb_data)
        drvc = di->context;
 
        if (sr_sw_limits_check(&devc->sw_limits))
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        if (sdi->status == SR_ST_STOPPING) {
                usb_source_remove(sdi->session, drvc->sr_ctx);
@@ -412,9 +411,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        sdi->status = SR_ST_STOPPING;
 
        return SR_OK;
index 92bb286e1c1ca71d7dab29766918118e2369e4a6..3fc7806f0247df5a617cb0ba6041c9e1136b4b44 100644 (file)
@@ -158,7 +158,7 @@ SR_PRIV int testo_request_packet(const struct sr_dev_inst *sdi)
                        receive_transfer, (void *)sdi, 100);
        if ((ret = libusb_submit_transfer(devc->out_transfer) != 0)) {
                sr_err("Failed to request packet: %s.", libusb_error_name(ret));
-               sdi->driver->dev_acquisition_stop((struct sr_dev_inst *)sdi);
+               sr_dev_acquisition_stop((struct sr_dev_inst *)sdi);
                return SR_ERR;
        }
        sr_dbg("Requested new packet.");
index 589161652ed79ca6eb9446216c95665a589eca88..13f043056255b7d42fcbae3f1370e2486a615dd9 100644 (file)
@@ -205,7 +205,7 @@ SR_PRIV int tondaj_sl_814_receive_data(int fd, int revents, void *cb_data)
        }
 
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 2a2fc663f6c5208603c4159ce4472678b1a867b7..c6e0dd9adcbc59d5180037d811e6cab9019b2b38 100644 (file)
@@ -171,7 +171,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       sr_dbg("Stopping acquisition.");
        std_session_send_df_end(sdi);
        sr_session_source_remove(sdi->session, -1);
 
index c0ed21f3fbbfa687ff0f5b2ed6b0709c21cb76be..6dc8980e7f07aa935003d6adb21ec052be1cdc45 100644 (file)
@@ -290,7 +290,7 @@ SR_PRIV int uni_t_dmm_receive_data(int fd, int revents, void *cb_data)
 
        /* Abort acquisition if we acquired enough samples. */
        if (sr_sw_limits_check(&devc->limits))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 25f142b49d9da9a9ff60cacbf430c89c21b50c42..2df113c322f3e6017777d51a343f99cc5b4f0476 100644 (file)
@@ -296,9 +296,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        /* Signal USB transfer handler to clean up and stop. */
        sdi->status = SR_ST_STOPPING;
 
index a5d6f62b3351336d6d106059631a40bac50614e1..6e04dd9b9038731f0e26b0f1d608f1912abff3f9 100644 (file)
@@ -140,10 +140,8 @@ static void process_packet(struct sr_dev_inst *sdi)
         * a sample limit on "Memory" data source still works: unused
         * memory slots come through as "----" measurements. */
        devc->num_samples++;
-       if (devc->limit_samples && devc->num_samples >= devc->limit_samples) {
-               sdi->driver->dev_acquisition_stop(sdi);
-       }
-
+       if (devc->limit_samples && devc->num_samples >= devc->limit_samples)
+               sr_dev_acquisition_stop(sdi);
 }
 
 SR_PRIV void LIBUSB_CALL uni_t_ut32x_receive_transfer(struct libusb_transfer *transfer)
index ff0302d913ef9d9574bb24eb9e7ceff2270362ea..1ea102ced9c81ef839f8b73aab0fc0203785913a 100644 (file)
@@ -32,8 +32,6 @@
 #define VICTOR_INTERFACE 0
 #define VICTOR_ENDPOINT (LIBUSB_ENDPOINT_IN | 1)
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi);
-
 static const uint32_t drvopts[] = {
        SR_CONF_MULTIMETER,
 };
@@ -223,13 +221,13 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
        devc = sdi->priv;
        if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) {
                /* USB device was unplugged. */
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        } else if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
                sr_dbg("Got %d-byte packet.", transfer->actual_length);
                if (transfer->actual_length == DMM_DATA_SIZE) {
                        victor_dmm_receive_data(sdi, transfer->buffer);
                        if (sr_sw_limits_check(&devc->limits))
-                               dev_acquisition_stop(sdi);
+                               sr_dev_acquisition_stop(sdi);
                }
        }
        /* Anything else is either an error or a timeout, which is fine:
@@ -242,7 +240,7 @@ static void LIBUSB_CALL receive_transfer(struct libusb_transfer *transfer)
                               libusb_error_name(ret));
                        g_free(transfer->buffer);
                        libusb_free_transfer(transfer);
-                       dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
        } else {
                /* This was the last transfer we're going to receive, so
@@ -269,7 +267,7 @@ static int handle_events(int fd, int revents, void *cb_data)
        drvc = di->context;
 
        if (sr_sw_limits_check(&devc->limits))
-               dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        if (sdi->status == SR_ST_STOPPING) {
                usb_source_remove(sdi->session, drvc->sr_ctx);
@@ -324,11 +322,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
 static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 {
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("Device not active, can't stop acquisition.");
-               return SR_ERR;
-       }
-
        sdi->status = SR_ST_STOPPING;
 
        return SR_OK;
index c58906f85d352bc59014ca6171a74adc622f895b..e11587e6ced551c77a340893cd392ff19b3d5404 100644 (file)
@@ -660,9 +660,6 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
 
        std_session_send_df_end(sdi);
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        devc->num_frames = 0;
index cf885f7ac01f984493437ca563cba2c4a4f93bcd..6955baaeec23bf2e11f894d7247d21880c3d3231 100644 (file)
@@ -1171,7 +1171,7 @@ SR_PRIV int dlm_data_receive(int fd, int revents, void *cb_data)
                 * As of now we only support importing the current acquisition
                 * data so we're going to stop at this point.
                 */
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
                return TRUE;
        } else
                devc->current_channel = devc->current_channel->next;
index deff5a7b2a9b703203ccf011256647d68e25f8ea..6f467edb17278f09ca26981404f0af6085a7f4bf 100644 (file)
@@ -592,6 +592,25 @@ SR_PRIV void sr_config_free(struct sr_config *src)
 
 }
 
+/** @private */
+SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi)
+{
+       if (!sdi || !sdi->driver) {
+               sr_err("%s: Invalid arguments.", __func__);
+               return SR_ERR_ARG;
+       }
+
+       if (sdi->status != SR_ST_ACTIVE) {
+               sr_err("%s: Device instance not active, can't stop.",
+                       sdi->driver->name);
+               return SR_ERR_DEV_CLOSED;
+       }
+
+       sr_dbg("%s: Stopping acquisition.", sdi->driver->name);
+
+       return sdi->driver->dev_acquisition_stop(sdi);
+}
+
 static void log_key(const struct sr_dev_inst *sdi,
        const struct sr_channel_group *cg, uint32_t key, int op, GVariant *data)
 {
index 3a987c626928c1a62b1953077713383fa18b5bf0..9cd1c2da1f7223cc5e236a3e354745a61f89ace0 100644 (file)
@@ -731,7 +731,7 @@ static int receive_data(int fd, int revents, void *cb_data)
 
        if (dev_limit_counter_limit_reached(&devc->frame_count) ||
            dev_time_limit_reached(&devc->time_count))
-               sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
 
        return TRUE;
 }
index 73e49ef4106b9886cb38ae3401ff2d0ecea14b52..d8610f820ee5bc17ed792cf7cd071d0efcba2abb 100644 (file)
@@ -834,6 +834,7 @@ SR_PRIV int sr_variant_type_check(uint32_t key, GVariant *data);
 SR_PRIV void sr_hw_cleanup_all(const struct sr_context *ctx);
 SR_PRIV struct sr_config *sr_config_new(uint32_t key, GVariant *data);
 SR_PRIV void sr_config_free(struct sr_config *src);
+SR_PRIV int sr_dev_acquisition_stop(struct sr_dev_inst *sdi);
 
 /*--- session.c -------------------------------------------------------------*/
 
index c88e48c74e49c159c85fdc0e946d7774e4e3f1a2..1843fd17b9f58bf248a58a66b6852f960d5215af 100644 (file)
@@ -830,7 +830,7 @@ SR_API int sr_session_start(struct sr_session *session)
                lend = l->next;
                for (l = session->devs; l != lend; l = l->next) {
                        sdi = l->data;
-                       sdi->driver->dev_acquisition_stop(sdi);
+                       sr_dev_acquisition_stop(sdi);
                }
                /* TODO: Handle delayed stops. Need to iterate the event
                 * sources... */
@@ -913,8 +913,7 @@ static gboolean session_stop_sync(void *user_data)
 
        for (node = session->devs; node; node = node->next) {
                sdi = node->data;
-               if (sdi->driver && sdi->driver->dev_acquisition_stop)
-                       sdi->driver->dev_acquisition_stop(sdi);
+               sr_dev_acquisition_stop(sdi);
        }
 
        return G_SOURCE_REMOVE;
index 87b3f1f137d5950116aeaf1b8b91cd0127715567..bd748914df407edc02b86c341aa45890fd6b5f0f 100644 (file)
--- a/src/std.c
+++ b/src/std.c
@@ -217,13 +217,6 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi)
        const char *prefix = sdi->driver->name;
        int ret;
 
-       if (sdi->status != SR_ST_ACTIVE) {
-               sr_err("%s: Device inactive, can't stop acquisition.", prefix);
-               return SR_ERR_DEV_CLOSED;
-       }
-
-       sr_dbg("%s: Stopping acquisition.", prefix);
-
        if ((ret = serial_source_remove(sdi->session, serial)) < 0) {
                sr_err("%s: Failed to remove source: %d.", prefix, ret);
                return ret;