Clone this wiki locally
This is a collection of FAQ-style troubleshooting tips.
If your problem isn't covered here, or you'd like to suggest a new addition, please use the mailing list (linked at left). We do not read the wiki comments.
I am using a custom ROM or older Android build and nothing works.
Stop right there; this project probably isn't for you.
usb-serial-for-android only supports devices which comply with the Android USB Host API. For a partial list of compatible devices, see CompatibleAndroidDevices.
How do I access
You don't; see previous question.
/dev/tty* is the Linux kernel's driver interface to various serial devices. Certain devices and custom ROMs may expose serial devices this way, but this library does not use this interface.
I am using an Arduino Uno, Sparkfun Pro Micro, or other Arduino and "if (Serial)" doesn't work.
Some Arduinos use the DTR line to determine serial channel readiness. In your Android code, call
When reading a message, why don't all bytes arrive at the same time?
The protocol layer does not guarantee all bytes will arrive in a single message. In fact the protocol layer doesn't have any knowledge of what your "message" is — it is just an interface for sending a serial stream of bytes.
For example, to receive a 100 byte string, you might read 64 bytes, then 36 bytes, instead of a single message of 100 bytes.
You need to account for this problem when designing your protocol. Some common techniques:
- Fixed length messages: If you a message is always going to be 100 bytes, just keep reading until you have all 100.
- Length-prefixed messages: Prefix every message with a fixed-length
sizevalue; your message is complete after you've read
- Newline-terminated messages: Read until you see a
\n(or any other "terminal" character).