1

I am using a rPi 2B to which I have plugged in a Magstripe Card Reader (using a PS/2 to USB converter). I determined the correct Vendor/Product ID's using lsusb and then am using the following code which uses libusb to connect to the reader. This code does the check for is_kernel_driver_active that seems to be the main source of error for this problem. Code is from the keyboard_alike project on github.

def initialize(self):
    self._device = usb.core.find(idVendor=self.vendor_id, idProduct=self.product_id)

    if self._device is None:
        raise DeviceException('No device found, check vendor_id and product_id')

    if self._device.is_kernel_driver_active(self.interface):
        try:
            self._device.detach_kernel_driver(self.interface)
        except usb.core.USBError as e:
            raise DeviceException('Could not detach kernel driver: %s' % str(e))

    try:
        self._device.set_configuration()
        if self.should_reset:
            self._device.reset()
    except usb.core.USBError as e:
        raise DeviceException('Could not set configuration: %s' % str(e))

    self._endpoint = self._device[0][(0, 0)][0]

When executed as root, I get a Resource busy on the call to self._device.set_configuration().

I have run all the updates and I am not sure what to try next.

Matthew
  • 9,851
  • 4
  • 46
  • 77

1 Answers1

2

I think I have fixed this using this post - it looks like the problem is that the Magstripe Reader was being claimed by the USBHID driver at start up. This issue is not resolved using detach_kernel_driver().

I created a rule in /etc/udev/rules.d to keep this device from being loaded. I am now on to a new problem but this appears to have corrected the initial problem.

My Rule looked like this: # Magstripe reader should be disabled SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="2324", ATTR{authorized}="0"

Matthew
  • 9,851
  • 4
  • 46
  • 77