Skip to content

Conversation

@Grimler91
Copy link
Member

@Grimler91 Grimler91 commented Apr 3, 2025

It contains the following functions:

  • termux_usb_get_device_list
  • termux_usb_free_device_list
  • termux_usb_open
  • termux_usb_get_config_descriptor
  • termux_usb_free_config_descriptor

These functions are replacements for the corresponding libusb_* functions, kind of. The termux variants uses structs like struct termux_usb_device and struct termux_usb_config_descriptor that are similar, but not identical, to libusb_device and
libusb_config_descriptor. They work by calling termux-api and get back information about devices and configs as a protobuf stream.

The free functions also frees all array elements, whereas the libusb variants only frees elements that have a reference count of 1 or less. For the termux variants where do not keep track of the reference count, so information that should be kept around should be memcpy'ed or similar before termux_usb_free_* is called.

termux_usb_open requires user interaction. It calls termux-api which opens the device through the android API, which shows a prompt to the user to accept or deny opening the device.

See the accompanying termux-api PR for the other side of the coin: termux/termux-api#759


I also have two test programs that I will incorperate in a testsuite later: https://github.com/Grimler91/termux-api-package/tree/usb-protobuf-with-test-programs

It contains the following functions: * termux_usb_get_device_list * termux_usb_free_device_list * termux_usb_open * termux_usb_get_config_descriptor * termux_usb_free_config_descriptor These functions are replacements for the corresponding libusb_* functions, kind of. The termux variants uses structs like struct termux_usb_device and struct termux_usb_config_descriptor that are similar, but not identical, to libusb_device and libusb_config_descriptor. They work by calling termux-api and get back information about devices and configs as a protobuf stream. The free functions also frees all array elements, whereas the libusb variants only frees elements that have a reference count of 1 or less. For the termux variants where do not keep track of the reference count, so information that should be kept around should be memcpy'ed or similar before termux_usb_free_* is called. termux_usb_open requires user interaction. It calls termux-api which opens the device through the android API, which shows a prompt to the user to accept or deny opening the device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant