Skip to content

SerialPort Open fails with 0x8007001f #27729

@maloo

Description

@maloo

Some USB serial port drivers does not support the EscapeCommFunction call made indirectly in SerialPort.Open at https://github.com/dotnet/corefx/blob/master/src/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs#L223.
These drivers don't use/support RTS/DTR so SerialPort.DtsEnable should always be false. SerialPort.Open always sets DtrEnable. This will trigger a DCB change with DTR_CONTROL_DISABLE (which succeeds). But this call is always followed by the EscapeCommFunction(DtsEnable ? SETDTR : CLRDTR) call which fails and triggers an IOException with error code 0x1f.
I propose that you don't call EscapeCommFunction when you already disabled this function using the DCB just above. Or at least allow this behavior to be overridden so SerialPort can be used with all USB serial port drivers.
Using WSL cu, Win32 or other terminal programs works just fine with these drivers. It is only .Net SerialPort that can't handle this and throws an exception in this non fatal error case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IO.Portsbugin-prThere is an active PR which will close this issue when it is merged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions