[英]PC usb host communicate with Android accessory mode through libusb
I want to communicate to Android accessory mode from HOST PC(linux) through libusb and I have already set up android accessory mode. 我想通过libusb从HOST PC(linux)交流到Android附件模式,并且我已经设置了android附件模式。 but I can't get usb handle.
但我无法获得USB手柄。
$ lsusb
Bus 001 Device 010: ID 18d1:2d00 Google Inc. Android-powered device in accessory mode
when I use libusb to get this usb handle , it always return NULL. 当我使用libusb来获取此USB句柄时,它始终返回NULL。 How to fix it ?
如何解决? Thanks.
谢谢。
libusb_init(NULL);
struct libusb_device_handle* handle = libusb_open_device_with_vid_pid(NULL, 0x18d1,0x2d00);
// this handle always return NULL
I opened debug message in libusb by libusb_set_debug(NULL, 3);
我通过
libusb_set_debug(NULL, 3);
在libusb中打开了调试消息libusb_set_debug(NULL, 3);
And I found that this user do not have permission to visit this usb device. 而且我发现该用户没有访问此USB设备的权限。
I fixed it by adding a file named 51-android.rules
in /etc/udev/rules.d/
我通过在
/etc/udev/rules.d/
添加名为51-android.rules
的文件来修复它
51-android.rules : 51-android.rules:
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", GROUP="plugdev"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.