]> sigrok.org Git - libsigrok.git/commitdiff
rigol-ds: Get correct samplerate for Memory and Segmented sources
authorValentin Ochs <redacted>
Thu, 11 Jun 2020 16:14:17 +0000 (18:14 +0200)
committerUwe Hermann <redacted>
Wed, 24 Jun 2020 21:56:01 +0000 (23:56 +0200)
Read it at the start of acquisition. This prevents requests for
the SR from interfering with ongoing transfers.

This fixes bug #1217.

src/hardware/rigol-ds/api.c
src/hardware/rigol-ds/protocol.h

index e86c922e630167efba80f66b7939760d85796d21..af15587db2e36fef02c2a6c1963e01ad56e81542 100644 (file)
@@ -526,7 +526,6 @@ static int config_get(uint32_t key, GVariant **data,
        struct dev_context *devc;
        struct sr_channel *ch;
        const char *tmp_str;
-       uint64_t samplerate;
        int analog_channel = -1;
        float smallest_diff = INFINITY;
        int idx = -1;
@@ -570,14 +569,7 @@ static int config_get(uint32_t key, GVariant **data,
                        *data = g_variant_new_string("Segmented");
                break;
        case SR_CONF_SAMPLERATE:
-               if (devc->data_source == DATA_SOURCE_LIVE) {
-                       samplerate = analog_frame_size(sdi) /
-                               (devc->timebase * devc->model->series->num_horizontal_divs);
-                       *data = g_variant_new_uint64(samplerate);
-               } else {
-                       sr_dbg("Unknown data source: %d.", devc->data_source);
-                       return SR_ERR_NA;
-               }
+               *data = g_variant_new_uint64(devc->sample_rate);
                break;
        case SR_CONF_TRIGGER_SOURCE:
                if (!strcmp(devc->trigger_source, "ACL"))
@@ -990,6 +982,20 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        devc->channel_entry = devc->enabled_channels;
 
+       if (devc->data_source == DATA_SOURCE_LIVE)
+               devc->sample_rate = analog_frame_size(sdi) / 
+                       (devc->timebase * devc->model->series->num_horizontal_divs);
+       else {
+               float xinc;
+               if (devc->model->series->protocol >= PROTOCOL_V3 && 
+                               sr_scpi_get_float(sdi->conn, "WAV:XINC?", &xinc) != SR_OK) {
+                       sr_err("Couldn't get sampling rate");
+                       return SR_ERR;
+               }
+               devc->sample_rate = 1. / xinc;
+       }
+
+
        if (rigol_ds_capture_start(sdi) != SR_OK)
                return SR_ERR;
 
index a40c7ac178805e9225292fe07cc75a167d91daf5..ccecfabe45333c8aa0892ff955baa2aa0b5a43eb 100644 (file)
@@ -129,6 +129,7 @@ struct dev_context {
        gboolean digital_channels[MAX_DIGITAL_CHANNELS];
        gboolean la_enabled;
        float timebase;
+       float sample_rate;
        float attenuation[MAX_ANALOG_CHANNELS];
        float vdiv[MAX_ANALOG_CHANNELS];
        int vert_reference[MAX_ANALOG_CHANNELS];