Skip to content

SerialPort.closePort not calling native interface on Windows when USB serial adapter is disconnected #107

Closed
@pietrygamat

Description

@pietrygamat

As noted in #63, There are several methods in the library that are described in javadoc as returning true or false to signify a success, but in fact throwing an exception on failure. The particulary nasty stack for us is:
closePort -> removeEventListener -> setEventMask because in the case where USB serial adapter is already disconnected, this throws an exception before closePort -> serialInterface.closePort(portHandle); is fired.

As a result, the device is not released. Some other software we use that also queries serial ports still sees that ghost port (or sees multiple COM ports, with duplicated number if the adapter is reconnected), even when Device Manager does not.

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