-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failing libusb_init example #1928
Comments
Downgrading libusb to 1.0.23 does not fix it. Not sure what else we might have changed that could be the problem. |
Same bug on Android 10, (oukitel wp5) |
Ok, i found the issue! We need to add a call to:
libusb_set_option(context, LIBUSB_OPTION_WEAK_AUTHORITY);
just BEFORE the libusb_init() one. |
Hello, though i solved the issue regarding the wiki libusb example, it does displays me the device information name, manufacturer...but i cannot get to read data from my device(which is a MIDI device: Akai midimix - works fine on Android), [edit] |
@ChewbakaJones what code are you trying to run? Have you modified it so that it uses libusb_wrap_sys_device + libusb_get_device instead of libusb_open? I have an example modification for a sports watch here. Will give your libusb_set_option fix a try later. |
Here is a modified version of the tool provided by libusb adapted for Termux, usefull to dump infos and debug USB devices, termux-usb-test-infos.c : Example usage (build it, then usage): $ gcc -o termux-usb-test-infos termux-usb-test-infos.c -lusb-1.0 $ termux-usb -l
|
What input? What is it suppose to give you? termux-usb just allows existing libusb application to work (after some modifications) on android without root, you cannot really use termux-usb to reverse-engineer (or create from scratch) the communication with any usb device
No, that code just shows an example of the modification needed to make it possible for existing libusb-based programs to work via the android API without root.
The application I forked, ttwatch, works on android with termux-usb after those modifications, yes. |
I just want to read the raw midi events with libusb, like when i'm turning a knob on the device it must send a packet with 1 byte that is the value of the knob, just like for a gamepad. Nice to hear you got the smartwatch working, i guess if this works my device is much more simple... |
I tried mofidying the minimal snippet above according to @ChewbakaJones' explanation: #include <stdio.h>
#include <assert.h>
#include <libusb-1.0/libusb.h>
int main(int argc, char **argv) {
libusb_context *context = NULL;
libusb_set_option(context, LIBUSB_OPTION_WEAK_AUTHORITY);
assert(!libusb_init(&context));
libusb_exit(context);
} I'm still getting an error: ~: termux-usb -e ./usbinit /dev/bus/usb/001/003
/home/builder/termux-packages/.termux-builder/libusb/src/libusb/os/linux_usbfs.c:419: void op_exit(struct libusb_context *): assertion "init_count != 0" failed
/data/data/com.termux/files/usr/libexec/termux-callback: line 3: 16012 Aborted $TERMUX_CALLBACK "$0"
|
This is an error with libusb, see: libusb/libusb@e78cafb It should be fixed in the next version of libusb. It should only affect the exiting of libusb. After adding the line: Your source code isn't doing anything so you just see the error. |
I verified it works without error by building libusb from the GitHub source in termux. If you want a step-by-step on how to build it, let me know. It's just a few lines in the terminal. |
Closing since its fixed and not a termux-app issue. Someone should update the wiki though. |
Problem description
I'm trying to follow https://wiki.termux.com/wiki/Termux-usb. Installing Termux:API and the packages worked.
termux-usb -l
works too. However, theusbtest.c
example fails.Steps to reproduce
I wrote a minimal version named
usbinit.c
:Output:
Expected behavior
usbinit should execute without failure.
Additional information
The text was updated successfully, but these errors were encountered: