-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
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.