rigol-ds1xx2: fix handling of partial frames.
This commit is contained in:
parent
4c7aca66de
commit
ee7e9bee5d
|
@ -552,6 +552,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
devc->channel_frame->name[2]) != SR_OK)
|
||||
return SR_ERR;
|
||||
|
||||
devc->num_frame_bytes = 0;
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,12 +47,12 @@ SR_PRIV int rigol_ds1xx2_receive(int fd, int revents, void *cb_data)
|
|||
return TRUE;
|
||||
|
||||
if (revents == G_IO_IN) {
|
||||
len = read(fd, buf, WAVEFORM_SIZE);
|
||||
len = read(fd, buf, WAVEFORM_SIZE - devc->num_frame_bytes);
|
||||
sr_dbg("Received %d bytes.", len);
|
||||
if (len == -1)
|
||||
return TRUE;
|
||||
|
||||
if (devc->num_frame_samples == 0) {
|
||||
if (devc->num_frame_bytes == 0) {
|
||||
/* Start of a new frame. */
|
||||
packet.type = SR_DF_FRAME_BEGIN;
|
||||
sr_session_send(sdi, &packet);
|
||||
|
@ -75,13 +75,17 @@ SR_PRIV int rigol_ds1xx2_receive(int fd, int revents, void *cb_data)
|
|||
sr_session_send(cb_data, &packet);
|
||||
g_slist_free(analog.probes);
|
||||
|
||||
if (len != WAVEFORM_SIZE)
|
||||
devc->num_frame_bytes += len;
|
||||
|
||||
if (devc->num_frame_bytes != WAVEFORM_SIZE) {
|
||||
/* Don't have the whole frame yet. */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* End of the frame. */
|
||||
packet.type = SR_DF_FRAME_END;
|
||||
sr_session_send(sdi, &packet);
|
||||
devc->num_frame_bytes = 0;
|
||||
|
||||
if (devc->channel_frame == devc->enabled_probes->data
|
||||
&& devc->enabled_probes->next != NULL) {
|
||||
|
|
|
@ -57,7 +57,7 @@ struct dev_context {
|
|||
char *device;
|
||||
int fd;
|
||||
uint64_t num_frames;
|
||||
uint64_t num_frame_samples;
|
||||
uint64_t num_frame_bytes;
|
||||
struct sr_probe *channel_frame;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue