Enumerate ports twice to ensure no leaks or duplicates

This commit is contained in:
Will Hedgecock 2021-11-17 01:03:56 -06:00
parent bb559137c9
commit 79d09f38c9
1 changed files with 5 additions and 1 deletions

View File

@ -85,7 +85,11 @@ public class SerialPortTest
{
System.out.println("\nUsing Library Version v" + SerialPort.getVersion());
SerialPort[] ports = SerialPort.getCommPorts();
System.out.println("\nAvailable Ports:\n");
System.out.println("\nAvailable Ports (First Try):\n");
for (int i = 0; i < ports.length; ++i)
System.out.println(" [" + i + "] " + ports[i].getSystemPortName() + ": " + ports[i].getDescriptivePortName() + " - " + ports[i].getPortDescription());
ports = SerialPort.getCommPorts();
System.out.println("\nAvailable Ports (Second Try):\n");
for (int i = 0; i < ports.length; ++i)
System.out.println(" [" + i + "] " + ports[i].getSystemPortName() + ": " + ports[i].getDescriptivePortName() + " - " + ports[i].getPortDescription());
SerialPort ubxPort;