Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OLS Improvements #51

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/hardware/openbench-logic-sniffer/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic;
uint32_t sample;
int num_bytes_read;
unsigned int i, j, num_changroups;
unsigned char byte;
gboolean received_a_byte;

(void)fd;
Expand All @@ -419,12 +419,18 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)

received_a_byte = FALSE;
while (revents == G_IO_IN &&
serial_read_nonblocking(serial, &byte, 1) == 1) {
(num_bytes_read = serial_read_nonblocking(
serial, devc->raw_sample + devc->raw_sample_size,
num_changroups - devc->raw_sample_size)) > 0) {
received_a_byte = TRUE;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout handling will still work the same, right?
Maybe 'received_a_byte' should be renamed to 'received_a_sample'?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, timeout handling is unaffected. We're just reading more at the same time.

About the variable: Since a sample can span multiple bytes but the serial interface might only deliver 1 byte (theoretically), I think received_a_byte is actually still correct.

devc->cnt_rx_bytes++;
devc->cnt_rx_bytes += num_bytes_read;
devc->raw_sample_size += num_bytes_read;

sr_spew("Received data. Current sample: %.2x%.2x%.2x%.2x (%u bytes)",
devc->raw_sample[0], devc->raw_sample[1],
devc->raw_sample[2], devc->raw_sample[3],
devc->raw_sample_size);

devc->raw_sample[devc->raw_sample_size++] = byte;
sr_spew("Received byte 0x%.2x.", byte);
if (devc->raw_sample_size == num_changroups) {
unsigned int samples_to_write, new_sample_buf_size;

Expand Down