/* 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;
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.");