From: Valentin Ochs Date: Thu, 11 Jun 2020 12:24:49 +0000 (+0200) Subject: rigol-ds: Experimental support for V5 frame reading X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=19f31c8acec775a35482328f517cb08dc66c4d66;p=libsigrok.git rigol-ds: Experimental support for V5 frame reading --- diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 38b880de..01914ff8 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -946,21 +946,25 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) /* Set memory mode. */ if (devc->data_source == DATA_SOURCE_SEGMENTED) { - if (devc->model->series->protocol == PROTOCOL_V4) { + switch (devc->model->series->protocol) { + case PROTOCOL_V4: + { int frames = 0; - /* PROTOCOL_V5 has RECORD:FRAMES?, but this seems to return the - * maximum that should be captured, not the current amount. If - * we can figure out how to get the current number of frames, - * or when we've hit the last one, adding support for this will - * be possible as well. - */ sr_scpi_get_int(sdi->conn, "FUNC:WREP:FEND?", &frames); if (frames <= 0) { sr_err("No segmented data available"); return SR_ERR; } devc->num_frames_segmented = frames; - } else { + break; + } + case PROTOCOL_V5: + /* The frame limit has to be read on the fly, just set up + * reading of the first frame */ + if (rigol_ds_config_set(sdi, "REC:CURR 1") != SR_OK) + return SR_ERR; + break; + default: sr_err("Data source 'Segmented' not yet supported"); return SR_ERR; } diff --git a/src/hardware/rigol-ds/protocol.c b/src/hardware/rigol-ds/protocol.c index 0628729a..fcfcbee1 100644 --- a/src/hardware/rigol-ds/protocol.c +++ b/src/hardware/rigol-ds/protocol.c @@ -431,7 +431,8 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi) if (rigol_ds_config_set(sdi, ":SING") != SR_OK) return SR_ERR; rigol_ds_set_wait_event(devc, WAIT_STOP); - if (devc->data_source == DATA_SOURCE_SEGMENTED) + 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; } @@ -805,7 +806,22 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data) /* Done with this frame. */ std_session_send_df_frame_end(sdi); - if (++devc->num_frames == devc->limit_frames || + devc->num_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. */