SR_CONF_TRIGGER_SLOPE,
SR_CONF_HORIZ_TRIGGERPOS,
SR_CONF_NUM_TIMEBASE,
+ SR_CONF_LIMIT_FRAMES,
+ SR_CONF_SAMPLERATE,
};
static const int32_t analog_hwcaps[] = {
#define AGILENT "Agilent Technologies"
static const struct rigol_ds_model supported_models[] = {
- {RIGOL, "DS1052E", RIGOL_DS1000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
- {RIGOL, "DS1102E", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
- {RIGOL, "DS1152E", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
- {RIGOL, "DS1052D", RIGOL_DS1000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
- {RIGOL, "DS1102D", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
- {RIGOL, "DS1152D", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
+ {RIGOL, "DS1052E", RIGOL_DS1000, PROTOCOL_IEEE488_2, {5, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
+ {RIGOL, "DS1102E", RIGOL_DS1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
+ {RIGOL, "DS1152E", RIGOL_DS1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
+ {RIGOL, "DS1052D", RIGOL_DS1000, PROTOCOL_IEEE488_2, {5, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
+ {RIGOL, "DS1102D", RIGOL_DS1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
+ {RIGOL, "DS1152D", RIGOL_DS1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 12},
{RIGOL, "DS2072", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, 2, false, 14},
{RIGOL, "DS2102", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, 2, false, 14},
{RIGOL, "DS2202", RIGOL_DS2000, PROTOCOL_IEEE488_2, {2, 1000000000}, {500, 1}, {500, 1000000}, 2, false, 14},
+ {RIGOL, "DS2302", RIGOL_DS2000, PROTOCOL_IEEE488_2, {1, 1000000000}, {1000, 1}, {500, 1000000}, 2, false, 14},
+ {RIGOL, "DS2072A", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {1000, 1}, {500, 1000000}, 2, false, 14},
+ {RIGOL, "DS2102A", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {1000, 1}, {500, 1000000}, 2, false, 14},
+ {RIGOL, "DS2202A", RIGOL_DS2000, PROTOCOL_IEEE488_2, {2, 1000000000}, {1000, 1}, {500, 1000000}, 2, false, 14},
+ {RIGOL, "DS2302A", RIGOL_DS2000, PROTOCOL_IEEE488_2, {1, 1000000000}, {1000, 1}, {500, 1000000}, 2, false, 14},
{RIGOL, "VS5022", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, 2, false, 14},
{RIGOL, "VS5022D", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, 2, true, 14},
{RIGOL, "VS5042", RIGOL_VS5000, PROTOCOL_LEGACY, {10, 1000000000}, {50, 1}, {2, 1000}, 2, false, 14},
{RIGOL, "VS5102D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 14},
{RIGOL, "VS5202", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 14},
{RIGOL, "VS5202D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, 2, true, 14},
+ {AGILENT, "DSO1002A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {5, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
+ {AGILENT, "DSO1004A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {5, 1000000000}, {50, 1}, {2, 1000}, 4, false, 12},
+ {AGILENT, "DSO1012A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
{AGILENT, "DSO1014A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 4, false, 12},
+ {AGILENT, "DSO1022A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 2, false, 12},
+ {AGILENT, "DSO1024A", AGILENT_DSO1000, PROTOCOL_IEEE488_2, {2, 1000000000}, {50, 1}, {2, 1000}, 4, false, 12},
};
SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
{
struct dev_context *devc;
struct sr_dev_inst *sdi;
- const char *usbtmc_prefix = "/dev/usbtmc";
- const char *tcp_prefix = "tcp/";
- gchar **tokens, *address, *port;
struct sr_scpi_dev_inst *scpi;
struct sr_scpi_hw_info *hw_info;
struct sr_probe *probe;
*devices = NULL;
- if (strncmp(resource, usbtmc_prefix, strlen(usbtmc_prefix)) == 0) {
- sr_dbg("Opening USBTMC device %s.", resource);
- if (!(scpi = scpi_usbtmc_dev_inst_new(resource)))
- return SR_ERR_MALLOC;
- } else if (strncmp(resource, tcp_prefix, strlen(tcp_prefix)) == 0) {
- sr_dbg("Opening TCP connection %s.", resource);
- tokens = g_strsplit(resource + strlen(tcp_prefix), "/", 0);
- address = tokens[0];
- port = tokens[1];
- if (!address || !port || tokens[2]) {
- sr_err("Invalid parameters.");
- g_strfreev(tokens);
- return SR_ERR_ARG;
- }
- scpi = scpi_tcp_dev_inst_new(address, port);
- g_strfreev(tokens);
- if (!scpi)
- return SR_ERR_MALLOC;
- } else {
- sr_dbg("Opening serial device %s.", resource);
- if (!(scpi = scpi_serial_dev_inst_new(resource, serialcomm)))
- return SR_ERR_MALLOC;
- }
+ if (!(scpi = scpi_dev_inst_new(resource, serialcomm)))
+ return SR_ERR;
if (sr_scpi_open(scpi) != SR_OK) {
sr_info("Couldn't open SCPI device.");
devc->num_timebases = &timebases[i] - devc->timebases + 1;
}
- for (i = 0; i < NUM_VDIV; i++) {
- if (!memcmp(&devc->model->min_vdiv, &vdivs[i], sizeof(uint64_t[2]))) {
+ for (i = 0; i < NUM_VDIV; i++)
+ if (!memcmp(&devc->model->min_vdiv, &vdivs[i], sizeof(uint64_t[2])))
devc->vdivs = &vdivs[i];
- devc->num_vdivs = NUM_VDIV - (&vdivs[i] - &vdivs[0]);
- }
- }
if (!(devc->buffer = g_try_malloc(ACQ_BUFFER_SIZE)))
return SR_ERR_MALLOC;
return dev_clear();
}
+static int analog_frame_size(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc = sdi->priv;
+ struct sr_probe *probe;
+ int analog_probes = 0;
+ GSList *l;
+
+ switch (devc->model->series) {
+ case RIGOL_VS5000:
+ return VS5000_ANALOG_LIVE_WAVEFORM_SIZE;
+ case RIGOL_DS1000:
+ return DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
+ default:
+ for (l = sdi->probes; l; l = l->next) {
+ probe = l->data;
+ if (probe->type == SR_PROBE_ANALOG && probe->enabled)
+ analog_probes++;
+ }
+ if (devc->data_source == DATA_SOURCE_MEMORY) {
+ if (analog_probes == 1)
+ return DS2000_ANALOG_MEM_WAVEFORM_SIZE_1C;
+ else
+ return DS2000_ANALOG_MEM_WAVEFORM_SIZE_2C;
+ } else {
+ if (devc->model->series == AGILENT_DSO1000)
+ return DSO1000_ANALOG_LIVE_WAVEFORM_SIZE;
+ else
+ return DS2000_ANALOG_LIVE_WAVEFORM_SIZE;
+ }
+ }
+}
+
+static int digital_frame_size(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc = sdi->priv;
+
+ switch (devc->model->series) {
+ case RIGOL_VS5000:
+ return VS5000_DIGITAL_WAVEFORM_SIZE;
+ case RIGOL_DS1000:
+ return DS1000_DIGITAL_WAVEFORM_SIZE;
+ default:
+ return 0;
+ }
+}
+
static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
const struct sr_probe_group *probe_group)
{
struct dev_context *devc;
- unsigned int i;
+ uint64_t samplerate;
if (!sdi || !(devc = sdi->priv))
return SR_ERR_ARG;
/* If a probe group is specified, it must be a valid one. */
- if (probe_group) {
- if (probe_group != &devc->analog_groups[0]
- && probe_group != &devc->analog_groups[1]) {
- sr_err("Invalid probe group specified.");
- return SR_ERR;
- }
+ if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) {
+ sr_err("Invalid probe group specified.");
+ return SR_ERR;
}
switch (id) {
case SR_CONF_NUM_TIMEBASE:
- *data = g_variant_new_int32(devc->num_timebases);
+ *data = g_variant_new_int32(devc->model->num_horizontal_divs);
break;
case SR_CONF_NUM_VDIV:
- if (!probe_group) {
- sr_err("No probe group specified.");
- return SR_ERR_PROBE_GROUP;
- }
- for (i = 0; i < 2; i++) {
- if (probe_group == &devc->analog_groups[i]) {
- *data = g_variant_new_int32(devc->num_vdivs);
- return SR_OK;
- }
- }
- return SR_ERR_NA;
+ *data = g_variant_new_int32(8);
case SR_CONF_DATA_SOURCE:
if (devc->data_source == DATA_SOURCE_LIVE)
*data = g_variant_new_string("Live");
else
*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->num_horizontal_divs);
+ *data = g_variant_new_uint64(samplerate);
+ } else {
+ return SR_ERR_NA;
+ }
+ break;
default:
return SR_ERR_NA;
}
return SR_ERR_DEV_CLOSED;
/* If a probe group is specified, it must be a valid one. */
- if (probe_group) {
- if (probe_group != &devc->analog_groups[0]
- && probe_group != &devc->analog_groups[1]) {
- sr_err("Invalid probe group specified.");
- return SR_ERR;
- }
+ if (probe_group && !g_slist_find(sdi->probe_groups, probe_group)) {
+ sr_err("Invalid probe group specified.");
+ return SR_ERR;
}
ret = SR_OK;
devc->data_source = DATA_SOURCE_LIVE;
else if (!strcmp(tmp_str, "Memory"))
devc->data_source = DATA_SOURCE_MEMORY;
- else if (devc->model->protocol == PROTOCOL_IEEE488_2
+ else if (devc->model->series >= RIGOL_DS1000Z
&& !strcmp(tmp_str, "Segmented"))
devc->data_source = DATA_SOURCE_SEGMENTED;
else
}
switch (key) {
- break;
case SR_CONF_DEVICE_OPTIONS:
if (!probe_group) {
sr_err("No probe group specified.");
return SR_ERR_PROBE_GROUP;
}
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
- for (i = 0; i < devc->num_vdivs; i++) {
+ for (i = 0; i < NUM_VDIV; i++) {
rational[0] = g_variant_new_uint64(devc->vdivs[i][0]);
rational[1] = g_variant_new_uint64(devc->vdivs[i][1]);
tuple = g_variant_new_tuple(rational, 2);
if (!devc)
/* Can't know this until we have the exact model. */
return SR_ERR_ARG;
+ if (devc->num_timebases <= 0)
+ return SR_ERR_NA;
g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
for (i = 0; i < devc->num_timebases; i++) {
rational[0] = g_variant_new_uint64(devc->timebases[i][0]);
scpi = sdi->conn;
devc = sdi->priv;
+ devc->num_frames = 0;
+
for (l = sdi->probes; l; l = l->next) {
probe = l->data;
sr_dbg("handling probe %s", probe->name);
if (set_cfg(sdi, ":CHAN%d:DISP %s", probe->index + 1,
probe->enabled ? "ON" : "OFF") != SR_OK)
return SR_ERR;
+ devc->analog_channels[probe->index] = probe->enabled;
}
} else if (probe->type == SR_PROBE_LOGIC) {
- if (probe->enabled)
+ if (probe->enabled) {
devc->enabled_digital_probes = g_slist_append(
devc->enabled_digital_probes, probe);
+ /* Turn on LA module if currently off. */
+ if (!devc->la_enabled) {
+ if (set_cfg(sdi, ":LA:DISP ON") != SR_OK)
+ return SR_ERR;
+ devc->la_enabled = TRUE;
+ }
+ }
if (probe->enabled != devc->digital_channels[probe->index]) {
/* Enabled channel is currently disabled, or vice versa. */
if (set_cfg(sdi, ":DIG%d:TURN %s", probe->index,
probe->enabled ? "ON" : "OFF") != SR_OK)
return SR_ERR;
+ devc->digital_channels[probe->index] = probe->enabled;
}
}
}
if (!devc->enabled_analog_probes && !devc->enabled_digital_probes)
return SR_ERR;
+ /* Turn off LA module if on and no digital probes selected. */
+ if (devc->la_enabled && !devc->enabled_digital_probes)
+ if (set_cfg(sdi, ":LA:DISP OFF") != SR_OK)
+ return SR_ERR;
+
if (devc->data_source == DATA_SOURCE_LIVE) {
if (set_cfg(sdi, ":RUN") != SR_OK)
return SR_ERR;
else
devc->channel_entry = devc->enabled_digital_probes;
- if (devc->model->protocol == PROTOCOL_LEGACY) {
- devc->analog_frame_size = (devc->model->series == RIGOL_VS5000 ?
- VS5000_ANALOG_LIVE_WAVEFORM_SIZE :
- DS1000_ANALOG_LIVE_WAVEFORM_SIZE);
+ devc->analog_frame_size = analog_frame_size(sdi);
+ devc->digital_frame_size = digital_frame_size(sdi);
+
+ if (devc->model->series < RIGOL_DS1000Z) {
/* Fetch the first frame. */
if (rigol_ds_channel_start(sdi) != SR_OK)
return SR_ERR;
} else {
if (devc->enabled_analog_probes) {
- if (devc->data_source == DATA_SOURCE_MEMORY)
- {
- if (g_slist_length(devc->enabled_analog_probes) == 1)
- devc->analog_frame_size = DS2000_ANALOG_MEM_WAVEFORM_SIZE_1C;
- else
- devc->analog_frame_size = DS2000_ANALOG_MEM_WAVEFORM_SIZE_2C;
+ if (devc->data_source == DATA_SOURCE_MEMORY) {
/* Apparently for the DS2000 the memory
* depth can only be set in Running state -
* this matches the behaviour of the UI. */
return SR_ERR;
if (set_cfg(sdi, ":STOP") != SR_OK)
return SR_ERR;
- } else {
- if (devc->model->series == AGILENT_DSO1000)
- devc->analog_frame_size = DSO1000_ANALOG_LIVE_WAVEFORM_SIZE;
- else
- devc->analog_frame_size = DS2000_ANALOG_LIVE_WAVEFORM_SIZE;
}
if (rigol_ds_capture_start(sdi) != SR_OK)
return SR_ERR;
{
struct dev_context *devc;
struct sr_scpi_dev_inst *scpi;
+ struct sr_datafeed_packet packet;
(void)cb_data;
return SR_ERR;
}
+ /* End of last frame. */
+ packet.type = SR_DF_END;
+ sr_session_send(sdi, &packet);
+
g_slist_free(devc->enabled_analog_probes);
g_slist_free(devc->enabled_digital_probes);
devc->enabled_analog_probes = NULL;