mik3y / usb-serial-for-android

Android USB host serial driver library for CDC, FTDI, Arduino and other devices.
MIT License
4.72k stars 1.57k forks source link

Did you do this by reverse engineering? #576

Closed midnight-wonderer closed 2 months ago

midnight-wonderer commented 2 months ago

Hi, I taught myself how to write a USB device driver, and I use some of the code here as a reference, specifically the CH34x one. It has a lot of magic numbers and pointless operations.

Do you guys (maintainers, collaborators, or contributors) implement this by sniffing wire protocol? Impressive!! If that is the case.

For instance, https://github.com/mik3y/usb-serial-for-android/blob/28506a9bf97faeee6ab82361b0ae0f1531a753ef/usbSerialForAndroid/src/main/java/com/hoho/android/usbserial/driver/Ch34xSerialDriver.java#L167 This one is not actually a state but a command to read the silicon version number. This version number should be used to implement things differently to support different hardware.

There are many more; most of the magic numbers used are unidentifiable. (I use the official driver as a reference.) Are you looking for improvement (e.g., naming things, removing redundant operations, or documenting), or are you OK with how things are? (Not that I can directly contribute myself, as I don't have the setup for testing/debugging Android devices. I'm just curious about the state of the project.)

kai-morich commented 2 months ago

Reverse engineering was done by different people or reused from other open source implementations. As there is no publicly available documentation, we should keep as is.