Skip to content

Commit 68f3ebe

Browse files
committed
ols: Immediately process data after expected sample count
Even with RLE enabled, we know how many samples to expect: Exactly the configured number, no less, no more. Thus, when that number is received, begin processing immediately. Also, put a warning so that we can get to know if the calculation is off. Since this works, the timeout can be bumped to provide for better usability if the logic sniffer is used over a slow network connection.
1 parent 6cc8c2e commit 68f3ebe

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
410410
std_session_send_df_header(sdi);
411411

412412
/* If the device stops sending for longer than it takes to send a byte,
413-
* that means it's finished. But wait at least 100 ms to be safe.
413+
* that means it's finished. Since the device can be used over a slow
414+
* network link, give it 10 seconds to reply.
414415
*/
415-
return serial_source_add(sdi->session, serial, G_IO_IN, 100,
416+
return serial_source_add(sdi->session, serial, G_IO_IN, 10*1000,
416417
ols_receive_data, (struct sr_dev_inst *)sdi);
417418
}
418419

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,12 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
426426
devc->rle_count = sample;
427427
sr_dbg("RLE count: %u.", devc->rle_count);
428428
devc->raw_sample_size = 0;
429-
return TRUE;
429+
430+
/*
431+
* Even on the rare occasion that the sampling ends with an RLE message,
432+
* the acquisition should end immediately, without any timeout.
433+
*/
434+
goto process_and_forward;
430435
}
431436
}
432437

@@ -486,7 +491,13 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
486491
devc->raw_sample_size = 0;
487492
devc->rle_count = 0;
488493
}
489-
} else {
494+
}
495+
496+
process_and_forward:
497+
if (revents != G_IO_IN || devc->cnt_rx_raw_samples == devc->limit_samples) {
498+
if (devc->cnt_rx_raw_samples != devc->limit_samples)
499+
sr_warn("Finished with unexpected sample count. Timeout?");
500+
490501
/*
491502
* This is the main loop telling us a timeout was reached, or
492503
* we've acquired all the samples we asked for -- we're done.

0 commit comments

Comments
 (0)