delmic/odemis

semcomedi sometimes fails to read all the data

Closed this issue · 1 comments

It seems that in some rare cases, the semcomedi fails to retrieve data from the driver. The code attempts to retry, but if it was synchronised, it'll wait for a new event, which it shouldn't.

Example log:

2016-10-19 17:35:06,919 (semcomedi) DEBUG: Waiting 0.100123 s for the acquisition to finish
2016-10-19 17:35:06,919 (semcomedi) DEBUG: read took 0.000221968 s
2016-10-19 17:35:06,920 (semcomedi) DEBUG: Waited for the read thread for actually 0.00140095 s
2016-10-19 17:35:06,920 (semcomedi) ERROR: Acquisition failed, will retry
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 1683, in _acquisition_run
    rdas = self._acquire_analog_detectors(detectors)
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 1806, in _acquire_analog_detectors
    rranges, period, margin, osr, dpr, scan)
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 991, in write_read_2d_data_raw
    period, margin, osr, lines, data)
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 1051, in _write_read_2d_lines
    rest=(islast and self._scanner.fast_park))
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 1362, in _write_read_raw_one_cmd
    rbuf = self._reader.wait(timeout)
  File "/usr/lib/python2.7/dist-packages/odemis/driver/semcomedi.py", line 2127, in wait
    raise IOError("Read only %d values from the %d expected" % (self.buf.size, self.count))
IOError: Read only 0 values from the 140 expected
2016-10-19 17:35:06,981 (andorcam3) DEBUG: Start time = 1476891306.953107, hw time = 1476891306.899461, diff = 0.0536463 s
2016-10-19 17:35:06,981 (_dataflow) DEBUG: Failed to send data with zero-copy
2016-10-19 17:35:07,003 (andorcam3) DEBUG: Waiting for acquisition trigger
2016-10-19 17:35:07,947 (semcomedi) INFO: Resetting device /dev/comedi0

It's not yet clear why the driver sometimes fails to read the data. However, commit 9e517ef fixes the problem with the next attempt blocked waiting for a new event.