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

how to regex, serial read buffers #448

Closed kashi022410 closed 2 years ago

kashi022410 commented 2 years ago

Dear, Mr I try read data from usb serial port and it is like (23610). Then convert it to string then split "(" ")" but it crashes. Would you have any idea? image

kai-morich commented 2 years ago

Not necessarily all bytes arrive in a single message. You should buffer until complete, see https://github.com/mik3y/usb-serial-for-android/wiki/FAQ#When_reading_a_message_why_dont_all_bytes_arrive_at_the_same_time