tejado / android-usb-gadget

Convert your Android phone to any USB device you like! USB Gadget Tool allows you to create and activate USB device roles, like a mouse or a keyboard. 🛠🛡📱
GNU General Public License v3.0
849 stars 66 forks source link

Can you add usbserial support? #37

Open kk580kk opened 1 year ago

kk580kk commented 1 year ago

Android device that not support USB serial, so I need a app can create ttyUSB0 file for python app read.

tejado commented 1 year ago

I added a serial gadget using ACM function: https://github.com/tejado/android-usb-gadget/commit/7e29b44dd5b9b12b3f84717ee40182d3b853493f

It might require a specific Android ROM which has ACM activated. I will look into other functions which could be an alternative to ACM abd are usually part of Android.

kk580kk commented 1 year ago

My device is XIAOMI pad 5, and this rom didn't have usb serial driver lib.

1|nabu:/system/lib # modprobe -d /vendor/lib/modules usbserial vendor=0x1a86 product=0x7523
modprobe: alias lines in modules.alias must have 3 entries, not 5
modprobe: alias lines in modules.alias must have 3 entries, not 4
modprobe: alias lines in modules.alias must have 3 entries, not 4
modprobe: alias lines in modules.alias must have 3 entries, not 4
modprobe: LoadWithAliases was unable to load usbserial
modprobe: Failed to load module usbserial: No such file or directory

Can you add gadget serial support like https://android.googlesource.com/kernel/common/+/bcmdhd-3.10/Documentation/usb/gadget_serial.txt

tejado commented 1 year ago

I did - it is in the commit I pointed out before. It is done over gadget CDC ACM (see your link). Can you provide me your Device Info in Android USB Gadget tool app on your device?

eadmaster commented 2 months ago

Is there an example on how to use this? I simply like to echo all incoming messages from serial onscreen.