rigol-ds: Add support for reading segmented data for protocol v4
This commit is contained in:
parent
704910e32c
commit
8cbe5339b1
|
@ -500,6 +500,7 @@ static int analog_frame_size(const struct sr_dev_inst *sdi)
|
||||||
case DATA_SOURCE_LIVE:
|
case DATA_SOURCE_LIVE:
|
||||||
return devc->model->series->live_samples;
|
return devc->model->series->live_samples;
|
||||||
case DATA_SOURCE_MEMORY:
|
case DATA_SOURCE_MEMORY:
|
||||||
|
case DATA_SOURCE_SEGMENTED:
|
||||||
return devc->model->series->buffer_samples / analog_channels;
|
return devc->model->series->buffer_samples / analog_channels;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -514,6 +515,7 @@ static int digital_frame_size(const struct sr_dev_inst *sdi)
|
||||||
case DATA_SOURCE_LIVE:
|
case DATA_SOURCE_LIVE:
|
||||||
return devc->model->series->live_samples * 2;
|
return devc->model->series->live_samples * 2;
|
||||||
case DATA_SOURCE_MEMORY:
|
case DATA_SOURCE_MEMORY:
|
||||||
|
case DATA_SOURCE_SEGMENTED:
|
||||||
return devc->model->series->buffer_samples * 2;
|
return devc->model->series->buffer_samples * 2;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -879,6 +881,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
devc = sdi->priv;
|
devc = sdi->priv;
|
||||||
|
|
||||||
devc->num_frames = 0;
|
devc->num_frames = 0;
|
||||||
|
devc->num_frames_segmented = 0;
|
||||||
|
|
||||||
some_digital = FALSE;
|
some_digital = FALSE;
|
||||||
for (l = sdi->channels; l; l = l->next) {
|
for (l = sdi->channels; l; l = l->next) {
|
||||||
|
@ -943,8 +946,24 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
||||||
|
|
||||||
/* Set memory mode. */
|
/* Set memory mode. */
|
||||||
if (devc->data_source == DATA_SOURCE_SEGMENTED) {
|
if (devc->data_source == DATA_SOURCE_SEGMENTED) {
|
||||||
sr_err("Data source 'Segmented' not yet supported");
|
if (devc->model->series->protocol == PROTOCOL_V4) {
|
||||||
return SR_ERR;
|
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 {
|
||||||
|
sr_err("Data source 'Segmented' not yet supported");
|
||||||
|
return SR_ERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
devc->analog_frame_size = analog_frame_size(sdi);
|
devc->analog_frame_size = analog_frame_size(sdi);
|
||||||
|
|
|
@ -338,12 +338,15 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
|
||||||
if (!(devc = sdi->priv))
|
if (!(devc = sdi->priv))
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
|
|
||||||
if (devc->limit_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,
|
sr_dbg("Starting data capture for frameset %" PRIu64,
|
||||||
devc->num_frames + 1);
|
devc->num_frames + 1);
|
||||||
else
|
else
|
||||||
sr_dbg("Starting data capture for frameset %" PRIu64 " of %"
|
sr_dbg("Starting data capture for frameset %" PRIu64 " of %"
|
||||||
PRIu64, devc->num_frames + 1, devc->limit_frames);
|
PRIu64, devc->num_frames + 1, limit_frames);
|
||||||
|
|
||||||
switch (devc->model->series->protocol) {
|
switch (devc->model->series->protocol) {
|
||||||
case PROTOCOL_V1:
|
case PROTOCOL_V1:
|
||||||
|
@ -428,6 +431,9 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
|
||||||
if (rigol_ds_config_set(sdi, ":SING") != SR_OK)
|
if (rigol_ds_config_set(sdi, ":SING") != SR_OK)
|
||||||
return SR_ERR;
|
return SR_ERR;
|
||||||
rigol_ds_set_wait_event(devc, WAIT_STOP);
|
rigol_ds_set_wait_event(devc, WAIT_STOP);
|
||||||
|
if (devc->data_source == DATA_SOURCE_SEGMENTED)
|
||||||
|
if (rigol_ds_config_set(sdi, "FUNC:WREP:FCUR %d", devc->num_frames + 1) != SR_OK)
|
||||||
|
return SR_ERR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -799,7 +805,9 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
|
||||||
/* Done with this frame. */
|
/* Done with this frame. */
|
||||||
std_session_send_df_frame_end(sdi);
|
std_session_send_df_frame_end(sdi);
|
||||||
|
|
||||||
if (++devc->num_frames == devc->limit_frames || devc->data_source == DATA_SOURCE_MEMORY) {
|
if (++devc->num_frames == devc->limit_frames ||
|
||||||
|
devc->num_frames == devc->num_frames_segmented ||
|
||||||
|
devc->data_source == DATA_SOURCE_MEMORY) {
|
||||||
/* Last frame, stop capture. */
|
/* Last frame, stop capture. */
|
||||||
sr_dev_acquisition_stop(sdi);
|
sr_dev_acquisition_stop(sdi);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -144,6 +144,8 @@ struct dev_context {
|
||||||
|
|
||||||
/* Number of frames received in total. */
|
/* Number of frames received in total. */
|
||||||
uint64_t num_frames;
|
uint64_t num_frames;
|
||||||
|
/* Number of frames available from the Segmented data source */
|
||||||
|
uint64_t num_frames_segmented;
|
||||||
/* GSList entry for the current channel. */
|
/* GSList entry for the current channel. */
|
||||||
GSList *channel_entry;
|
GSList *channel_entry;
|
||||||
/* Number of bytes received for current channel. */
|
/* Number of bytes received for current channel. */
|
||||||
|
|
Loading…
Reference in New Issue