tarm / serial

BSD 3-Clause "New" or "Revised" License
1.6k stars 451 forks source link

How catch Lost Serial port(for example USB virtual rs-232 unplug) #121

Open irbismaestro opened 2 years ago

irbismaestro commented 2 years ago

Hi Thanks for library. I have a question. My environment: Linux Centos 7x 64 . Usb Virtual rs-232 . Its mapped as /dev/USB0(1,2,3..) or /dev/ACM0(1,2,3...) library work but when USB device unplug, my application have crashed and exit. How I can catch this event(unplug) and reconnect(or wait connection),?

FObersteiner commented 1 year ago

I think that calls for a state machine that catches the error and goes into a (re)connect state when the connection is lost. But I guess that should not be part of a basic serial port library such as this.