Rxtx com port
I am using rxtx api to read data from GPS device via COM port. Right now I am finding the correct COM port by reading the config file and looking for the specified port. The problem I am facing is that if the device is disabled the com port might change and the user needs to know to change the config file. I wrote an app like this in C # and was able to list the Windows device name instead of the COM port and I went through the com ports until the device name matched the name in the config file. Using this method, nothing in the configuration file should change, even if the used COM port changes. Is there a way to do this using the rxtx api?
Thanks in advance!
a source to share
If anyone is interested ...
I have created a Windows Service in C # that monitors a socket. If a client connects to this socket, the service collects the port name and device ID that is on that port and sends the data in a string through the COM port, after which the client can parse that string to get the data it needs.
In my case, the transmitted string is: "ACPI \ PNP0501 * PNP0501, COM1, PCI \ VEN_8086 & DEV_29B7 & SUBSYS_02111028 & REV_02 PCI \ VEN_8086 & DEV_29B7 & SUBSYS_02111028 PCI, VEN_8086 & DEV_297807 & COMB3 Vid_067b & Pid_2303 & Rev_0400 USB \ Vid_067b & Pid_2303, COM5 "
When I parse it, I see that ACPI \ PNP0501 * PNP0501 is the device ID for COM 1, there are three device IDs for COM3 and two device IDs on COM5.
It's not the best way to handle it, but it's good enough for my needs and it saved me from JNI. :)
a source to share
CommPortIdentifier.getPortIdentifiers lists all ports on the system that can be used by the Javacomm API. Go through them to find the port your device is connected to.
a source to share
If you want to get the name associated with a device on a COM port (especially if a driver is installed to provide it), you have to do so with the dreaded Java-> Native Interface swipe to talk to the Windows APIs that collect this information. C # is nice as this information is collected and provided to you, but in Java you need to take this extra step.
Windows detection can be helpful. I'm not sure if the API provides this functionality.
a source to share