Skip to content

Only 63 COM Ports can be opened concurrently on Windows #235

@BenjaminLetz

Description

@BenjaminLetz

I have more than 64 COM Ports configured in my Windows System. Windows 10 supports 4096 COM Ports.

After opening 63 Serialports with SerialPort serialPort = (SerialPort) commPortIdentifier.open("NRSerialTest", 0); my application just "waits" at the opening of the 64th. I suspect that only 63 SerialPorts can be opened at tha same time, but I do not get why.

I tried looking in the code, but did not find any restrictions.

Here is a small test application I wrote:

` public static void main(String[] args) {

    ArrayList<CommPortIdentifier> commPortIdentifiers= new ArrayList<>();
    ArrayList<SerialPort> serialPorts= new ArrayList<>();
    for(String s:NRSerialPort.getAvailableSerialPorts())
    {
        System.out.println(s);
        try {
            CommPortIdentifier commPortIdentifier = CommPortIdentifier.getPortIdentifier(s);
            commPortIdentifiers.add(commPortIdentifier);
            SerialPort serialPort = (SerialPort) commPortIdentifier.open("NRSerialTest", 0);
            serialPorts.add(serialPort);
            //serialPort.close();
        } catch (NoSuchPortException e) {
            System.out.println("Not a Port: " + s);
        } catch (PortInUseException e) {
            System.out.println("Port in Use: " + s);
        }
    }
}`

When I add the serialPort.close(); line, the program finishes with all ports being opened once.

Some Information abput my system:
Windows 10 22H2 Build 19045
Java 11.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions