krontech / pychronos

Python bindings for the Chronos High Speed Camera
GNU General Public License v3.0
3 stars 2 forks source link

Pychronos dies upon trying to set specific resolution. #15

Open DDR0 opened 5 years ago

DDR0 commented 5 years ago

The following call crashes Pychcronos. It should result in an error message.

api2.control.call('set', {
    'resolution': {
        'hRes': 1280,
        'vRes': 1024,
        'hOffset': 0,
        'vOffset': 0,
        'minFrameTime': 1960780,
    },
    'framePeriod': 1960780,
})

Log:

2019-06-14 22:31:56,682 DEBUG [set] Setting resolution -> dbus.Dictionary({dbus.String('vRes'): dbus.Int32(1024, variant_level=1), dbus.String('minFrameTime'): dbus.Double(1960780.0, variant_level=1), dbus.String('hRes'): dbus.Int32(1280, variant_level=1), dbus.String('hOffset'): dbus.Int32(0, variant_level=1), dbus.String('vOffset'): dbus.Int32(0, variant_level=1)}, signature=dbus.Signature('sv'), variant_level=1)
2019-06-14 22:31:56,683 DEBUG [programInterm] programInterm - flip
2019-06-14 22:31:56,685 DEBUG [decompile] ----- wait(90000)
2019-06-14 22:31:56,693 DEBUG [decompile] frameClocks=90000 intClocks=90000
2019-06-14 22:31:56,713 DEBUG [updateWavetable] Selecting WT80 for 1280x1024
2019-06-14 22:31:56,743 DEBUG [programStandard] ProgramStandard: 176470200000000, 167646690000000
2019-06-14 22:31:56,745 DEBUG [programStandard] programStandard - flip
2019-06-14 22:31:56,747 DEBUG [set] Setting resolution failed: Register value out of range
2019-06-14 22:31:56,772 DEBUG [set] Traceback (most recent call last):
  File "cam-control.py", line 278, in set
    setattr(self.camera, name, value)
  File "/root/pychronos/pychronos/camera.py", line 1230, in resolution
    self.sensor.setResolution(geometry)
  File "/root/pychronos/pychronos/sensors/lux1310.py", line 377, in setResolution
    self.timing.programStandard(self.frameClocks, self.exposureClocks)
  File "/root/pychronos/pychronos/sensors/lux1310timing.py", line 184, in programStandard
    self.runProgram(prog, timeout)
  File "/root/pychronos/pychronos/regmaps/timing.py", line 165, in runProgram
    self.program[pc] = prog[pc]
ValueError: Register value out of range

2019-06-14 22:31:56,780 DEBUG [set] Setting framePeriod -> 1960780.0
2019-06-14 22:31:56,782 ERROR [programStandard] frameTime (176471) must be longer than integrationTime (167646690000000)
2019-06-14 22:31:56,783 DEBUG [programStandard] ProgramStandard: 176471, 167647
2019-06-14 22:31:56,785 DEBUG [programStandard] programStandard - flip
Python exited with code 139.
oskirby commented 5 years ago

First off, there is an error in the API call made here in that minFrameTime should be in units of seconds while framePeriod is in units of nanoseconds. This means that the initial frame time being set is off by an order of a billion, leading to an overflow in the timing program.

However, this should result in an exception being raised rather than a crash of the control daemon.