python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.
https://www.python-microscope.org
GNU General Public License v3.0
73 stars 42 forks source link

read_until() got an unexpected keyword argument 'terminator' with pySerial 3.5 #233

Closed carandraug closed 2 years ago

carandraug commented 2 years ago

This issue was split from the discussion in #232 and reported by @jacopoabramo:

[...] now instead I get the following error:

Traceback (most recent call last):
 File "C:\git\sandbox\sandbox.py", line 3, in <module>
   laser = TopticaiBeam("COM3")
 File "C:\Users\iScat_Lab\AppData\Local\Programs\Python\Python39\lib\site-packages\microscope\lights\toptica.py", line 218, in __init__
   self._conn = _iBeamConnection(port)
 File "C:\Users\iScat_Lab\AppData\Local\Programs\Python\Python39\lib\site-packages\microscope\lights\toptica.py", line 101, in __init__
   self.command(b"")
 File "C:\Users\iScat_Lab\AppData\Local\Programs\Python\Python39\lib\site-packages\microscope\lights\toptica.py", line 131, in command
   answer = self._serial.read_until(b"\r\n[OK]\r\n")
 File "C:\Users\iScat_Lab\AppData\Local\Programs\Python\Python39\lib\site-packages\microscope\_utils.py", line 117, in read_until
   return self._serial.read_until(terminator=terminator, size=size)
TypeError: read_until() got an unexpected keyword argument 'terminator'
Exception in disable() during shutdown: 'TopticaiBeam' object has no attribute '_conn'
carandraug commented 2 years ago

The issue is that pySerial 3.5 changed the named of the arguments for Serial.read_until. What was previously named terminator was renamed expected. There was no change of behaviour, only the name of the argument changed to "reflect functionality beyond just line terminators". This change was done in commit pyserial/pyserial@daaf33edd1a054a52fa8ec297a5767d06f96a942 . I have reported as being backwards incompatible at pyserial/pyserial#634 but I guess we now should do something about it on our side.

carandraug commented 2 years ago

I have changed this in f190c7b1c7b2 to avoid the use of the argument name and reply on its position only. @jacopoabramo, while we do not have a new release of Microscope, you can either apply the change to your installation of Microscope or you could install any pyserial release before 3.5 (pip install "pyserial<3.5").

Closing as fixed.