Skip to content

Fix interpreting baud rate bitmask as decimal value#123348

Open
mrek-msft wants to merge 10 commits intodotnet:mainfrom
mrek-msft:dev/mrek/serial_baud_bitmask_bitrate_missmatch
Open

Fix interpreting baud rate bitmask as decimal value#123348
mrek-msft wants to merge 10 commits intodotnet:mainfrom
mrek-msft:dev/mrek/serial_baud_bitmask_bitrate_missmatch

Conversation

@mrek-msft
Copy link
Member

Intended to fix !119105.

Copilot AI review requested due to automatic review settings January 19, 2026 13:20
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 19, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 19, 2026
@mrek-msft
Copy link
Member Author

@dotnet-policy-service agree company="Microsoft"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ConvertMaxBaudBitMaskToBaudRate to intelligently interpret the dwMaxBaud field 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

@huoyaoyuan huoyaoyuan added area-System.IO.Ports and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 19, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io-ports
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@MihaZupan MihaZupan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way for us to test this in CI without a weird device/driver?

@mrek-msft
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO.Ports community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SerialStream.Windows.cs treats dwMaxBaud as a baud rate when it's defined as an enum

3 participants