Fix interpreting baud rate bitmask as decimal value#123348
Fix interpreting baud rate bitmask as decimal value#123348mrek-msft wants to merge 10 commits intodotnet:mainfrom
Conversation
…(obtained from user).
|
@dotnet-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Pull request overview
This pull request fixes an issue where baud rate bitmask values from Windows drivers were being incorrectly interpreted as decimal values, causing validation errors. Some device drivers (like Silicon Labs USB to UART converters) return a decimal baud rate value instead of a bitmask, while Windows documentation specifies bitmasks should be used.
Changes:
- Added a new helper method
ConvertMaxBaudBitMaskToBaudRateto intelligently interpret thedwMaxBaudfield as either a bitmask or decimal value - Updated the BaudRate property setter to use the converted value for validation
- Updated the SerialStream constructor to use the converted value for validation
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
Show resolved
Hide resolved
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.Ports/src/System/IO/Ports/SerialStream.Windows.cs
Outdated
Show resolved
Hide resolved
|
Tagging subscribers to this area: @dotnet/area-system-io-ports |
MihaZupan
left a comment
There was a problem hiding this comment.
Is there a way for us to test this in CI without a weird device/driver?
It is possible to run it on virtual machine with emulated ports. Not sure if it runs in this way in CI though. |
Intended to fix !119105.