Skip to content

Commit e068d80

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 1a2437b commit e068d80

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
397397
uint32_t sample;
398398
unsigned int i, j, num_changroups;
399399
unsigned char byte;
400+
gboolean received_a_byte;
400401

401402
(void)fd;
402403

@@ -416,9 +417,10 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
416417
}
417418
}
418419

419-
if (revents == G_IO_IN) {
420-
if (serial_read_nonblocking(serial, &byte, 1) != 1)
421-
return FALSE;
420+
received_a_byte = FALSE;
421+
while (revents == G_IO_IN &&
422+
serial_read_nonblocking(serial, &byte, 1) == 1) {
423+
received_a_byte = TRUE;
422424
devc->cnt_rx_bytes++;
423425

424426
devc->raw_sample[devc->raw_sample_size++] = byte;
@@ -527,6 +529,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
527529
devc->rle_count = 0;
528530
}
529531
}
532+
if (revents == G_IO_IN && !received_a_byte)
533+
return FALSE;
530534

531535
process_and_forward:
532536
if (revents != G_IO_IN ||

0 commit comments

Comments
 (0)