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

Continous data bottleneck location #468

Open FrancoHMJP opened 1 year ago

FrancoHMJP commented 1 year ago

Hi, We are currently using the library as a plugin for a Unity app.

Unity script refresh rate is 30Hz so we are polling port.read() every ~30mS. Device is sending continous data at 9600 baud but we are loosing packets.

1) Is there any "interrupt driven" usage of the library in order to buffer incoming data? 2) Is this a common/know limitation of Android USB API? If so, whats the procedure to handle this?

Lastly, we are in doutb why the "protocol header" is 2 bytes?. We always seem to have 2 bytes more thant the returned by port.read(). ie: device sends 0x01-0x02-0x03-0x04, port.read() returns 2.

kai-morich commented 1 year ago

Hi

there are various methods to improve throughput: