rigol-ds: Get correct samplerate for Memory and Segmented sources

Read it at the start of acquisition. This prevents requests for
the SR from interfering with ongoing transfers.

This fixes bug #1217.
This commit is contained in:
Valentin Ochs 2020-06-11 18:14:17 +02:00 committed by Uwe Hermann
parent 418c99248c
commit 1cbb3b1cfb
2 changed files with 16 additions and 9 deletions

View 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;

View 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];