Why am I getting a Java NoSuchPortException when the port exists?

Posted by user258526 on Stack Overflow See other posts from Stack Overflow or by user258526
Published on 2010-06-11T23:09:11Z Indexed on 2010/06/11 23:12 UTC
Read the original article Hit count: 163

Filed under:
|

Got the following production code below, I'm using it for a new driver. portName is COM4 and this port exists on the PC (and I can connect to it with hyperterminal), so why does Javacomm throw a NoSuchPortException? COM4 shows up fine in device mgr. too

    final String portName = getSerialPort();
    try {
        final CommPortIdentifier id = CommPortIdentifier.getPortIdentifier(portName);
        port = (SerialPort) id.open(getName(), 1000);
    } catch (NoSuchPortException nspe) {
        report(SeverityCode.LEVEL2, getName(), "PIN Pad is not connected to " + portName + " port, or the port does not exist.");
        return;
    } catch (PortInUseException piue) {
        report(SeverityCode.LEVEL2, getName(), portName + " port is already in-use by some other device. Reason: " + piue.getMessage());
        return;
    }

© Stack Overflow or respective owner

Related posts about java

Related posts about serial