-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Description
Recreate issue requires a USB serial device that doesn't allow Dtr setting. In this case it was a Sirit/Motorola/Zebra FX9500 UHF RFID reader.
The code to reproduce is just "new SerialStream("COM123", 115_200).Open()"
This will fail with the error "Device is not functioning properly". Error occurs in DtrEnable that gets set in ctor of SerialStream here.
I have downloaded dotnet/runtime and built the System.IO.Ports.dll without this line. Then everything works fine.
Expected behavior is that DtrEnable is not set unconditionally in the constructor. It should only be set if is different from device current value. If this value is impossible to get, there should be some other way to configure SerialPort before Open that prevent this call from happening. The current behavior is making it impossible to use many devices. Behavior is also not the same in Windows and Linux. In Linux it is possible to get around the issue by setting DtrEnable property of SerialPort before calling Open, this can prevent SerialStream from setting the value. But this setting has to be hard coded to the value that works with the device, so Linux behavior is also broken and should also be fixed.
Configuration
Same on .Net 3.1 and .Net 5 preview 5
Running on Windows x64, sort of works in Linux
Regression?
I think it used to work in .Net Framework, but it could have been another type of device. Latest version of nuget does not work. But it has never worked in .Net Core 3.x or 5.0.
@krwq, anything familiar?