2 * This file is part of the libsigrok project.
4 * Copyright (C) 2012 Martin Ling <martin-git@earth.li>
5 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
6 * Copyright (C) 2013 Mathias Grimmberger <mgri@zaphod.sax.de>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "libsigrok.h"
28 #include "libsigrok-internal.h"
31 static const int32_t hwopts[] = {
36 static const int32_t hwcaps[] = {
39 SR_CONF_TRIGGER_SOURCE,
40 SR_CONF_TRIGGER_SLOPE,
41 SR_CONF_HORIZ_TRIGGERPOS,
45 static const int32_t analog_hwcaps[] = {
52 static const uint64_t timebases[][2] = {
91 /* { 1000, 1 }, Confuses other code? */
94 static const uint64_t vdivs[][2] = {
114 #define NUM_TIMEBASE ARRAY_SIZE(timebases)
115 #define NUM_VDIV ARRAY_SIZE(vdivs)
117 static const char *trigger_sources[] = {
140 static const char *coupling[] = {
146 /* Do not change the order of entries */
147 static const char *data_sources[] = {
154 * name, series, protocol flavor, min timebase, max timebase, min vdiv,
155 * digital channels, number of horizontal divs
157 static const struct rigol_ds_model supported_models[] = {
158 {"DS1052E", RIGOL_DS1000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, false, 12},
159 {"DS1102E", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 12},
160 {"DS1152E", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 12},
161 {"DS1052D", RIGOL_DS1000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, true, 12},
162 {"DS1102D", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 12},
163 {"DS1152D", RIGOL_DS1000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 12},
164 {"DS2072", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
165 {"DS2102", RIGOL_DS2000, PROTOCOL_IEEE488_2, {5, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
166 {"DS2202", RIGOL_DS2000, PROTOCOL_IEEE488_2, {2, 1000000000}, {500, 1}, {500, 1000000}, false, 14},
167 {"VS5022", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, false, 14},
168 {"VS5022D", RIGOL_VS5000, PROTOCOL_LEGACY, {20, 1000000000}, {50, 1}, {2, 1000}, true, 14},
169 {"VS5042", RIGOL_VS5000, PROTOCOL_LEGACY, {10, 1000000000}, {50, 1}, {2, 1000}, false, 14},
170 {"VS5042D", RIGOL_VS5000, PROTOCOL_LEGACY, {10, 1000000000}, {50, 1}, {2, 1000}, true, 14},
171 {"VS5062", RIGOL_VS5000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, false, 14},
172 {"VS5062D", RIGOL_VS5000, PROTOCOL_LEGACY, {5, 1000000000}, {50, 1}, {2, 1000}, true, 14},
173 {"VS5102", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 14},
174 {"VS5102D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 14},
175 {"VS5202", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, false, 14},
176 {"VS5202D", RIGOL_VS5000, PROTOCOL_LEGACY, {2, 1000000000}, {50, 1}, {2, 1000}, true, 14},
179 SR_PRIV struct sr_dev_driver rigol_ds_driver_info;
180 static struct sr_dev_driver *di = &rigol_ds_driver_info;
182 static void clear_helper(void *priv)
184 struct dev_context *devc;
188 g_free(devc->buffer);
189 g_free(devc->coupling[0]);
190 g_free(devc->coupling[1]);
191 g_free(devc->trigger_source);
192 g_free(devc->trigger_slope);
193 g_slist_free(devc->analog_groups[0].probes);
194 g_slist_free(devc->analog_groups[1].probes);
195 g_slist_free(devc->digital_group.probes);
198 static int dev_clear(void)
200 return std_dev_clear(di, clear_helper);
203 static int set_cfg(const struct sr_dev_inst *sdi, const char *format, ...)
208 va_start(args, format);
209 ret = sr_scpi_send_variadic(sdi->conn, format, args);
215 /* When setting a bunch of parameters in a row, the DS1052E scrambles
216 * some of them unless there is at least 100ms delay in between. */
217 sr_spew("delay %dms", 100);
223 static int init(struct sr_context *sr_ctx)
225 return std_init(sr_ctx, di, LOG_PREFIX);
228 static int probe_port(const char *resource, const char *serialcomm, GSList **devices)
230 struct dev_context *devc;
231 struct sr_dev_inst *sdi;
232 const char *usbtmc_prefix = "/dev/usbtmc";
233 const char *tcp_prefix = "tcp/";
234 gchar **tokens, *address, *port;
235 struct sr_scpi_dev_inst *scpi;
236 struct sr_scpi_hw_info *hw_info;
237 struct sr_probe *probe;
239 const struct rigol_ds_model *model = NULL;
244 if (strncmp(resource, usbtmc_prefix, strlen(usbtmc_prefix)) == 0) {
245 sr_dbg("Opening USBTMC device %s.", resource);
246 if (!(scpi = scpi_usbtmc_dev_inst_new(resource)))
247 return SR_ERR_MALLOC;
248 } else if (strncmp(resource, tcp_prefix, strlen(tcp_prefix)) == 0) {
249 sr_dbg("Opening TCP connection %s.", resource);
250 tokens = g_strsplit(resource + strlen(tcp_prefix), "/", 0);
253 if (!address || !port || tokens[2]) {
254 sr_err("Invalid parameters.");
258 scpi = scpi_tcp_dev_inst_new(address, port);
261 return SR_ERR_MALLOC;
263 sr_dbg("Opening serial device %s.", resource);
264 if (!(scpi = scpi_serial_dev_inst_new(resource, serialcomm)))
265 return SR_ERR_MALLOC;
268 if (sr_scpi_open(scpi) != SR_OK) {
273 if (sr_scpi_get_hw_id(scpi, &hw_info) != SR_OK) {
274 sr_info("Couldn't get IDN response.");
280 if (strcasecmp(hw_info->manufacturer, "Rigol Technologies")) {
281 sr_scpi_hw_info_free(hw_info);
287 for (i = 0; i < ARRAY_SIZE(supported_models); i++) {
288 if (!strcmp(hw_info->model, supported_models[i].name)) {
289 model = &supported_models[i];
294 if (!model || !(sdi = sr_dev_inst_new(0, SR_ST_ACTIVE,
295 hw_info->manufacturer, hw_info->model,
296 hw_info->firmware_version))) {
297 sr_scpi_hw_info_free(hw_info);
303 sr_scpi_hw_info_free(hw_info);
309 sdi->inst_type = SR_INST_SCPI;
311 if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
312 return SR_ERR_MALLOC;
314 devc->limit_frames = 0;
317 for (i = 0; i < 2; i++) {
318 channel_name = (i == 0 ? "CH1" : "CH2");
319 if (!(probe = sr_probe_new(i, SR_PROBE_ANALOG, TRUE, channel_name)))
320 return SR_ERR_MALLOC;
321 sdi->probes = g_slist_append(sdi->probes, probe);
322 devc->analog_groups[i].name = channel_name;
323 devc->analog_groups[i].probes = g_slist_append(NULL, probe);
324 sdi->probe_groups = g_slist_append(sdi->probe_groups,
325 &devc->analog_groups[i]);
328 if (devc->model->has_digital) {
329 for (i = 0; i < 16; i++) {
330 if (!(channel_name = g_strdup_printf("D%d", i)))
331 return SR_ERR_MALLOC;
332 probe = sr_probe_new(i, SR_PROBE_LOGIC, TRUE, channel_name);
333 g_free(channel_name);
335 return SR_ERR_MALLOC;
336 sdi->probes = g_slist_append(sdi->probes, probe);
337 devc->digital_group.probes = g_slist_append(
338 devc->digital_group.probes, probe);
340 devc->digital_group.name = "LA";
341 sdi->probe_groups = g_slist_append(sdi->probe_groups,
342 &devc->digital_group);
345 for (i = 0; i < NUM_TIMEBASE; i++) {
346 if (!memcmp(&devc->model->min_timebase, &timebases[i], sizeof(uint64_t[2])))
347 devc->timebases = &timebases[i];
348 if (!memcmp(&devc->model->max_timebase, &timebases[i], sizeof(uint64_t[2])))
349 devc->num_timebases = &timebases[i] - devc->timebases + 1;
352 for (i = 0; i < NUM_VDIV; i++) {
353 if (!memcmp(&devc->model->min_vdiv, &vdivs[i], sizeof(uint64_t[2]))) {
354 devc->vdivs = &vdivs[i];
355 devc->num_vdivs = NUM_VDIV - (&vdivs[i] - &vdivs[0]);
359 if (!(devc->buffer = g_try_malloc(ACQ_BUFFER_SIZE)))
360 return SR_ERR_MALLOC;
361 if (!(devc->data = g_try_malloc(ACQ_BUFFER_SIZE * sizeof(float))))
362 return SR_ERR_MALLOC;
364 devc->data_source = DATA_SOURCE_LIVE;
368 *devices = g_slist_append(NULL, sdi);
373 static GSList *scan(GSList *options)
375 struct drv_context *drvc;
376 struct sr_config *src;
380 const gchar *dev_name;
382 gchar *serialcomm = NULL;
386 for (l = options; l; l = l->next) {
390 port = (char *)g_variant_get_string(src->data, NULL);
392 case SR_CONF_SERIALCOMM:
393 serialcomm = (char *)g_variant_get_string(src->data, NULL);
400 if (probe_port(port, serialcomm, &devices) == SR_ERR_MALLOC) {
407 if (!(dir = g_dir_open("/sys/class/usbmisc/", 0, NULL)))
408 if (!(dir = g_dir_open("/sys/class/usb/", 0, NULL)))
410 while ((dev_name = g_dir_read_name(dir))) {
411 if (strncmp(dev_name, "usbtmc", 6))
413 port = g_strconcat("/dev/", dev_name, NULL);
414 ret = probe_port(port, serialcomm, &devices);
418 if (ret == SR_ERR_MALLOC) {
426 /* Tack a copy of the newly found devices onto the driver list. */
427 l = g_slist_copy(devices);
428 drvc->instances = g_slist_concat(drvc->instances, l);
433 static GSList *dev_list(void)
435 return ((struct drv_context *)(di->priv))->instances;
438 static int dev_open(struct sr_dev_inst *sdi)
440 struct sr_scpi_dev_inst *scpi = sdi->conn;
442 if (sr_scpi_open(scpi) < 0)
445 if (rigol_ds_get_dev_cfg(sdi) != SR_OK)
448 sdi->status = SR_ST_ACTIVE;
453 static int dev_close(struct sr_dev_inst *sdi)
455 struct sr_scpi_dev_inst *scpi;
460 if (sr_scpi_close(scpi) < 0)
462 sdi->status = SR_ST_INACTIVE;
468 static int cleanup(void)
473 static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,
474 const struct sr_probe_group *probe_group)
476 struct dev_context *devc;
479 if (!sdi || !(devc = sdi->priv))
482 /* If a probe group is specified, it must be a valid one. */
484 if (probe_group != &devc->analog_groups[0]
485 && probe_group != &devc->analog_groups[1]) {
486 sr_err("Invalid probe group specified.");
492 case SR_CONF_NUM_TIMEBASE:
493 *data = g_variant_new_int32(devc->num_timebases);
495 case SR_CONF_NUM_VDIV:
497 sr_err("No probe group specified.");
498 return SR_ERR_PROBE_GROUP;
500 for (i = 0; i < 2; i++) {
501 if (probe_group == &devc->analog_groups[i]) {
502 *data = g_variant_new_int32(devc->num_vdivs);
507 case SR_CONF_DATA_SOURCE:
508 if (devc->data_source == DATA_SOURCE_LIVE)
509 *data = g_variant_new_string("Live");
510 else if (devc->data_source == DATA_SOURCE_MEMORY)
511 *data = g_variant_new_string("Memory");
513 *data = g_variant_new_string("Segmented");
522 static int config_set(int id, GVariant *data, const struct sr_dev_inst *sdi,
523 const struct sr_probe_group *probe_group)
525 struct dev_context *devc;
526 uint64_t tmp_u64, p, q;
532 if (!(devc = sdi->priv))
535 if (sdi->status != SR_ST_ACTIVE)
536 return SR_ERR_DEV_CLOSED;
538 /* If a probe group is specified, it must be a valid one. */
540 if (probe_group != &devc->analog_groups[0]
541 && probe_group != &devc->analog_groups[1]) {
542 sr_err("Invalid probe group specified.");
549 case SR_CONF_LIMIT_FRAMES:
550 devc->limit_frames = g_variant_get_uint64(data);
552 case SR_CONF_TRIGGER_SLOPE:
553 tmp_u64 = g_variant_get_uint64(data);
554 if (tmp_u64 != 0 && tmp_u64 != 1)
556 g_free(devc->trigger_slope);
557 devc->trigger_slope = g_strdup(tmp_u64 ? "POS" : "NEG");
558 ret = set_cfg(sdi, ":TRIG:EDGE:SLOP %s", devc->trigger_slope);
560 case SR_CONF_HORIZ_TRIGGERPOS:
561 t_dbl = g_variant_get_double(data);
562 if (t_dbl < 0.0 || t_dbl > 1.0)
564 devc->horiz_triggerpos = t_dbl;
565 /* We have the trigger offset as a percentage of the frame, but
566 * need to express this in seconds. */
567 t_dbl = -(devc->horiz_triggerpos - 0.5) * devc->timebase * devc->num_timebases;
568 ret = set_cfg(sdi, ":TIM:OFFS %.6f", t_dbl);
570 case SR_CONF_TIMEBASE:
571 g_variant_get(data, "(tt)", &p, &q);
572 for (i = 0; i < devc->num_timebases; i++) {
573 if (devc->timebases[i][0] == p && devc->timebases[i][1] == q) {
574 devc->timebase = (float)p / q;
575 ret = set_cfg(sdi, ":TIM:SCAL %.9f", devc->timebase);
579 if (i == devc->num_timebases)
582 case SR_CONF_TRIGGER_SOURCE:
583 tmp_str = g_variant_get_string(data, NULL);
584 for (i = 0; i < ARRAY_SIZE(trigger_sources); i++) {
585 if (!strcmp(trigger_sources[i], tmp_str)) {
586 g_free(devc->trigger_source);
587 devc->trigger_source = g_strdup(trigger_sources[i]);
588 if (!strcmp(devc->trigger_source, "AC Line"))
590 else if (!strcmp(devc->trigger_source, "CH1"))
592 else if (!strcmp(devc->trigger_source, "CH2"))
595 tmp_str = (char *)devc->trigger_source;
596 ret = set_cfg(sdi, ":TRIG:EDGE:SOUR %s", tmp_str);
600 if (i == ARRAY_SIZE(trigger_sources))
605 sr_err("No probe group specified.");
606 return SR_ERR_PROBE_GROUP;
608 g_variant_get(data, "(tt)", &p, &q);
609 for (i = 0; i < 2; i++) {
610 if (probe_group == &devc->analog_groups[i]) {
611 for (j = 0; j < ARRAY_SIZE(vdivs); j++) {
612 if (vdivs[j][0] != p || vdivs[j][1] != q)
614 devc->vdiv[i] = (float)p / q;
615 return set_cfg(sdi, ":CHAN%d:SCAL %.3f", i + 1,
622 case SR_CONF_COUPLING:
624 sr_err("No probe group specified.");
625 return SR_ERR_PROBE_GROUP;
627 tmp_str = g_variant_get_string(data, NULL);
628 for (i = 0; i < 2; i++) {
629 if (probe_group == &devc->analog_groups[i]) {
630 for (j = 0; j < ARRAY_SIZE(coupling); j++) {
631 if (!strcmp(tmp_str, coupling[j])) {
632 g_free(devc->coupling[i]);
633 devc->coupling[i] = g_strdup(coupling[j]);
634 return set_cfg(sdi, ":CHAN%d:COUP %s", i + 1,
642 case SR_CONF_DATA_SOURCE:
643 tmp_str = g_variant_get_string(data, NULL);
644 if (!strcmp(tmp_str, "Live"))
645 devc->data_source = DATA_SOURCE_LIVE;
646 else if (!strcmp(tmp_str, "Memory"))
647 devc->data_source = DATA_SOURCE_MEMORY;
648 else if (devc->model->protocol == PROTOCOL_IEEE488_2
649 && !strcmp(tmp_str, "Segmented"))
650 devc->data_source = DATA_SOURCE_SEGMENTED;
662 static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
663 const struct sr_probe_group *probe_group)
665 GVariant *tuple, *rational[2];
668 struct dev_context *devc = NULL;
673 if (key == SR_CONF_SCAN_OPTIONS) {
674 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
675 hwopts, ARRAY_SIZE(hwopts), sizeof(int32_t));
677 } else if (key == SR_CONF_DEVICE_OPTIONS && probe_group == NULL) {
678 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
679 hwcaps, ARRAY_SIZE(hwcaps), sizeof(int32_t));
683 /* Every other option requires a valid device instance. */
684 if (!sdi || !(devc = sdi->priv))
687 /* If a probe group is specified, it must be a valid one. */
689 if (probe_group != &devc->analog_groups[0]
690 && probe_group != &devc->analog_groups[1]) {
691 sr_err("Invalid probe group specified.");
698 case SR_CONF_DEVICE_OPTIONS:
700 sr_err("No probe group specified.");
701 return SR_ERR_PROBE_GROUP;
703 if (probe_group == &devc->digital_group) {
704 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
705 NULL, 0, sizeof(int32_t));
708 for (i = 0; i < 2; i++) {
709 if (probe_group == &devc->analog_groups[i]) {
710 *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
711 analog_hwcaps, ARRAY_SIZE(analog_hwcaps), sizeof(int32_t));
718 case SR_CONF_COUPLING:
720 sr_err("No probe group specified.");
721 return SR_ERR_PROBE_GROUP;
723 *data = g_variant_new_strv(coupling, ARRAY_SIZE(coupling));
727 /* Can't know this until we have the exact model. */
730 sr_err("No probe group specified.");
731 return SR_ERR_PROBE_GROUP;
733 g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
734 for (i = 0; i < devc->num_vdivs; i++) {
735 rational[0] = g_variant_new_uint64(devc->vdivs[i][0]);
736 rational[1] = g_variant_new_uint64(devc->vdivs[i][1]);
737 tuple = g_variant_new_tuple(rational, 2);
738 g_variant_builder_add_value(&gvb, tuple);
740 *data = g_variant_builder_end(&gvb);
742 case SR_CONF_TIMEBASE:
744 /* Can't know this until we have the exact model. */
746 g_variant_builder_init(&gvb, G_VARIANT_TYPE_ARRAY);
747 for (i = 0; i < devc->num_timebases; i++) {
748 rational[0] = g_variant_new_uint64(devc->timebases[i][0]);
749 rational[1] = g_variant_new_uint64(devc->timebases[i][1]);
750 tuple = g_variant_new_tuple(rational, 2);
751 g_variant_builder_add_value(&gvb, tuple);
753 *data = g_variant_builder_end(&gvb);
755 case SR_CONF_TRIGGER_SOURCE:
757 /* Can't know this until we have the exact model. */
759 *data = g_variant_new_strv(trigger_sources,
760 devc->model->has_digital ? ARRAY_SIZE(trigger_sources) : 4);
762 case SR_CONF_DATA_SOURCE:
764 /* Can't know this until we have the exact model. */
766 /* This needs tweaking by series/model! */
767 if (devc->model->series == RIGOL_DS2000)
768 *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources));
770 *data = g_variant_new_strv(data_sources, ARRAY_SIZE(data_sources) - 1);
779 static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
781 struct sr_scpi_dev_inst *scpi;
782 struct dev_context *devc;
783 struct sr_probe *probe;
786 if (sdi->status != SR_ST_ACTIVE)
787 return SR_ERR_DEV_CLOSED;
792 for (l = sdi->probes; l; l = l->next) {
794 sr_dbg("handling probe %s", probe->name);
795 if (probe->type == SR_PROBE_ANALOG) {
797 devc->enabled_analog_probes = g_slist_append(
798 devc->enabled_analog_probes, probe);
799 if (probe->enabled != devc->analog_channels[probe->index]) {
800 /* Enabled channel is currently disabled, or vice versa. */
801 if (set_cfg(sdi, ":CHAN%d:DISP %s", probe->index + 1,
802 probe->enabled ? "ON" : "OFF") != SR_OK)
805 } else if (probe->type == SR_PROBE_LOGIC) {
807 devc->enabled_digital_probes = g_slist_append(
808 devc->enabled_digital_probes, probe);
809 if (probe->enabled != devc->digital_channels[probe->index]) {
810 /* Enabled channel is currently disabled, or vice versa. */
811 if (set_cfg(sdi, ":DIG%d:TURN %s", probe->index,
812 probe->enabled ? "ON" : "OFF") != SR_OK)
818 if (!devc->enabled_analog_probes && !devc->enabled_digital_probes)
821 if (devc->data_source == DATA_SOURCE_LIVE) {
822 if (set_cfg(sdi, ":RUN") != SR_OK)
824 } else if (devc->data_source == DATA_SOURCE_MEMORY) {
825 if (devc->model->series != RIGOL_DS2000) {
826 sr_err("Data source 'Memory' not supported for this device");
829 } else if (devc->data_source == DATA_SOURCE_SEGMENTED) {
830 sr_err("Data source 'Segmented' not yet supported");
834 sr_scpi_source_add(scpi, G_IO_IN, 50, rigol_ds_receive, (void *)sdi);
836 /* Send header packet to the session bus. */
837 std_session_send_df_header(cb_data, LOG_PREFIX);
839 if (devc->model->protocol == PROTOCOL_LEGACY) {
840 devc->analog_frame_size = DS1000_ANALOG_LIVE_WAVEFORM_SIZE;
841 /* Fetch the first frame. */
842 if (devc->enabled_analog_probes)
843 devc->channel = devc->enabled_analog_probes->data;
845 devc->channel = devc->enabled_digital_probes->data;
846 if (rigol_ds_channel_start(sdi) != SR_OK)
849 if (devc->enabled_analog_probes) {
850 if (devc->data_source == DATA_SOURCE_MEMORY)
852 if (g_slist_length(devc->enabled_analog_probes) == 1)
853 devc->analog_frame_size = DS2000_ANALOG_MEM_WAVEFORM_SIZE_1C;
855 devc->analog_frame_size = DS2000_ANALOG_MEM_WAVEFORM_SIZE_2C;
856 /* Apparently for the DS2000 the memory
857 * depth can only be set in Running state -
858 * this matches the behaviour of the UI. */
859 if (set_cfg(sdi, ":RUN") != SR_OK)
861 if (set_cfg(sdi, "ACQ:MDEP %d", devc->analog_frame_size) != SR_OK)
863 if (set_cfg(sdi, ":STOP") != SR_OK)
866 devc->analog_frame_size = DS2000_ANALOG_LIVE_WAVEFORM_SIZE;
867 devc->channel = devc->enabled_analog_probes->data;
868 if (rigol_ds_capture_start(sdi) != SR_OK)
876 static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
878 struct dev_context *devc;
879 struct sr_scpi_dev_inst *scpi;
885 if (sdi->status != SR_ST_ACTIVE) {
886 sr_err("Device inactive, can't stop acquisition.");
890 g_slist_free(devc->enabled_analog_probes);
891 g_slist_free(devc->enabled_digital_probes);
892 devc->enabled_analog_probes = NULL;
893 devc->enabled_digital_probes = NULL;
895 sr_scpi_source_remove(scpi);
900 SR_PRIV struct sr_dev_driver rigol_ds_driver_info = {
902 .longname = "Rigol DS",
907 .dev_list = dev_list,
908 .dev_clear = dev_clear,
909 .config_get = config_get,
910 .config_set = config_set,
911 .config_list = config_list,
912 .dev_open = dev_open,
913 .dev_close = dev_close,
914 .dev_acquisition_start = dev_acquisition_start,
915 .dev_acquisition_stop = dev_acquisition_stop,