python-ivi / python-usbtmc

Provides a USBTMC driver for controlling instruments over USB
MIT License
160 stars 69 forks source link

FreeBSD problem with reset #9

Closed UffeJakobsen closed 8 years ago

UffeJakobsen commented 10 years ago

Hi,

On FreeBSD the reset issued during connect is no good - and prevents usctmc from working (throws exception). If I remove/disable the exception is works fine.

I suspect that you've has/seen the same problem with eg Windows ? At lease I can see that usbtmc.py line 255 has the following construction:

if os.name == 'posix': self.device.reset()

That needs to be extended to specificly check for FreeBSD (using os.platform or os.uname ???)

Please let me know if you need more info /Uffe

alexforencich commented 10 years ago

Interesting. Can you post the output of os.platform and os.uname on your system?

UffeJakobsen commented 10 years ago

Here you are

os.name 'posix'

os.uname() ('FreeBSD', 'asus-u32u', '10.0-RELEASE-p1', 'FreeBSD 10.0-RELEASE-p1 #0: Tue Apr 8 06:45:06 UTC 2014 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC', 'amd64')

platform.system() 'FreeBSD'

platform.release() '10.0-RELEASE-p1'

platform.version() 'FreeBSD 10.0-RELEASE-p1 #0: Tue Apr 8 06:45:06 UTC 2014 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC'

platform.uname()
('FreeBSD', 'asus-u32u', '10.0-RELEASE-p1', 'FreeBSD 10.0-RELEASE-p1 #0: Tue Apr 8 06:45:06 UTC 2014 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC', 'amd64', 'amd64')

/Uffe

alexforencich commented 10 years ago

Thanks. Also, what exception is it throwing?

UffeJakobsen commented 10 years ago

Here is the exception output:

python rigol.py

Unknown error -99 None Traceback (most recent call last): File "rigol.py", line 17, in instr = usbtmc.Instrument(0x1ab1, 0x0588) # Rigol DS1102D File "/_ext.tmp/python-usbtmc.git/usbtmc/usbtmc.py", line 248, in init self.reset() File "/_ext.tmp/python-usbtmc.git/usbtmc/usbtmc.py", line 257, in reset self.device.reset() File "/_ext.tmp/python-usbtmc.git/usb/core.py", line 595, in reset self._ctx.backend.reset_device(self._ctx.handle) File "/_ext.tmp/python-usbtmc.git/usb/backend/libusb1.py", line 846, in reset_device _check(self.lib.libusb_reset_device(dev_handle.handle)) File "/_ext.tmp/python-usbtmc.git/usb/backend/libusb1.py", line 572, in _check raise USBError(_str_error[ret], ret, _libusb_errno[ret]) usb.core.USBError: [Errno None] Unknown error #

alexforencich commented 8 years ago

This particular reset call has now been completely removed, so this should no longer be an issue.