Skip to content

Commit e73bf19

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

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
@@ -377,8 +377,8 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
377377
struct sr_datafeed_packet packet;
378378
struct sr_datafeed_logic logic;
379379
uint32_t sample;
380+
int num_bytes_read;
380381
unsigned int i, j, num_changroups;
381-
unsigned char byte;
382382
gboolean received_a_byte;
383383

384384
(void)fd;
@@ -400,12 +400,18 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
400400
}
401401

402402
received_a_byte = FALSE;
403-
while (revents == G_IO_IN && serial_read_nonblocking(serial, &byte, 1) == 1) {
403+
while (revents == G_IO_IN &&
404+
(num_bytes_read = serial_read_nonblocking(serial,
405+
devc->raw_sample + devc->raw_sample_size,
406+
num_changroups - devc->raw_sample_size)) > 0) {
404407
received_a_byte = TRUE;
405-
devc->cnt_rx_bytes++;
408+
devc->cnt_rx_bytes += num_bytes_read;
409+
devc->raw_sample_size += num_bytes_read;
410+
411+
sr_spew("Received data. Current sample: %.2x%.2x%.2x%.2x (%u bytes)",
412+
devc->raw_sample[0], devc->raw_sample[1],
413+
devc->raw_sample[2], devc->raw_sample[3], devc->raw_sample_size);
406414

407-
devc->raw_sample[devc->raw_sample_size++] = byte;
408-
sr_spew("Received byte 0x%.2x.", byte);
409415
if (devc->raw_sample_size == num_changroups) {
410416
devc->cnt_rx_raw_samples++;
411417
/*

0 commit comments

Comments
 (0)