LJMUAstroecology / flirpy

Python library to interact with FLIR camera cores
Other
191 stars 54 forks source link

checksum/escaping inconsistent in Python 2 #4

Closed jveitchmichaelis closed 4 years ago

jveitchmichaelis commented 4 years ago

In some instances reading camera configuration can fail on Python 2 when Python 3 works as expected:

e.g.

Python 3.5.3 (default, Sep 27 2018, 17:25:39) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from flirpy.camera.boson import Boson
>>> cam = Boson()
>>> cam.get_camera_serial()
11482
>>> cam.get_sensor_serial()
1647278
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from flirpy.camera.boson import Boson
>>> cam = Boson()
>>> cam.get_camera_serial()
11482
>>> cam.get_sensor_serial()
WARNING:flirpy.camera.boson:Invalid checksum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/flirpy/camera/boson.py", line 286, in get_sensor_serial
    return struct.unpack(">I", res)[0]
struct.error: unpack requires a string argument of length 4
jveitchmichaelis commented 4 years ago

Due to bytes/strings being the same in Py2. Fixed in: https://github.com/LJMUAstroecology/flirpy/commit/5228dc59d60aca7e265d07e6efd1d07786457c3e