Closed daritter closed 9 years ago
does it work on Python 3 as well? If not, please use the same solution as here:
https://github.com/hgrecco/pyvisa/blob/master/pyvisa/util.py#L28
I don't have python3 on the machine where the device is connected so I cannot verify it directly. But struct.pack(b">I", 5) == struct.pack(">I", 5)
seems to work fine in python 3.4 on my local machine.
Of course the solution in utils.py would also be fine. Do you want me to prepare a pull request for the two occurences in protocols/rpc.py and the four in protocols/usbmtc.py ?
I have the idea that there was a bug in certain versions of python (maybe in 3.2) that required us to do the solution coded in utils.py
. We are putting common compatibility code in PyVISA compat package to make it easier to maintain and test. Therefore, please:
compat\struct.py
and then use them directly from there in utils.py
. rpc.py
and usbtmc.py
Thanks for looking into this!
when running on python2.7 I get errors with struct.pack:
File "/home/hybrid5/.local/lib/python2.7/site-packages/pyvisa-py/protocols/rpc.py", line 282, in sendfrag header = struct.pack(">I", x) TypeError: Struct() argument 1 must be string, not unicode
locally I fixed the two occurences of struct.pack to use a byte-string literal and that seems to work fine.