I'm developing an application that needs to be able to communicate with devices over Serial Comms on Windows OS. The application is written in Java. I am using the jSSC library. (Javax.comm has issues and RxTx has no Java 8 support apart from an unofficial update) The devices may connect directly to the PC using a Serial Port, or alternatively using a USB-to-Serial converter.
My Question: COM ports on windows are dynamic. This raises an issue for defining which comm port to connect to. Is there a way to automatically figure out which COM port to connect to?
So far the only solutions I have been able to come up with involves scanning all the com ports for active ports, saving this list and then asking the user to insert the device and performing another scan - the additional COM port will then be the one to connect to.
Alternatively, the device will respond to a specific 'identification' packet: I can open each COM port and send this packet and evaluate the response. This has the risk of the other devices being hijacked for a short period of time which is not ideal.