You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
thank you for you solution to https://github.com/libusb/hidapi/issues/24, I have build android .so lib。
first,I have use "hid_init()",and the result is 0;
second,I have got "hid_device_info" from the method "hid_enumerate(0x0, 0x0)" , and the result is (
info = HidDeviceInfo{path='0003:0003:00', vendor_id=D197, product_id=E0A097}
info = HidDeviceInfo{path='0003:000b:00', vendor_id=D1B1, product_id=E78083}
info = HidDeviceInfo{path='0003:000b:01', vendor_id=D1B1, product_id=E78083}
)
third,When i use hid_open(vendor_id, product_id, NULL) from hidapi.h(vendor_id and product_id from hid_device_info),but it is not working, and log result is "unable to open device"。
then,i was tested "hid_open" in hid.c,flag "handle = hid_open_path(path_to_open);",go into this method,i do not know why "hid_open_path" return NULL。
can you help me? thanks
i have added usb permission, but hid_open is still no working
and i hava a question about if vendor_id and product_id those two params are get from hid_enumerate(0x0, 0x0), and put those params to hid_open(vendor_id, product_id, NULL) ?
because the method hid_open in hid.c is use while condition and check "cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id".
I think i understand. your path is wrongly returned by enum_device().
/dev/bus/usb/003/003 is a path, but "0003:0003:00" isnt a path. you need to build a string leading to usb device file descriptor.
Hi @tuxun,
Thanks for helping out. Please note, that your last answer isn't correct for this case and makes a confusion:
On Android hidapi is using libusb backend, and it doesn't operate with file-paths, but instead with USB entities, like "bus_number:device_address:interface_number", which makes a path, and it is a correct representation.
coud we have an hid_open_path function using file path and another one using the other kind of path? IMHO its confusing ATM.
The hid_open_path function both take filepath and USB path?
Activity
tuxun commentedon Jan 20, 2020
Hi,
Does android ask you the permission to use the device when you start your app?
https://developer.android.com/guide/topics/connectivity/usb/host.html#permission-d
You can dig in your system logs running "logcat" as admin in a terminal, that may help you to understand whats wrong.
xmutzlq commentedon Jan 21, 2020
Hi @tuxun
thank you for your answer.
i have added usb permission, but hid_open is still no working
and i hava a question about if vendor_id and product_id those two params are get from hid_enumerate(0x0, 0x0), and put those params to hid_open(vendor_id, product_id, NULL) ?
because the method hid_open in hid.c is use while condition and check "cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id".
i thank the problem is hid_open_path(const char *path) , but i have no idea how to test this method, can you help me ? thanks.
tuxun commentedon Jan 21, 2020
Hi,
I think i understand. your path is wrongly returned by enum_device().
/dev/bus/usb/003/003 is a path, but "0003:0003:00" isnt a path. you need to build a string leading to usb device file descriptor.
You should check the file exist before open it :)
Youw commentedon Jan 21, 2020
Hi @tuxun,
Thanks for helping out. Please note, that your last answer isn't correct for this case and makes a confusion:
On Android hidapi is using libusb backend, and it doesn't operate with file-paths, but instead with USB entities, like "
bus_number:device_address:interface_number", which makes a path, and it is a correct representation.@xmutzlq
I assume you're using a build from latest master. Can you confirm?
Is it from hidtest here:
hidapi/hidtest/test.c
Line 75 in ca1a2d6
If so, it doesn't exactly describe what went wrong.
Would you be able to trace with a debugger, to catch where exactly
hid_open_pathfails?What would be helpful to know: is it goes as far as here:
hidapi/libusb/hid.c
Line 906 in ca1a2d6
or not.
tuxun commentedon Jul 26, 2020
coud we have an hid_open_path function using file path and another one using the other kind of path? IMHO its confusing ATM.
The hid_open_path function both take filepath and USB path?
Youw commentedon Jul 26, 2020
hid_open_pathtakes a platform-specific path to a device (which happens to be a file-path only for linux/hidraw backend)strictly speaking, it is intended to receive only a
pathfield ofhid_device_infoit is not designed to be human-readable, or manually constructible
it it shouldn't be confusing, as you shouldn't normally try to read it
mcuee commentedon Jan 26, 2021
libusb/libusb#830
This example might help.