Skip to content

Commit 1b3b544

Browse files
committed
ols: Receive many bytes in a row
We're talking about 20 kB, so there's little need to go back to the event loop in between. But there's also no reason why we should go back to the event loop if we can read more data immediately.
1 parent 68f3ebe commit 1b3b544

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hardware/openbench-logic-sniffer/protocol.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
379379
uint32_t sample;
380380
unsigned int i, j, num_changroups;
381381
unsigned char byte;
382+
gboolean received_a_byte;
382383

383384
(void)fd;
384385

@@ -398,9 +399,9 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
398399
}
399400
}
400401

401-
if (revents == G_IO_IN) {
402-
if (serial_read_nonblocking(serial, &byte, 1) != 1)
403-
return FALSE;
402+
received_a_byte = FALSE;
403+
while (revents == G_IO_IN && serial_read_nonblocking(serial, &byte, 1) == 1) {
404+
received_a_byte = TRUE;
404405
devc->cnt_rx_bytes++;
405406

406407
devc->raw_sample[devc->raw_sample_size++] = byte;
@@ -492,6 +493,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
492493
devc->rle_count = 0;
493494
}
494495
}
496+
if (revents == G_IO_IN && !received_a_byte)
497+
return FALSE;
495498

496499
process_and_forward:
497500
if (revents != G_IO_IN || devc->cnt_rx_raw_samples == devc->limit_samples) {

0 commit comments

Comments
 (0)