X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Frigol-ds%2Fprotocol.c;h=201e0a31b920d6761c6c7104e01a52e14e3431cd;hb=cb828f1b3e00ccd0ad23d7cb98dca4d0d4749b07;hp=d9a53f547e67e598fb1a0c458828c509e8741798;hpb=c1aae90038456a61d0f9313d34e6107c3440d3e7;p=libsigrok.git
diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c
index d9a53f54..201e0a31 100644
--- a/src/hardware/rigol-ds/protocol.c
+++ b/src/hardware/rigol-ds/protocol.c
@@ -19,6 +19,7 @@
* along with this program. If not, see .
*/
+#include
#include
#include
#include
@@ -30,6 +31,7 @@
#include
#include
#include "libsigrok-internal.h"
+#include "scpi.h"
#include "protocol.h"
/*
@@ -175,7 +177,7 @@ static int rigol_ds_trigger_wait(const struct sr_dev_inst *sdi)
if (!(devc = sdi->priv))
return SR_ERR;
- /*
+ /*
* If timebase < 50 msecs/DIV just sleep about one sweep time except
* for really fast sweeps.
*/
@@ -218,11 +220,19 @@ static int rigol_ds_check_stop(const struct sr_dev_inst *sdi)
if (devc->model->series->protocol != PROTOCOL_V3)
return SR_OK;
- if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
- ch->index + 1) != SR_OK)
- return SR_ERR;
+ if (ch->type == SR_CHANNEL_LOGIC) {
+ if (rigol_ds_config_set(sdi, ":WAV:SOUR LA") != SR_OK)
+ return SR_ERR;
+ } else {
+ if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
+ ch->index + 1) != SR_OK)
+ return SR_ERR;
+ }
/* Check that the number of samples will be accepted */
- if (rigol_ds_config_set(sdi, ":WAV:POIN %d", devc->analog_frame_size) != SR_OK)
+ if (rigol_ds_config_set(sdi, ":WAV:POIN %d",
+ ch->type == SR_CHANNEL_LOGIC ?
+ devc->digital_frame_size :
+ devc->analog_frame_size) != SR_OK)
return SR_ERR;
if (sr_scpi_get_int(sdi->conn, "*ESR?", &tmp) != SR_OK)
return SR_ERR;
@@ -323,12 +333,22 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
struct dev_context *devc;
gchar *trig_mode;
unsigned int num_channels, i, j;
+ int buffer_samples;
if (!(devc = sdi->priv))
return SR_ERR;
- sr_dbg("Starting data capture for frameset %lu of %lu",
- devc->num_frames + 1, devc->limit_frames);
+ const gboolean first_frame = (devc->num_frames == 0);
+
+ uint64_t limit_frames = devc->limit_frames;
+ if (devc->num_frames_segmented != 0 && devc->num_frames_segmented < limit_frames)
+ limit_frames = devc->num_frames_segmented;
+ if (limit_frames == 0)
+ sr_dbg("Starting data capture for frameset %" PRIu64,
+ devc->num_frames + 1);
+ else
+ sr_dbg("Starting data capture for frameset %" PRIu64 " of %"
+ PRIu64, devc->num_frames + 1, limit_frames);
switch (devc->model->series->protocol) {
case PROTOCOL_V1:
@@ -355,19 +375,20 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
- if (rigol_ds_config_set(sdi, ":WAV:FORM BYTE") != SR_OK)
+ case PROTOCOL_V5:
+ if (first_frame && rigol_ds_config_set(sdi, ":WAV:FORM BYTE") != SR_OK)
return SR_ERR;
if (devc->data_source == DATA_SOURCE_LIVE) {
- if (rigol_ds_config_set(sdi, ":WAV:MODE NORM") != SR_OK)
+ if (first_frame && rigol_ds_config_set(sdi, ":WAV:MODE NORM") != SR_OK)
return SR_ERR;
devc->analog_frame_size = devc->model->series->live_samples;
devc->digital_frame_size = devc->model->series->live_samples;
rigol_ds_set_wait_event(devc, WAIT_TRIGGER);
} else {
if (devc->model->series->protocol == PROTOCOL_V3) {
- if (rigol_ds_config_set(sdi, ":WAV:MODE RAW") != SR_OK)
+ if (first_frame && rigol_ds_config_set(sdi, ":WAV:MODE RAW") != SR_OK)
return SR_ERR;
- } else if (devc->model->series->protocol == PROTOCOL_V4) {
+ } else if (devc->model->series->protocol >= PROTOCOL_V4) {
num_channels = 0;
/* Channels 3 and 4 are multiplexed with D0-7 and D8-15 */
@@ -384,17 +405,38 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
}
}
- devc->analog_frame_size = devc->digital_frame_size =
- num_channels == 1 ?
- devc->model->series->buffer_samples :
- num_channels == 2 ?
- devc->model->series->buffer_samples / 2 :
- devc->model->series->buffer_samples / 4;
+ buffer_samples = devc->model->series->buffer_samples;
+ if (first_frame && buffer_samples == 0)
+ {
+ /* The DS4000 series does not have a fixed memory depth, it
+ * can be chosen from the menu and also varies with number
+ * of active channels. Retrieve the actual number with the
+ * ACQ:MDEP command. */
+ sr_scpi_get_int(sdi->conn, "ACQ:MDEP?", &buffer_samples);
+ devc->analog_frame_size = devc->digital_frame_size =
+ buffer_samples;
+ }
+ else if (first_frame)
+ {
+ /* The DS1000Z series has a fixed memory depth which we
+ * need to divide correctly according to the number of
+ * active channels. */
+ devc->analog_frame_size = devc->digital_frame_size =
+ num_channels == 1 ?
+ buffer_samples :
+ num_channels == 2 ?
+ buffer_samples / 2 :
+ buffer_samples / 4;
+ }
}
- if (rigol_ds_config_set(sdi, ":SING") != SR_OK)
+ if (devc->data_source == DATA_SOURCE_LIVE && rigol_ds_config_set(sdi, ":SINGL") != SR_OK)
return SR_ERR;
rigol_ds_set_wait_event(devc, WAIT_STOP);
+ if (devc->data_source == DATA_SOURCE_SEGMENTED &&
+ devc->model->series->protocol <= PROTOCOL_V4)
+ if (rigol_ds_config_set(sdi, "FUNC:WREP:FCUR %d", devc->num_frames + 1) != SR_OK)
+ return SR_ERR;
}
break;
}
@@ -415,6 +457,8 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
sr_dbg("Starting reading data from channel %d", ch->index + 1);
+ const gboolean first_frame = (devc->num_frames == 0);
+
switch (devc->model->series->protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
@@ -429,9 +473,14 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
rigol_ds_set_wait_event(devc, WAIT_NONE);
break;
case PROTOCOL_V3:
- if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
- ch->index + 1) != SR_OK)
- return SR_ERR;
+ if (ch->type == SR_CHANNEL_LOGIC) {
+ if (rigol_ds_config_set(sdi, ":WAV:SOUR LA") != SR_OK)
+ return SR_ERR;
+ } else {
+ if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
+ ch->index + 1) != SR_OK)
+ return SR_ERR;
+ }
if (devc->data_source != DATA_SOURCE_LIVE) {
if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK)
return SR_ERR;
@@ -440,6 +489,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
}
break;
case PROTOCOL_V4:
+ case PROTOCOL_V5:
if (ch->type == SR_CHANNEL_ANALOG) {
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
ch->index + 1) != SR_OK)
@@ -450,19 +500,34 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
return SR_ERR;
}
- if (rigol_ds_config_set(sdi,
+ if (first_frame && rigol_ds_config_set(sdi,
devc->data_source == DATA_SOURCE_LIVE ?
":WAV:MODE NORM" :":WAV:MODE RAW") != SR_OK)
return SR_ERR;
+
+ if (devc->data_source != DATA_SOURCE_LIVE) {
+ if (rigol_ds_config_set(sdi, ":WAV:RES") != SR_OK)
+ return SR_ERR;
+ }
break;
}
if (devc->model->series->protocol >= PROTOCOL_V3 &&
ch->type == SR_CHANNEL_ANALOG) {
+ /* Vertical increment. */
+ if (first_frame && sr_scpi_get_float(sdi->conn, ":WAV:YINC?",
+ &devc->vert_inc[ch->index]) != SR_OK)
+ return SR_ERR;
+ /* Vertical origin. */
+ if (first_frame && sr_scpi_get_float(sdi->conn, ":WAV:YOR?",
+ &devc->vert_origin[ch->index]) != SR_OK)
+ return SR_ERR;
/* Vertical reference. */
- if (sr_scpi_get_int(sdi->conn, ":WAV:YREF?",
+ if (first_frame && sr_scpi_get_int(sdi->conn, ":WAV:YREF?",
&devc->vert_reference[ch->index]) != SR_OK)
return SR_ERR;
+ } else if (ch->type == SR_CHANNEL_ANALOG) {
+ devc->vert_inc[ch->index] = devc->vdiv[ch->index] / 25.6;
}
rigol_ds_set_wait_event(devc, WAIT_BLOCK);
@@ -538,8 +603,11 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
+ struct sr_analog_encoding encoding;
+ struct sr_analog_meaning meaning;
+ struct sr_analog_spec spec;
struct sr_datafeed_logic logic;
- double vdiv, offset;
+ double vdiv, offset, origin;
int len, i, vref;
struct sr_channel *ch;
gsize expected_data_bytes;
@@ -557,6 +625,8 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
if (!(revents == G_IO_IN || revents == 0))
return TRUE;
+ const gboolean first_frame = (devc->num_frames == 0);
+
switch (devc->wait_event) {
case WAIT_NONE:
break;
@@ -590,18 +660,21 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
if (devc->num_block_bytes == 0) {
if (devc->model->series->protocol >= PROTOCOL_V4) {
- if (sr_scpi_send(sdi->conn, ":WAV:START %d",
+ if (first_frame && rigol_ds_config_set(sdi, ":WAV:START %d",
devc->num_channel_bytes + 1) != SR_OK)
return TRUE;
- if (sr_scpi_send(sdi->conn, ":WAV:STOP %d",
+ if (first_frame && rigol_ds_config_set(sdi, ":WAV:STOP %d",
MIN(devc->num_channel_bytes + ACQ_BLOCK_SIZE,
devc->analog_frame_size)) != SR_OK)
return TRUE;
}
- if (devc->model->series->protocol >= PROTOCOL_V3)
+ if (devc->model->series->protocol >= PROTOCOL_V3) {
+ if (rigol_ds_config_set(sdi, ":WAV:BEG") != SR_OK)
+ return TRUE;
if (sr_scpi_send(sdi->conn, ":WAV:DATA?") != SR_OK)
return TRUE;
+ }
if (sr_scpi_read_begin(scpi) != SR_OK)
return TRUE;
@@ -613,22 +686,22 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
/* Still reading the header. */
return TRUE;
if (len == -1) {
- sr_err("Read error, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_err("Error while reading block header, aborting capture.");
+ std_session_send_df_frame_end(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}
- /* At slow timebases in live capture the DS2072
- * sometimes returns "short" data blocks, with
+ /* At slow timebases in live capture the DS2072 and
+ * DS1054Z sometimes return "short" data blocks, with
* apparently no way to get the rest of the data.
- * Discard these, the complete data block will
- * appear eventually.
+ * Discard these, the complete data block will appear
+ * eventually.
*/
if (devc->data_source == DATA_SOURCE_LIVE
&& (unsigned)len < expected_data_bytes) {
- sr_dbg("Discarding short data block");
+ sr_dbg("Discarding short data block: got %d/%d bytes\n", len, (int)expected_data_bytes);
sr_scpi_read_data(scpi, (char *)devc->buffer, len + 1);
+ devc->num_header_bytes = 0;
return TRUE;
}
devc->num_block_bytes = len;
@@ -646,10 +719,9 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
len = sr_scpi_read_data(scpi, (char *)devc->buffer, len);
if (len == -1) {
- sr_err("Read error, aborting capture.");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_err("Error while reading block data, aborting capture.");
+ std_session_send_df_frame_end(sdi);
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}
@@ -659,34 +731,38 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
if (ch->type == SR_CHANNEL_ANALOG) {
vref = devc->vert_reference[ch->index];
- vdiv = devc->vdiv[ch->index] / 25.6;
+ vdiv = devc->vert_inc[ch->index];
+ origin = devc->vert_origin[ch->index];
offset = devc->vert_offset[ch->index];
if (devc->model->series->protocol >= PROTOCOL_V3)
for (i = 0; i < len; i++)
- devc->data[i] = ((int)devc->buffer[i] - vref) * vdiv - offset;
+ devc->data[i] = ((int)devc->buffer[i] - vref - origin) * vdiv;
else
for (i = 0; i < len; i++)
devc->data[i] = (128 - devc->buffer[i]) * vdiv - offset;
- analog.channels = g_slist_append(NULL, ch);
+ float vdivlog = log10f(vdiv);
+ int digits = -(int)vdivlog + (vdivlog < 0.0);
+ sr_analog_init(&analog, &encoding, &meaning, &spec, digits);
+ analog.meaning->channels = g_slist_append(NULL, ch);
analog.num_samples = len;
analog.data = devc->data;
- analog.mq = SR_MQ_VOLTAGE;
- analog.unit = SR_UNIT_VOLT;
- analog.mqflags = 0;
+ analog.meaning->mq = SR_MQ_VOLTAGE;
+ analog.meaning->unit = SR_UNIT_VOLT;
+ analog.meaning->mqflags = 0;
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
- sr_session_send(cb_data, &packet);
- g_slist_free(analog.channels);
+ sr_session_send(sdi, &packet);
+ g_slist_free(analog.meaning->channels);
} else {
logic.length = len;
// TODO: For the MSO1000Z series, we need a way to express that
// this data is in fact just for a single channel, with the valid
// data for that channel in the LSB of each byte.
- logic.unitsize = devc->model->series->protocol == PROTOCOL_V4 ? 1 : 2;
+ logic.unitsize = devc->model->series->protocol >= PROTOCOL_V4 ? 1 : 2;
logic.data = devc->buffer;
packet.type = SR_DF_LOGIC;
packet.payload = &logic;
- sr_session_send(cb_data, &packet);
+ sr_session_send(sdi, &packet);
}
if (devc->num_block_read == devc->num_block_bytes) {
@@ -702,16 +778,13 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
if (devc->data_source != DATA_SOURCE_LIVE)
rigol_ds_set_wait_event(devc, WAIT_BLOCK);
}
- if (!sr_scpi_read_complete(scpi)) {
+ if (!sr_scpi_read_complete(scpi) && !devc->channel_entry->next) {
sr_err("Read should have been completed");
- packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
- return TRUE;
}
devc->num_block_read = 0;
} else {
- sr_dbg("%d of %d block bytes read", devc->num_block_read, devc->num_block_bytes);
+ sr_dbg("%" PRIu64 " of %" PRIu64 " block bytes read",
+ devc->num_block_read, devc->num_block_bytes);
}
devc->num_channel_bytes += len;
@@ -738,12 +811,28 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
rigol_ds_channel_start(sdi);
} else {
/* Done with this frame. */
- packet.type = SR_DF_FRAME_END;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_frame_end(sdi);
+
+ devc->num_frames++;
- if (++devc->num_frames == devc->limit_frames) {
+ /* V5 has no way to read the number of recorded frames, so try to set the
+ * next frame and read it back instead.
+ */
+ if (devc->data_source == DATA_SOURCE_SEGMENTED &&
+ devc->model->series->protocol == PROTOCOL_V5) {
+ int frames = 0;
+ if (rigol_ds_config_set(sdi, "REC:CURR %d", devc->num_frames + 1) != SR_OK)
+ return SR_ERR;
+ if (sr_scpi_get_int(sdi->conn, "REC:CURR?", &frames) != SR_OK)
+ return SR_ERR;
+ devc->num_frames_segmented = frames;
+ }
+
+ if (devc->num_frames == devc->limit_frames ||
+ devc->num_frames == devc->num_frames_segmented ||
+ devc->data_source == DATA_SOURCE_MEMORY) {
/* Last frame, stop capture. */
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ sr_dev_acquisition_stop(sdi);
} else {
/* Get the next frame, starting with the first channel. */
devc->channel_entry = devc->enabled_channels;
@@ -751,8 +840,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
rigol_ds_capture_start(sdi);
/* Start of next frame. */
- packet.type = SR_DF_FRAME_BEGIN;
- sr_session_send(cb_data, &packet);
+ std_session_send_df_frame_begin(sdi);
}
}
@@ -762,6 +850,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
{
struct dev_context *devc;
+ struct sr_channel *ch;
char *cmd;
unsigned int i;
int res;
@@ -775,6 +864,8 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
g_free(cmd);
if (res != SR_OK)
return SR_ERR;
+ ch = g_slist_nth_data(sdi->channels, i);
+ ch->enabled = devc->analog_channels[i];
}
sr_dbg("Current analog channel state:");
for (i = 0; i < devc->model->analog_channels; i++)
@@ -783,20 +874,25 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
/* Digital channel state. */
if (devc->model->has_digital) {
if (sr_scpi_get_bool(sdi->conn,
- devc->model->series->protocol >= PROTOCOL_V4 ?
+ devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT?" : ":LA:DISP?",
&devc->la_enabled) != SR_OK)
return SR_ERR;
sr_dbg("Logic analyzer %s, current digital channel state:",
devc->la_enabled ? "enabled" : "disabled");
for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
- cmd = g_strdup_printf(
- devc->model->series->protocol >= PROTOCOL_V4 ?
- ":LA:DIG%d:DISP?" : ":DIG%d:TURN?", i);
+ if (devc->model->series->protocol >= PROTOCOL_V5)
+ cmd = g_strdup_printf(":LA:DISP? D%d", i);
+ else if (devc->model->series->protocol >= PROTOCOL_V3)
+ cmd = g_strdup_printf(":LA:DIG%d:DISP?", i);
+ else
+ cmd = g_strdup_printf(":DIG%d:TURN?", i);
res = sr_scpi_get_bool(sdi->conn, cmd, &devc->digital_channels[i]);
g_free(cmd);
if (res != SR_OK)
return SR_ERR;
+ ch = g_slist_nth_data(sdi->channels, i + devc->model->analog_channels);
+ ch->enabled = devc->digital_channels[i];
sr_dbg("D%d: %s", i, devc->digital_channels[i] ? "on" : "off");
}
}
@@ -806,29 +902,35 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
return SR_ERR;
sr_dbg("Current timebase %g", devc->timebase);
- /* Vertical gain. */
+ /* Probe attenuation. */
for (i = 0; i < devc->model->analog_channels; i++) {
- cmd = g_strdup_printf(":CHAN%d:SCAL?", i + 1);
- res = sr_scpi_get_float(sdi->conn, cmd, &devc->vdiv[i]);
- g_free(cmd);
+ cmd = g_strdup_printf(":CHAN%d:PROB?", i + 1);
+
+ /* DSO1000B series prints an X after the probe factor, so
+ * we get a string and check for that instead of only handling
+ * floats. */
+ char *response;
+ res = sr_scpi_get_string(sdi->conn, cmd, &response);
if (res != SR_OK)
return SR_ERR;
- }
- sr_dbg("Current vertical gain:");
- for (i = 0; i < devc->model->analog_channels; i++)
- sr_dbg("CH%d %g", i + 1, devc->vdiv[i]);
- /* Vertical offset. */
- for (i = 0; i < devc->model->analog_channels; i++) {
- cmd = g_strdup_printf(":CHAN%d:OFFS?", i + 1);
- res = sr_scpi_get_float(sdi->conn, cmd, &devc->vert_offset[i]);
+ int len = strlen(response);
+ if (response[len-1] == 'X')
+ response[len-1] = 0;
+
+ res = sr_atof_ascii(response, &devc->attenuation[i]);
+ g_free(response);
g_free(cmd);
if (res != SR_OK)
return SR_ERR;
}
- sr_dbg("Current vertical offset:");
+ sr_dbg("Current probe attenuation:");
for (i = 0; i < devc->model->analog_channels; i++)
- sr_dbg("CH%d %g", i + 1, devc->vert_offset[i]);
+ sr_dbg("CH%d %g", i + 1, devc->attenuation[i]);
+
+ /* Vertical gain and offset. */
+ if (rigol_ds_get_dev_cfg_vertical(sdi) != SR_OK)
+ return SR_ERR;
/* Coupling. */
for (i = 0; i < devc->model->analog_channels; i++) {
@@ -848,7 +950,8 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
sr_dbg("Current trigger source %s", devc->trigger_source);
/* Horizontal trigger position. */
- if (sr_scpi_get_float(sdi->conn, ":TIM:OFFS?", &devc->horiz_triggerpos) != SR_OK)
+ if (sr_scpi_get_float(sdi->conn, devc->model->cmds[CMD_GET_HORIZ_TRIGGERPOS].str,
+ &devc->horiz_triggerpos) != SR_OK)
return SR_ERR;
sr_dbg("Current horizontal trigger position %g", devc->horiz_triggerpos);
@@ -857,5 +960,46 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)
return SR_ERR;
sr_dbg("Current trigger slope %s", devc->trigger_slope);
+ /* Trigger level. */
+ if (sr_scpi_get_float(sdi->conn, ":TRIG:EDGE:LEV?", &devc->trigger_level) != SR_OK)
+ return SR_ERR;
+ sr_dbg("Current trigger level %g", devc->trigger_level);
+
+ return SR_OK;
+}
+
+SR_PRIV int rigol_ds_get_dev_cfg_vertical(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ char *cmd;
+ unsigned int i;
+ int res;
+
+ devc = sdi->priv;
+
+ /* Vertical gain. */
+ for (i = 0; i < devc->model->analog_channels; i++) {
+ cmd = g_strdup_printf(":CHAN%d:SCAL?", i + 1);
+ res = sr_scpi_get_float(sdi->conn, cmd, &devc->vdiv[i]);
+ g_free(cmd);
+ if (res != SR_OK)
+ return SR_ERR;
+ }
+ sr_dbg("Current vertical gain:");
+ for (i = 0; i < devc->model->analog_channels; i++)
+ sr_dbg("CH%d %g", i + 1, devc->vdiv[i]);
+
+ /* Vertical offset. */
+ for (i = 0; i < devc->model->analog_channels; i++) {
+ cmd = g_strdup_printf(":CHAN%d:OFFS?", i + 1);
+ res = sr_scpi_get_float(sdi->conn, cmd, &devc->vert_offset[i]);
+ g_free(cmd);
+ if (res != SR_OK)
+ return SR_ERR;
+ }
+ sr_dbg("Current vertical offset:");
+ for (i = 0; i < devc->model->analog_channels; i++)
+ sr_dbg("CH%d %g", i + 1, devc->vert_offset[i]);
+
return SR_OK;
}