See USB infos in termux wiki;
List connected USB devices and get ID:
termux-usb -l
Run script (test) with selected device:
termux-usb -r -e ./usbtest_rw1.py.sh /dev/bus/usb/001/002
Working with Python 3.8.
Theoretically only needs PyUSB
.
Enganced with IPython
, PyFtdi
(two formatting functions).
Style check and formatting with Flake8
and Black
.
Create environment:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- Android restricts device access, see comments on libusb
- Termux only provides a file descriptor (probably queried from Android)
- device handles etc. have to be retrieved from a single file descriptor
- my module
usblib.py
provides a functiondevice_from_fd(fd)
that extends thePyUSB 1.0
library to provide aDevice
object from a file descriptor number that can be used as usual
- own implementation, guided by:
- only tested with cp2102 usb-ttl board v4.2 device
- throughput, performance unknown, (seems to work for me)
- flow control (RTS/CTS, DTR/DSR, Xon/Xoff) untested
- does transmission have to be in chunks, with size reported in endpoint info or does the libusb1 library handles this? - works fine with chunks, but may drop in performance for heavy use?
- sync writing?, can a chunk be transmitted in part only (read/write)?
- no interrupting of transmissions
- test scripts supplied for various simple situations; tests currently only with connected device
- example usage script for DSO138mini data dumps
Hopefully my fix can be adopted in the original PyUSB library. Else, free for all. :-)
Copyright (c) 2019 Querela. All rights reserved.
See the file "LICENSE" for information on the history of this software, terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.
All trademarks referenced herein are property of their respective holders.