mirror of
https://github.com/mik3y/usb-serial-for-android
synced 2025-06-16 12:26:41 +00:00
Updated Troubleshooting (markdown)
parent
42185ff771
commit
a8114e95fa
@ -17,3 +17,16 @@ You don't; see previous question. `/dev/tty*` is the Linux kernel's driver inte
|
||||
## 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 `setDTR(true);`
|
||||
|
||||
|
||||
## 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 `size` value; your message is complete after you've read `size` more bytes.
|
||||
* Newline-terminated messages: Read until you see a `\n` (or any other "terminal" character).
|
Loading…
x
Reference in New Issue
Block a user