felHR85 / UsbSerial

Usb serial controller for Android
MIT License
1.8k stars 585 forks source link

SerialInputStream read function #252

Open zcsrf opened 5 years ago

zcsrf commented 5 years ago

There seems to be an issue with the SerialInputStream read to buffer function.

If the user calls the serialInput.read() to check for new data and afterwards calls serialInput.available() to find out how many more bytes are available the following call to serialInput.read(buffer) should obtain all the previous bytes of data obtained and only afterwards issue a issue a syncRead to get the rest of the data.

The current implementations makes it a bit more complex to implement communication API where the first byte of the message is always the size.

tamasharasztosi commented 5 years ago

I'm having the same problem.