简体   繁体   English

树莓派上的 usb_claim_interface()

[英]usb_claim_interface() on Raspberry Pi

I'm trying to get a USB HID device to work on Raspberry Pi.我正在尝试让 USB HID 设备在 Raspberry Pi 上工作。

The code utilizes the RawHID lib for MacOSX/Linux/Windows.该代码使用 MacOSX/Linux/Windows 的RawHID库。

I got it working on MacOSX, but for other reasons I can't use it on that OS anymore.我让它在 MacOSX 上工作,但由于其他原因我不能再在那个操作系统上使用它了。 Now I'm trying to get it to work on Raspberry Pi via hid_LINUX.c .现在我正在尝试通过hid_LINUX.c在 Raspberry Pi 上hid_LINUX.c

When I tried it out, it just completely fails to connect.当我尝试它时,它完全无法连接。 I added the debug info, and found out it's failing here:我添加了调试信息,发现这里失败了:

if (usb_claim_interface(u, i) < 0) {          
    printf("  unable claim interface %d\n", i); 
    continue;                                   
}

I tried googling for ages and I see various things about...我尝试谷歌搜索了很长时间,我看到了关于……的各种事情。

  • modprobe.d blacklist (didn't work, although that looked for for rtl devices... not sure) modprobe.d 黑名单(没有用,虽然寻找 rtl 设备......不确定)
  • updating all packages (didn't work)更新所有软件包(不起作用)
  • compiling your own version of libhid (I don't know why I'd have to do this, considering the creator of the USB device recommended this RawHID lib which uses libusb-dev ( usb.h ), and which works fine on OS X and Windows)编译你自己的libhid版本(我不知道为什么我必须这样做,考虑到 USB 设备的创建者推荐了这个使用libusb-dev ( usb.h ) 的 RawHID lib,它在 OS X 上运行良好和窗户)

Does anyone have any possible ideas how I can proceed?有没有人有任何可能的想法我该如何继续? How do I 'free' my USB device so I can claim it?如何“释放”我的 USB 设备以便我可以声明它?

I have a Raspberry Pi B+我有一个树莓派 B+

Apparently I can not comment (insufficient reputation) so I answer instead: I finally found the reason for my problem with the comment "Now I solved it by just running the code with sudo rights" above, so I'm grateful!显然我无法发表评论(声誉不足)所以我回答:我终于通过上面的评论“现在我通过使用 sudo 权限运行代码解决了它”找到了我的问题的原因,所以我很感激!

I use a Pi 3b for Domoticz for > 3 years.我将 Pi 3b 用于 Domoticz 超过 3 年。 (same software on PC before that) After a failed update, followed by a complete re-install, my CM15 Domoticz interface (connected via USB) would be recognized as present with lsusb, but would not work. (之前 PC 上的相同软件)更新失败后,然后完全重新安装,我的 CM15 Domoticz 接口(通过 USB 连接)将被识别为存在 lsusb,但无法工作。 I boot my PI from a USB key, so maybe the -very old- USB key failed, so I bought a new USB 3.0 key.我从 USB 密钥启动我的 PI,所以可能 - 非常旧的 - USB 密钥失败了,所以我买了一个新的 USB 3.0 密钥。 No joy.没有喜悦。 USB 3.0 uses more power, maybe draining USB power from my CM15, so I bought a bigger supply. USB 3.0 使用更多电源,可能会耗尽我的 CM15 的 USB 电源,所以我购买了更大的电源。 Did not solve the problem.So I bought a new memory card, no change.没有解决问题。所以我买了一个新的存储卡,没有变化。 Searching for "usb_claim_interface failed -6 mochad" brought me here for a correct diagnostic and the way to make it work "manually" Not yet the solution;搜索“usb_claim_interface failed -6 mochad”让我获得了正确的诊断以及“手动”使其工作的方法还不是解决方案; normally libusb starts the "interface" software (mochad) when it finds a new USB device connected, but "claiming it" apparently now requires more permissions.通常,libusb 在发现连接的新 USB 设备时会启动“接口”软件 (mochad),但“声明它”显然现在需要更多权限。 Now that I understand the problem, I'll find the answer.现在我明白了这个问题,我会找到答案。 Thanks much for showing the way dennis-tra!非常感谢您展示丹尼斯特拉的方式!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM