java-native / jssc

Java library for talking to serial ports (with added build support for maven, cmake, MSVC)
https://discord.gg/RBsUfE9sX9
GNU Lesser General Public License v3.0
164 stars 53 forks source link

How to get notified of disconnect / connection close #89

Open muety opened 3 years ago

muety commented 3 years ago

Is there some way of getting notified once the plug is pulled out?

tresf commented 3 years ago

Are you talking about a USB adapter plug? That might be possible utilizing some additional logic such as that proposed in #69 which aims to query some of the lower-level USB information. Until that's implemented, listening for a timeout exception may be the only viable sign. Note, USB information wasn't originally part of the purpose of this library but as USB-Serial adapters become the norm, I find it to be only natural that the library should be enhanced to make the experience with them better.

Furthemore, this is a rarely updated open source library, so feel free to begin the code yourself and issue us a pull request with the requested changes if you need to move this along faster. 🍻