hameg-hmo: Send exactly one sigrok frame per scope frame
The previous implementation used to put FRAME_BEGIN and FRAME_END markers around each received chunk of samples, while those chunks correspond to a single channel (analog) or a group of eight channels (digital) each. In other words, the hameg-hmo driver had provided a multiple of the requested frames, and those frames were incomplete. Make sure to only send FRAME_BEGIN before the first channel's data, and FRAME_END after the last channel's data of a frame. Thus make sigrok frames exactly match the scope's frames. Add some comments on the frame marker and the acquisition stop logic while we are here.
This commit is contained in:
parent
65a6794ea1
commit
b23eb1d4d1
|
@ -799,6 +799,18 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
ch = devc->current_channel->data;
|
ch = devc->current_channel->data;
|
||||||
state = devc->model_state;
|
state = devc->model_state;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send "frame begin" packet upon reception of data for the
|
||||||
|
* first enabled channel.
|
||||||
|
*/
|
||||||
|
if (devc->current_channel == devc->enabled_channels) {
|
||||||
|
packet.type = SR_DF_FRAME_BEGIN;
|
||||||
|
sr_session_send(sdi, &packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pass on the received data of the channel(s).
|
||||||
|
*/
|
||||||
switch (ch->type) {
|
switch (ch->type) {
|
||||||
case SR_CHANNEL_ANALOG:
|
case SR_CHANNEL_ANALOG:
|
||||||
if (sr_scpi_get_block(sdi->conn, NULL, &data) != SR_OK) {
|
if (sr_scpi_get_block(sdi->conn, NULL, &data) != SR_OK) {
|
||||||
|
@ -808,9 +820,6 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_FRAME_BEGIN;
|
|
||||||
sr_session_send(sdi, &packet);
|
|
||||||
|
|
||||||
packet.type = SR_DF_ANALOG;
|
packet.type = SR_DF_ANALOG;
|
||||||
|
|
||||||
analog.data = data->data;
|
analog.data = data->data;
|
||||||
|
@ -857,8 +866,6 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_FRAME_BEGIN;
|
|
||||||
sr_session_send(sdi, &packet);
|
|
||||||
|
|
||||||
logic.length = data->len;
|
logic.length = data->len;
|
||||||
logic.unitsize = 1;
|
logic.unitsize = 1;
|
||||||
|
@ -874,13 +881,24 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
packet.type = SR_DF_FRAME_END;
|
/*
|
||||||
sr_session_send(sdi, &packet);
|
* Advance to the next enabled channel. When data for all enabled
|
||||||
|
* channels was received, then send the "frame end" packet.
|
||||||
|
*/
|
||||||
if (devc->current_channel->next) {
|
if (devc->current_channel->next) {
|
||||||
devc->current_channel = devc->current_channel->next;
|
devc->current_channel = devc->current_channel->next;
|
||||||
hmo_request_data(sdi);
|
hmo_request_data(sdi);
|
||||||
} else if (++devc->num_frames == devc->frame_limit) {
|
return TRUE;
|
||||||
|
}
|
||||||
|
packet.type = SR_DF_FRAME_END;
|
||||||
|
sr_session_send(sdi, &packet);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* End of frame was reached. Stop acquisition after the specified
|
||||||
|
* number of frames, or continue reception by starting over at
|
||||||
|
* the first enabled channel.
|
||||||
|
*/
|
||||||
|
if (++devc->num_frames == devc->frame_limit) {
|
||||||
sdi->driver->dev_acquisition_stop(sdi);
|
sdi->driver->dev_acquisition_stop(sdi);
|
||||||
} else {
|
} else {
|
||||||
devc->current_channel = devc->enabled_channels;
|
devc->current_channel = devc->enabled_channels;
|
||||||
|
|
Loading…
Reference in New Issue