Skip to content

OLS Improvements #51

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

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
10 changes: 7 additions & 3 deletions src/hardware/openbench-logic-sniffer/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
uint32_t sample;
unsigned int i, j, num_changroups;
unsigned char byte;
gboolean received_a_byte;

(void)fd;

Expand All @@ -416,9 +417,10 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
}
}

if (revents == G_IO_IN) {
if (serial_read_nonblocking(serial, &byte, 1) != 1)
return FALSE;
received_a_byte = FALSE;
while (revents == G_IO_IN &&
serial_read_nonblocking(serial, &byte, 1) == 1) {

Choose a reason for hiding this comment

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

As mentioned before, I have a OLS clone with 1MB of memory. This may be a bit too much to poll in one go? Dunno what a reasonable size for chunks would be? 64KB?

Copy link
Author

Choose a reason for hiding this comment

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

I agree to not block the event loop, though the device would have respond pretty quickly to not cause serial_read_nonblocking to return nothing (assuming the latter really doesn't block). Nonetheless, to be safe, I added a safeguard to "ols: Capture multiple bytes at once".

received_a_byte = TRUE;
devc->cnt_rx_bytes++;

devc->raw_sample[devc->raw_sample_size++] = byte;
Expand Down Expand Up @@ -527,6 +529,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
devc->rle_count = 0;
}
}
if (revents == G_IO_IN && !received_a_byte)
return FALSE;

process_and_forward:
if (revents != G_IO_IN ||
Expand Down