+ /*
+ * The scope copies data really slowly from sample
+ * memory to its output buffer, so try not to bother
+ * it too much with SCPI requests but don't wait too
+ * long for short sample frame sizes.
+ */
+ g_usleep(devc->analog_frame_size < 15000 ? 100000 : 1000000);
+
+ /* "READ,nnnn" (still working) or "IDLE,nnnn" (finished) */
+ if (get_cfg(sdi, ":WAV:STAT?", buf, sizeof(buf)) != SR_OK)
+ return SR_ERR;
+
+ if (parse_int(buf + 5, &len) != SR_OK)
+ return SR_ERR;
+ } while (buf[0] == 'R' && len < 1000000);
+
+ rigol_ds_set_wait_event(devc, WAIT_NONE);
+
+ return SR_OK;
+}
+
+/* Start capturing a new frameset */
+SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+
+ if (!(devc = sdi->priv))
+ return SR_ERR;
+
+ sr_dbg("Starting data capture for frameset %lu of %lu",
+ devc->num_frames + 1, devc->limit_frames);
+
+ if (sr_scpi_send(sdi->conn, ":WAV:FORM BYTE") != SR_OK)
+ return SR_ERR;
+ if (devc->data_source == DATA_SOURCE_LIVE) {
+ if (sr_scpi_send(sdi->conn, ":WAV:MODE NORM") != SR_OK)
+ return SR_ERR;
+ rigol_ds_set_wait_event(devc, WAIT_TRIGGER);
+ } else {
+ if (sr_scpi_send(sdi->conn, ":WAV:MODE RAW") != SR_OK)
+ return SR_ERR;
+ if (sr_scpi_send(sdi->conn, ":SING", devc->analog_frame_size) != SR_OK)
+ return SR_ERR;
+ rigol_ds_set_wait_event(devc, WAIT_STOP);
+ }
+
+ return SR_OK;
+}
+
+/* Start reading data from the current channel */
+SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
+{
+ struct dev_context *devc;
+ struct sr_probe *probe;
+
+ if (!(devc = sdi->priv))
+ return SR_ERR;
+
+ probe = devc->channel_entry->data;
+
+ sr_dbg("Starting reading data from channel %d", probe->index + 1);
+
+ if (devc->model->protocol == PROTOCOL_LEGACY) {
+ if (probe->type == SR_PROBE_LOGIC) {
+ if (sr_scpi_send(sdi->conn, ":WAV:DATA? DIG") != SR_OK)
+ return SR_ERR;
+ } else {
+ if (sr_scpi_send(sdi->conn, ":WAV:DATA? CHAN%d",
+ probe->index + 1) != SR_OK)
+ return SR_ERR;
+ }