rigol-ds: Send FRAME_BEGIN and FRAME_END per frame, not per channel.

This commit is contained in:
Martin Ling 2014-01-17 15:07:15 +00:00
parent bac11aeb1b
commit f76c24f6fd
3 changed files with 35 additions and 28 deletions

View File

@ -807,6 +807,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
struct sr_scpi_dev_inst *scpi;
struct dev_context *devc;
struct sr_probe *probe;
struct sr_datafeed_packet packet;
GSList *l;
if (sdi->status != SR_ST_ACTIVE)
@ -908,6 +909,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
}
}
/* Start of first frame. */
packet.type = SR_DF_FRAME_BEGIN;
sr_session_send(cb_data, &packet);
return SR_OK;
}

View File

@ -351,7 +351,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
rigol_ds_set_wait_event(devc, WAIT_NONE);
}
devc->num_frame_samples = 0;
devc->num_channel_bytes = 0;
devc->num_block_bytes = 0;
return SR_OK;
@ -494,12 +494,6 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
devc->num_block_read += len;
if (devc->num_frame_samples == 0) {
/* Start of a new frame. */
packet.type = SR_DF_FRAME_BEGIN;
sr_session_send(sdi, &packet);
}
if (probe->type == SR_PROBE_ANALOG) {
vref = devc->vert_reference[probe->index];
vdiv = devc->vdiv[probe->index] / 25.6;
@ -551,16 +545,13 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
sr_dbg("%d of %d block bytes read", devc->num_block_read, devc->num_block_bytes);
}
devc->num_frame_samples += len;
devc->num_channel_bytes += len;
if (devc->num_frame_samples < expected_data_bytes)
/* Don't have the whole frame yet. */
if (devc->num_channel_bytes < expected_data_bytes)
/* Don't have the full data for this channel yet, re-run. */
return TRUE;
/* End of the frame. */
sr_dbg("Frame completed, %d samples", devc->num_frame_samples);
packet.type = SR_DF_FRAME_END;
sr_session_send(sdi, &packet);
/* End of data for this channel. */
if (devc->model->series >= RIGOL_DS1000Z) {
/* Signal end of data download to scope */
if (devc->data_source != DATA_SOURCE_LIVE)
@ -585,19 +576,30 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
/* Now we need to get the digital data. */
devc->channel_entry = devc->enabled_digital_probes;
rigol_ds_channel_start(sdi);
} else if (++devc->num_frames == devc->limit_frames) {
sdi->driver->dev_acquisition_stop(sdi, cb_data);
} else {
/* Get the next frame, starting with the first analog channel. */
if (devc->enabled_analog_probes)
devc->channel_entry = devc->enabled_analog_probes;
else
devc->channel_entry = devc->enabled_digital_probes;
/* Done with this frame. */
packet.type = SR_DF_FRAME_END;
sr_session_send(cb_data, &packet);
if (devc->model->series < RIGOL_DS1000Z)
rigol_ds_channel_start(sdi);
else
rigol_ds_capture_start(sdi);
if (++devc->num_frames == devc->limit_frames) {
/* Last frame, stop capture. */
sdi->driver->dev_acquisition_stop(sdi, cb_data);
} else {
/* Get the next frame, starting with the first analog channel. */
if (devc->enabled_analog_probes)
devc->channel_entry = devc->enabled_analog_probes;
else
devc->channel_entry = devc->enabled_digital_probes;
if (devc->model->series < RIGOL_DS1000Z)
rigol_ds_channel_start(sdi);
else
rigol_ds_capture_start(sdi);
/* Start of next frame. */
packet.type = SR_DF_FRAME_BEGIN;
sr_session_send(cb_data, &packet);
}
}
}
}

View File

@ -132,8 +132,8 @@ struct dev_context {
uint64_t num_frames;
/* GSList entry for the current channel. */
GSList *channel_entry;
/* Number of samples received in current frame. */
uint64_t num_frame_samples;
/* Number of bytes received for current channel. */
uint64_t num_channel_bytes;
/* Number of bytes in current data block, if 0 block header expected */
uint64_t num_block_bytes;
/* Number of data block bytes already read */