Hantek6022API icon indicating copy to clipboard operation
Hantek6022API copied to clipboard

error while running example_linux_continous_read.py

Open piotx opened this issue 8 years ago • 4 comments

Hallo,

thanks for sharing your API.

I get an error, when running example_linux_continous_read.py

python example_linux_continous_read.py

Clearing FIFO and starting data transfer... Stopping new transfers. Snooze 1 Closing handle Traceback (most recent call last): File "example_linux_continous_read.py", line 68, in scope.close_handle() File "/usr/local/lib/python2.7/dist-packages/Python_Hantek_6022BE_Wrapper-0.0.2-py2.7.egg/PyHT6022/LibUsbScope.py", line 116, in close_handle self.device_handle.close() File "build/bdist.linux-x86_64/egg/usb1.py", line 1113, in close File "build/bdist.linux-x86_64/egg/usb1.py", line 737, in cancel libusb1.USBError: LIBUSB_ERROR_NOT_FOUND [-5] Exception usb1.USBErrorNotFound: USBErrorNotFound() in <bound method Oscilloscope.del of <PyHT6022.LibUsbScope.Oscilloscope object at 0x7f616c3bc2d0>> ignored Exception libusb1.USBError: USBError() in <bound method USBDeviceHandle.del of <usb1.USBDeviceHandle object at 0x7f6169323190>> ignored

So the device can not be accessed, from what I understand.. Any ideas how to solve the problem?

piotx avatar Aug 17 '16 13:08 piotx

I think you need to install libusb, e.g.

sudo apt install libusb-1.0-0-dev

jhoenicke avatar Aug 17 '16 16:08 jhoenicke

well, I have installed it, but it doesn't make any difference; the error comes only, when closing the handly, so I just moved the command to the end of the script.

piotx avatar Aug 21 '16 17:08 piotx

Hello, python-libusb1 dev here.

@rpcope1: Earlier this year I improved the interpreter exit situation by avoiding dependency on destructors, as they do not follow object references (ie, if object A references object B and both have __del__ methods, A.__del__ may still be invoked before B.__del__). To avoid such interpreter-shutdown-time errors, you may want to either explicitly call USBContext.close or use with to manage the lifetime of USBContext instance (which likely means using it to manage the lifetime of Oscilloscope class with it and calling USBContext.close from Oscilloscope.__exit__).

File "build/bdist.linux-x86_64/egg/usb1.py", line 1113, in close File "build/bdist.linux-x86_64/egg/usb1.py", line 737, in cancel libusb1.USBError: LIBUSB_ERROR_NOT_FOUND [-5]

This is a bug in python-libusb1: while USBErrorNotFound exception is caught in USBDeviceHandle.close, it is USBError (the base exception class) which is raised in USBTransfer.close. This should be fixed by vpelletier/python-libusb1@7a4b8d8afc1d18a4c3ca1dc49975e3b40ae676a4 which I released today as 1.5.2 .

vpelletier avatar Aug 22 '16 12:08 vpelletier

I'm getting the same error. I am running on Ubuntu, I tried with system python +python-libusb from official sources, pypi and github, and anaconda with python-libusb1 1.6.6. Uploading firmware seems to work.

OpenHantek also works.

akloster avatar Sep 06 '18 04:09 akloster