简体   繁体   English

libusb_open在jni android中返回LIBUSB_ERROR_ACCESS

[英]libusb_open return LIBUSB_ERROR_ACCESS in jni android

I want to access a usb device from c++ native code in ROOTed android device ( 4.4 )using libusb1.0.22 . 我想使用libusb1.0.22从ROOTed android设备( 4.4 )中的c ++本机代码访问usb设备。 First, I call libusb_init successfully and then call libusb_open but get LIBUSB_ERROR_ACCESS error. 首先,我成功调用libusb_init,然后调用libusb_open但得到LIBUSB_ERROR_ACCESS错误。 Why this error is occurring while the device is rooted? 为何在设备植根时发生此错误?


A 一种

Also on rooted device you MUST permissions! 同样在root设备上你必须权限! (like linux...) (比如linux ...)

(1) You MUST to turn off the SELinux (setenforce 0) (1)你必须关闭SELinux(setenforce 0)

(2) You MUST to give file permissions (chmod 666 /dev/bus/usb/*/*), after that your USB connected to the Android device. (2)你必须提供文件权限(chmod 666 / dev / bus / usb / * / *),之后你的USB连接到Android设备。 you can do it with adb over wifi if you have only one USB port. 如果你只有一个USB端口,你可以通过wifi上的adb来做。 (or to change the device rules to attach USB device node with 666 permissions) (或更改设备规则以附加具有666权限的USB设备节点)

(*) You can use "adb shell run-as" to check your App permissions. (*)您可以使用“adb shell run-as”来检查您的应用程序权限。

B

(1) You need to check that your device is also work in HOST mode. (1)您需要检查您的设备是否也在HOST模式下工作。

(2) You need to check if your USB cable is OTG. (2)您需要检查USB电缆是否为OTG。

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

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