]> sigrok.org Git - libsigrok.git/blobdiff - hardware/rigol-ds/api.c
rigol-ds: Use rigol_ds_channel_start() function for legacy protocol too.
[libsigrok.git] / hardware / rigol-ds / api.c
index 8af03eb6970626e3482d3ef1d2b51cc7fafe179a..5a78b67ce38ddb690307c8ed9eb1f2c9a073c4e5 100644 (file)
@@ -279,6 +279,7 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
 
        if (strcasecmp(hw_info->manufacturer, "Rigol Technologies")) {
                sr_scpi_hw_info_free(hw_info);
+               sr_scpi_close(scpi);
                sr_scpi_free(scpi);
                return SR_ERR_NA;
        }
@@ -294,11 +295,13 @@ static int probe_port(const char *resource, const char *serialcomm, GSList **dev
                                              hw_info->manufacturer, hw_info->model,
                                                  hw_info->firmware_version))) {
                sr_scpi_hw_info_free(hw_info);
+               sr_scpi_close(scpi);
                sr_scpi_free(scpi);
                return SR_ERR_NA;
        }
 
        sr_scpi_hw_info_free(hw_info);
+       sr_scpi_close(scpi);
 
        sdi->conn = scpi;
 
@@ -836,20 +839,14 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
        std_session_send_df_header(cb_data, LOG_PREFIX);
 
        if (devc->model->protocol == PROTOCOL_LEGACY) {
+               devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
                /* Fetch the first frame. */
-               if (devc->enabled_analog_probes) {
-                       devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
-                       devc->channel_frame = devc->enabled_analog_probes->data;
-                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d",
-                                       devc->channel_frame->index + 1) != SR_OK)
-                               return SR_ERR;
-               } else {
-                       devc->channel_frame = devc->enabled_digital_probes->data;
-                       if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
-                               return SR_ERR;
-               }
-
-               devc->num_frame_bytes = 0;
+               if (devc->enabled_analog_probes)
+                       devc->channel = devc->enabled_analog_probes->data;
+               else
+                       devc->channel = devc->enabled_digital_probes->data;
+               if (rigol_ds_channel_start(sdi) != SR_OK)
+                       return SR_ERR;
        } else {
                if (devc->enabled_analog_probes) {
                        if (devc->data_source == DATA_SOURCE_MEMORY)
@@ -869,7 +866,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
                                        return SR_ERR;
                        } else
                                devc->analog_frame_size = DS2000_ANALOG_LIVE_WAVEFORM_SIZE;
-                       devc->channel_frame = devc->enabled_analog_probes->data;
+                       devc->channel = devc->enabled_analog_probes->data;
                        if (rigol_ds_capture_start(sdi) != SR_OK)
                                return SR_ERR;
                }