mik3y / usb-serial-for-android

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

Detect end of stream with onNewData #462

Closed emendo-web closed 11 months ago

emendo-web commented 1 year ago

Hello,

Thank you for this package.

From what I could see of this package how can I know that my data has all arrived before processing it?

With the onNewData method I receive data substitution

Would there be a solution to know when all the bytes received?

InputStream returned -1 if reading data is complete

Or is the only solution to detect a delimiter character and close the stream when found ?

Thanks, Cyril

kai-morich commented 1 year ago

see https://github.com/mik3y/usb-serial-for-android/wiki/FAQ#when-reading-a-message-why-dont-all-bytes-arrive-at-the-same-time