Skip to content

Commit

Permalink
allBR
Browse files Browse the repository at this point in the history
  • Loading branch information
abakum committed Feb 3, 2025
1 parent 8d0b118 commit 013802a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions serial_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ func (port *unixPort) SetMode(mode *Mode) error {
if mode.BaudRate == 0 {
mode.BaudRate = int(settings.Ospeed)
}
if mode.BaudRate == 0 {
allBR := baudrateMap[0]
for _, rate := range baudrateMap {
allBR |= rate
}
for k, rate := range baudrateMap {
if settings.Cflag&allBR == rate {
mode.BaudRate = k
break
}
}
}
if mode.BaudRate == 0 {
mode.BaudRate = 9600 // Default to 9600
}
Expand Down

0 comments on commit 013802a

Please sign in to comment.