openbench-logic-sniffer: Avoid recreating event source

With the current driver API and the corresponding session event
handling, it is not possible to destroy and then re-create an
event source with the same key within the same main loop iteration.

The next generation driver API will fix this problem. But for now,
just change the driver to make do without that sort of thing. Also
increase the I/O timeout to 100 ms to be safer in the event of all
kind of delays the OS environment may induce.

This fixes bug #678.
This commit is contained in:
Daniel Elstner 2015-11-01 19:38:40 +01:00
parent d09a82a8fe
commit 8105e82913
2 changed files with 9 additions and 10 deletions

View File

@ -573,7 +573,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
/* Send header packet to the session bus. */
std_session_send_df_header(cb_data, LOG_PREFIX);
serial_source_add(sdi->session, serial, G_IO_IN, -1,
/* If the device stops sending for longer than it takes to send a byte,
* that means it's finished. But wait at least 100 ms to be safe.
*/
serial_source_add(sdi->session, serial, G_IO_IN, 100,
ols_receive_data, cb_data);
return SR_OK;

View File

@ -344,16 +344,12 @@ SR_PRIV int ols_receive_data(int fd, int revents, void *cb_data)
serial = sdi->conn;
devc = sdi->priv;
if (devc->num_transfers == 0 && revents == 0) {
/* Ignore timeouts as long as we haven't received anything */
return TRUE;
}
if (devc->num_transfers++ == 0) {
/*
* First time round, means the device started sending data,
* and will not stop until done. If it stops sending for
* longer than it takes to send a byte, that means it's
* finished. We'll double that to 30ms to be sure...
*/
serial_source_remove(sdi->session, serial);
serial_source_add(sdi->session, serial, G_IO_IN, 30,
ols_receive_data, cb_data);
devc->raw_sample_buf = g_try_malloc(devc->limit_samples * 4);
if (!devc->raw_sample_buf) {
sr_err("Sample buffer malloc failed.");