Android (USB)
USB-serial runs in Rust: the
android-usb-serial crate (a port of
usb-serial-for-android on top of nusb). Kotlin only asks for USB permission and
hands over the device file descriptor.
Supported chips: FTDI (FT232R, FT2232, FT4232, FT232H, FT-X), Silicon Labs CP210x (CP2102/2104/2105/2108), Prolific PL2303 (all types incl. HXN/GC/GS/GT), WCH CH340/CH341, Chrome OS CCD, Unisoc GSM modems, and any CDC-ACM device (Arduino, RP2040, STM32 VCP, ESP32-S2/S3 native USB, CH9102, CH343, modems).
Nothing to configure in the app:
- The plugin adds a
USB_DEVICE_ATTACHEDintent filter for those devices to your activity, so Android offers to open the app when one is plugged in. open()asks the user for USB permission the first time.available_ports()lists attached devices. Paths are the USB device name (/dev/bus/usb/001/002); multi-port chips get one path per port (/dev/bus/usb/001/002#0,…#1).bytesToWrite()is always 0 (writes complete synchronously).- A chip that answers a control request with a short packet gives an error on that
call (e.g.
readClearToSend()), not a crash.
Bluetooth LE serial (ble://, feature ble) works on Android too, see
Bluetooth LE for its permissions (added to the app manifest only with ble).
The Android emulator has no USB passthrough; test with a phone, or use tcp://
to a bridge on the host (the emulator reaches the host as 10.0.2.2).