Skip to content

Commit fadfd5e

Browse files
committed
ols: Capture multiple bytes at once
Why just read a single byte when you can read a whole sample?
1 parent e068d80 commit fadfd5e

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
395395
struct sr_datafeed_packet packet;
396396
struct sr_datafeed_logic logic;
397397
uint32_t sample;
398+
int num_bytes_read;
398399
unsigned int i, j, num_changroups;
399-
unsigned char byte;
400400
gboolean received_a_byte;
401401

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

420420
received_a_byte = FALSE;
421421
while (revents == G_IO_IN &&
422-
serial_read_nonblocking(serial, &byte, 1) == 1) {
422+
(num_bytes_read = serial_read_nonblocking(
423+
serial, devc->raw_sample + devc->raw_sample_size,
424+
num_changroups - devc->raw_sample_size)) > 0) {
423425
received_a_byte = TRUE;
424-
devc->cnt_rx_bytes++;
426+
devc->cnt_rx_bytes += num_bytes_read;
427+
devc->raw_sample_size += num_bytes_read;
428+
429+
sr_spew("Received data. Current sample: %.2x%.2x%.2x%.2x (%u bytes)",
430+
devc->raw_sample[0], devc->raw_sample[1],
431+
devc->raw_sample[2], devc->raw_sample[3],
432+
devc->raw_sample_size);
425433

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

0 commit comments

Comments
 (0)