mik3y / usb-serial-for-android

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

Connection closed warning in logs #547

Closed recser closed 6 months ago

recser commented 8 months ago

Hello, i keep getting the bellow warnings in the logs and don't know if this is something normal or I am doing something wrong? The main idea is that I close a port to change its baud rate (dont know if this is the recommended way or I should just change the parameters to new baud rate without close and open each time) from 19200 to 115200 and the other way around. I do it quite often(to print information on a thermal printer) and getting this warnings make me feel like i could be doing something wrong. Also recently I've started to experience sudden crashes of my application without any logs or dialog to submit feedback, which occurs primarily during cycles when i am writing on the port.

Any help or suggestion is appreciated!

Thanks

kai-morich commented 8 months ago

The blocking SerialInputOutputManager wakes up on connection close and prints this warning. This is not an issue

recser commented 8 months ago

Hi, thanks for the reply. From the traces collected i can see that the android kills the application, although it is not clear why? Could it be that the work done reading the serial data is deemed as too 'heavy' and the OS kills the application, since i run it in the background ?

kai-morich commented 7 months ago

to prevent your app getting stopped, you have to use a foreground service + notification while in background as done here