【发布时间】:2017-10-13 04:51:57
【问题描述】:
这里我使用库 usb4java 来访问我的 USB 设备。
问题是我在尝试声明我的 USB 设备接口时出错。错误在这一行:
int msg = LibUsb.claimInterface(deviceHandler, 1);
错误:USB 错误 3:无法声明接口:访问被拒绝(权限不足)
是否有人知道我为什么会出现此错误或如何解决?
【问题讨论】:
这里我使用库 usb4java 来访问我的 USB 设备。
问题是我在尝试声明我的 USB 设备接口时出错。错误在这一行:
int msg = LibUsb.claimInterface(deviceHandler, 1);
错误:USB 错误 3:无法声明接口:访问被拒绝(权限不足)
是否有人知道我为什么会出现此错误或如何解决?
【问题讨论】:
对于 Linux 系统,听起来好像用户无权访问 USB 设备。
这可以通过在 /etc/udev/rules.d 中添加规则来更改,例如名称为“50-usb-permissions.rules”和内容
SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678",
MODE="0666",GROUP="users"
十六进制数字 1234 是供应商 ID,5678 是连接的 USB 设备的产品 ID,可以通过“lsusb -v”找到。示例规则允许用户组“users”访问指定的 USB 设备。重新启动后,将应用该规则。
根据 Linux 版本,路径可能会有所不同。
【讨论】:
我遇到了同样的问题,我的环境是 Mac OS X 10.9
经过长时间的谷歌搜索,我终于找到了这个帮助我的just get the names of USB devices attached to a system?,现在我的代码就像魅力一样。
解决方法是here,因为mac会自动认领设备,我们可以为它创建一个dummy driver。
这里是如何做的步骤。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- This is a dummy driver which binds to Proxmark. It -->
<!-- contains no actual code; its only purpose is to -->
<!-- prevent Apple's USBHID driver from exclusively -->
<!-- opening the device. -->
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.proxmark.driver.dummy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.0d1</string>
<key>IOKitPersonalities</key>
<dict>
<!-- The Proxmark3 USB interface -->
<key>Proxmark3</key>
<dict>
<key>CFBundleIdentifier</key>
<string>com.apple.kpi.iokit</string>
<key>IOClass</key>
<string>IOService</string>
<key>IOProviderClass</key>
<string>IOUSBInterface</string>
<key>bConfigurationValue</key>
<integer>1</integer>
<key>bInterfaceNumber</key>
<integer>0</integer>
<key>idProduct</key>
<integer>{your-usb-hardware-product-id}</integer>
<key>idVendor</key>
<integer>{your-usb-hardware-vendor-id}</integer>
</dict>
</dict>
<key>OSBundleLibraries</key>
<dict>
<key>com.apple.iokit.IOUSBFamily</key>
<string>1.8</string>
</dict>
</dict>
</plist>
注意:{your-usb-hardware-product-id} 和 {your-usb-hardware-vendor-id} 必须是您自己的硬件 id,可以从 关于本机 - 系统报告 - 硬件 - USB。
sudo chown -R root:wheel Proxmark3.kext
sudo chmod -R 755 Proxmark3.kext
sudo kextcache -system-caches
【讨论】:
当 adb 服务器在 MacOS 上运行时出现此错误。重新启动计算机释放了界面,以便我可以再次声明它。但是adb每次启动都会锁住USB接口,需要重新启动电脑。
【讨论】: