altera2015 / usbserial

Flutter Android USB Serial plugin
BSD 3-Clause "New" or "Revised" License
119 stars 83 forks source link

Truncated received data #85

Closed SevenK34 closed 10 months ago

SevenK34 commented 1 year ago

Hi, thanks for the package, intuitive and efficient :)

I am using this package to create a command interpreter between my Arduino Uno R3 and my smartphone, connecting them via OTG. For testing purposes, for now I am just reading messages from the Arduino and displaying them in my application. The problem is that messages are often truncated and sometimes data is lost. For example, characters are not transmitted correctly or are lost altogether.

Screenshot of my debug logs: image Screenshot of messages received inside the application image

I have tried using different baud rates, sending messages every 100ms, 1s and 8s and more. I have also tried sending short messages (about 8 characters maximum), they were a little more stable but always the same problem. The data is lost or truncated every time. I tried using serial monitors found on Google Play and they work fine, messages are received correctly, so I think the problem is not OTG.

I think it is something related to the buffer or, maybe a timeout in the reading process that doesn't wait the messages to be completely transmitted. I don't know, maybe when the data is read the output buffer of my Arduino is not cleared. These are just guesses, I am not sure.

Can someone please help me?

altera2015 commented 10 months ago

Looks like a serial setup mismatch, check baud rates stop bits, data bits etc.