pyvisa / pyvisa-py

A pure python PyVISA backend
https://pyvisa-py.readthedocs.io
MIT License
282 stars 120 forks source link

USB Timeout TypeError #143

Closed svenuniku closed 6 years ago

svenuniku commented 6 years ago

Hi,

when I am running a keysight scope via usb and the master branch of pyvisa-py, I'm running in a Exception because the timeout type is a float instead of an unsigned int: ctypes.ArgumentError: argument 6: <class 'TypeError'>: wrong type in

File "/usr/local/lib/python3.6/dist-packages/usb/backend/libusb1.py", line 933, in __read

in pyvisa I'm setting the timeout to 12345 ms. The libusb is awaiting an integer in ms as timeout value[1]. but pyvisa-py is setting the timeout magically in seconds and in floats[2].

my hack at the moment is to overwrite the Line 80[2] with: self.interface.timeout = int(value) This then sets the current timeout as an integer in ms. I think this is not be clean solution. Hopefully somebody who is more experienced in pyvisa-py can fix this issue.

[1] https://github.com/pyusb/pyusb/blob/master/usb/core.py#L716 [2] https://github.com/pyvisa/pyvisa-py/blob/master/pyvisa-py/usb.py#L80 My system is running on debian testing. usb.version = '1.0.2' from debian testing repo visa.version = '1.10.0.dev0' directly from github

MatthieuDartiailh commented 6 years ago

The handling of timeout is a bit inconsistent within pyvisa-py partially because support for it on some interfaces was added only recently. I will try to fix this issue before the next release which I plan for next week. I will let you know when you can test again.

svenuniku commented 6 years ago

The Fix #144 seems to work for the usb timeout. I didn't got timeouts any more and no TypeErrors.