【问题标题】:LibUSB ErrNo 16 Resource Busy - Magstripe readerLibUSB ErrNo 16 Resource Busy - 磁条阅读器
【发布时间】:2016-10-23 20:01:14
【问题描述】:

我使用的 rPi 2B 已插入磁条读卡器(使用 PS/2 到 USB 转换器)。我使用 lsusb 确定了正确的供应商/产品 ID,然后使用以下代码使用 libusb 连接到阅读器。此代码检查is_kernel_driver_active,这似乎是此问题的主要错误来源。代码来自github上的keyboard_alike项目。

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]

当以 root 身份执行时,我在调用 self._device.set_configuration() 时收到一个 Resource busy

我已经运行了所有更新,但我不确定接下来要尝试什么。

【问题讨论】:

    标签: python raspberry-pi pyusb libusb-1.0


    【解决方案1】:

    我想我已经使用 post 解决了这个问题 - 看起来问题是磁条阅读器在启动时被 USBHID 驱动程序占用。使用detach_kernel_driver() 无法解决此问题。

    我在/etc/udev/rules.d 中创建了一条规则,以防止加载此设备。我现在遇到了一个新问题,但这似乎已经纠正了最初的问题。

    我的规则如下所示: # 磁条阅读器应该被禁用 SUBSYSTEM=="usb", ATTRS{idVendor}=="04b4", ATTRS{idProduct}=="2324", ATTR{authorized}="0"

    【讨论】:

      猜你喜欢
      • 2022-06-29
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 2012-02-28
      • 2013-08-02
      • 1970-01-01
      • 2011-07-19
      • 1970-01-01
      相关资源
      最近更新 更多