AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
125 stars 28 forks source link

TypeError when initializing Thorlabs TSI camera since version 1.4.2 #65

Open rgeneaux opened 7 months ago

rgeneaux commented 7 months ago

Hi,

Since the upgrade to version 1.4.2, we encounter the following issue on a Thorlabs Zelux Monochrome sCMOS camera: Things are fine in 1.4.1.

Minimal code to reproduce bug

from pylablib.devices import Thorlabs

serialnumbers = Thorlabs.list_cameras_tlcam()

cam = Thorlabs.ThorlabsTLCamera(serialnumbers[0])

Error message (python==3.9.0, pylablib==1.4.2, windows 10)

Traceback (most recent call last):
  File "C:\Users\ATTOExpFa1b\PycharmProjects\pymodaq_plugins_thorlabs\test_pylablib.py", line 6, in <module>
    with Thorlabs.ThorlabsTLCamera(sn) as cam:
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\devices\Thorlabs\TLCamera.py", line 74, in __init__
    self.open()
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\devices\Thorlabs\TLCamera.py", line 110, in open
    self.set_color_format()
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\core\devio\interface.py", line 666, in wrapped
    res=func(**all_args)
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\devices\Thorlabs\TLCamera.py", line 205, in set_color_format
    cinfo=self.get_color_info()
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\core\devio\interface.py", line 667, in wrapped
    return parse_reply(res,args,kwargs)
  File "C:\Miniconda3\envs\v410\lib\site-packages\pylablib\core\devio\interface.py", line 654, in parse_reply
    if len(returns)!=len(res):
TypeError: object of type 'NoneType' has no len()

Unrelated PS: thanks for the great work - we use pylablib everyday in our labs!

AlexShkarin commented 7 months ago

Hello!

Thank you for the kind words! You are right, this is a bug intrduced when adding the color mode, which breaks the code on monochrome cameras. I'm not quite sure how it made through the testing... To fix it for now, you'll need to replace the file pylablib/devices/Thorlabs/TLCamera.py with the fixed version. Otherwise, this will be fixed in the next release.