Discussion:
[pyusb-users] NotImplementedError when using pyusb
greg yurikov
2012-05-17 18:40:21 UTC
Permalink
When running the following code:



import sys
import usb.core
import usb.util

VENDOR_ID = 0x1bcf
PRODUCT_ID = 0x0007
DATA_SIZE = 8

# find the MagTek reader

device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)

if device is None:
    sys.exit("Could not find device.")

# make sure the hiddev kernel driver is not active

if device.is_kernel_driver_active(0):
    try:
        device.detach_kernel_driver(0)
    except usb.core.USBError as e:
        sys.exit("Could not detatch kernel driver: %s" % str(e))
....

I get this error:

  File "test.py", line 20, in <module>
    if device.is_kernel_driver_active(0):
  File "C:\Python26\lib\site-packages\usb\core.py", line 704, in is_kernel_driver_active
    return self._ctx.backend.is_kernel_driver_active(self._ctx.handle, interface)
  File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 355, in is_kernel_driver_active
    _not_implemented(self.is_kernel_driver_active)
  File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 79, in _not_implemented
    raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active

Am I suppose to implement this on my own? Can I just redirect this to another python module that actually implements this?
chris clark
2012-05-17 20:07:17 UTC
Permalink
Post by greg yurikov
....
File "test.py", line 20, in <module>
File "C:\Python26\lib\site-packages\usb\core.py", line 704, in
is_kernel_driver_active
return self._ctx.backend.is_kernel_driver_active(self._ctx.handle,
interface)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 355,
in is_kernel_driver_active
_not_implemented(self.is_kernel_driver_active)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 79,
in _not_implemented
raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active
Am I suppose to implement this on my own? Can I just redirect this to
another python module that actually implements this?
It looks like the generic device code is being fired, not the
backend implemention code.

Which backend is being used?
greg yurikov
2012-05-17 21:00:46 UTC
Permalink
I'm using the libusb1.2.4.9 win32 backend I think. I downloaded the .zip file found here:
https://sourceforge.net/projects/libusb-win32/files/libusb-win32-snapshots/20110713/ 


In the zip were the following files:
libusb-win32-devel-filter-1.2.4.9.exe

libusb-win32-src-1.2.4.9.zip

libusb-win32-bin-1.2.4.9.zip

libusb-win32-debug-1.2.4.9.zip


I did nothing more than run the exe. I feel like I'm missing a step here.



________________________________
From: chris clark <***@gmail.com>
To: greg yurikov <***@yahoo.com>; pyusb-***@lists.sourceforge.net
Sent: Thursday, May 17, 2012 1:07 PM
Subject: Re: [pyusb-users] NotImplementedError when using pyusb





On Thu, May 17, 2012 at 11:40 AM, greg yurikov <***@yahoo.com> wrote:

....
Post by greg yurikov
  File "test.py", line 20, in <module>
  File "C:\Python26\lib\site-packages\usb\core.py", line 704, in is_kernel_driver_active
    return self._ctx.backend.is_kernel_driver_active(self._ctx.handle, interface)
  File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 355, in is_kernel_driver_active
    _not_implemented(self.is_kernel_driver_active)
  File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 79, in _not_implemented
    raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active
Am I suppose to implement this on my own? Can I just redirect this to another python module that actually implements this?
It looks like the generic device code is being fired, not the backend implemention code.

Which backend is being used?
chris clark
2012-05-18 00:49:33 UTC
Permalink
Ah! Windows (didn't notice that at first), it isn't implemented (and isn't
possible). I posted a similar question a while back. The response
I received is worth reading.

Chris
Post by greg yurikov
https://sourceforge.net/projects/libusb-win32/files/libusb-win32-snapshots/20110713/
libusb-win32-devel-filter-1.2.4.9.exe
libusb-win32-src-1.2.4.9.zip
libusb-win32-bin-1.2.4.9.zip
libusb-win32-debug-1.2.4.9.zip
I did nothing more than run the exe. I feel like I'm missing a step here.
------------------------------
*Sent:* Thursday, May 17, 2012 1:07 PM
*Subject:* Re: [pyusb-users] NotImplementedError when using pyusb
....
File "test.py", line 20, in <module>
File "C:\Python26\lib\site-packages\usb\core.py", line 704, in
is_kernel_driver_active
return self._ctx.backend.is_kernel_driver_active(self._ctx.handle,
interface)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 355,
in is_kernel_driver_active
_not_implemented(self.is_kernel_driver_active)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 79,
in _not_implemented
raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active
Am I suppose to implement this on my own? Can I just redirect this to
another python module that actually implements this?
It looks like the generic device code is being fired, not the
backend implemention code.
Which backend is being used?
Wander Lairson Costa
2012-05-18 03:29:45 UTC
Permalink
Hi,

To make a long story short, in Windows, libusb needs a driver attached, so
makes no sense a function to detach the driver.
Post by greg yurikov
https://sourceforge.net/projects/libusb-win32/files/libusb-win32-snapshots/20110713/
libusb-win32-devel-filter-1.2.4.9.exe
libusb-win32-src-1.2.4.9.zip
libusb-win32-bin-1.2.4.9.zip
libusb-win32-debug-1.2.4.9.zip
I did nothing more than run the exe. I feel like I'm missing a step here.
------------------------------
*Sent:* Thursday, May 17, 2012 1:07 PM
*Subject:* Re: [pyusb-users] NotImplementedError when using pyusb
....
File "test.py", line 20, in <module>
File "C:\Python26\lib\site-packages\usb\core.py", line 704, in
is_kernel_driver_active
return self._ctx.backend.is_kernel_driver_active(self._ctx.handle,
interface)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 355,
in is_kernel_driver_active
_not_implemented(self.is_kernel_driver_active)
File "C:\Python26\lib\site-packages\usb\backend\__init__.py", line 79,
in _not_implemented
raise NotImplementedError(func.__name__)
NotImplementedError: is_kernel_driver_active
Am I suppose to implement this on my own? Can I just redirect this to
another python module that actually implements this?
It looks like the generic device code is being fired, not the
backend implemention code.
Which backend is being used?
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
pyusb-users mailing list
https://lists.sourceforge.net/lists/listinfo/pyusb-users
Loading...