You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派3B+使用hidapi hidtest无法打开设备求助

解决树莓派3B+上hidapi无法打开USB鼠标的问题

问题复现

pi@led-panel:~/hidapi/hidtest $ sudo ./test
hidapi test/example tool.
Compiled with hidapi version 0.13.0, runtime version 0.13.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 17ef 6019 path: 1-1.1.3:1.0 serial_number: (null)
Manufacturer: Logitech Product: Lenovo USB Optical Mouse
Release: 7200 Interface: 0 Usage (page): 0x0 (0x0) Bus type: 1
unable to open device
pi@led-panel:~/hidapi/hidtest $

可行解决方案

  • 调整设备权限规则
    即使使用sudo,系统udev规则可能仍限制HID设备访问。创建专属规则文件:

    sudo nano /etc/udev/rules.d/99-hidmouse.rules
    

    写入以下内容(替换17ef和6019为你的设备VID/PID):

    SUBSYSTEM=="hidraw", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="6019", MODE="0666"
    SUBSYSTEM=="usb", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="6019", MODE="0666"
    

    保存后重载规则:

    sudo udevadm control --reload-rules && sudo udevadm trigger
    
  • 释放被占用的设备
    系统默认输入子系统可能已接管鼠标,临时禁用测试:

    sudo modprobe -r usbhid
    

    运行hidtest工具后恢复:

    sudo modprobe usbhid
    
  • 直接指定hidraw设备路径
    先找到对应hidraw节点:

    ls /dev/hidraw*
    

    然后用工具指定路径打开:

    sudo ./test /dev/hidrawX  # 替换X为实际数字
    
  • 切换hidapi后端重新编译
    64位Raspbian上默认可能用libusb后端,改用hidraw后端编译:

    cd ../hidapi
    ./configure --with-hidraw
    make clean && make
    cd hidtest && make clean && make
    sudo ./test
    

内容的提问来源于stack exchange,提问作者Hannes Campidell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 09:45:33