-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
Add termux-api support to libusb #5831
Comments
Aa part of pyusb/pyusb#287 I had the idea that the usb library can open the device by executing termux-usb and exec'ing a small helper that passes the device fd back to the original app (via a unix pipe similar to how termux-api sends the fd back to termux). I wrote https://gist.github.com/normanr/9816a5db24dda0ce87a17da342a9684c as a proof of concept and it works very well. A couple of small changes to termux-api would make this smoother:
|
Hi, this would be a great improvement and we would be very happy to merge such a PR! |
This issue/PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think we may patch libusb to use termux-api for enumerating devices and getting device fds. I think it may be done by implementing some pretty dumb binary which will be invoked by termux-usb binary in order to get answers and file descriptors through some temporary unix socket (maybe passed as non-closeable on exec to target process). |
@twaik I did some proof-of-concept stuff in usb branch of termux-api{,-package} were programs could link to libtermux-api.so and get file descriptors through two functions Having some simple functions as in the first attempt at an implementation would probably be useful, I should try to clean that up.. Maybe during the upcoming holidays |
See if this may help: there is a project called AnotherTerm similar to Termux and they implement a patched version libusb with helper service in the app: https://green-green-avk.github.io/AnotherTerm-docs/installing-libusb-for-nonrooted-android.html#main_content I do not have much knowledge in this field but really glad to see progress of libusb in Termux. Look forward to being able to run Arduino IDE and PlatformIO one day in Termux (perhaps with proot-distro) and we can burn a program into microcontrollers! |
green-green-avk implemented the same thing as @Grimler91 did. Libusb simply interacts with some socket owned by Android Activity. |
Probably it will be a good idea to move some part of code to termux-app. Effective polling for usb events is not possible without service running in background. termux-api's BroadcastReceiver can not be used for this since it is killed after some period of time. |
It should be possible to use existing apps that use libusb without requiring them to individually support termux-usb.
Places where this has come up recently:
My proposal would be to enhance libusb so that (on non-rooted devices) it can use termux-api to enumerate and connect to usb devices. It would then be transparent to apps how they end up getting access to the usb devices that they use.
The text was updated successfully, but these errors were encountered: