Skip to content

fix: Serial Monitor corrupted output in some rare cases #1032

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Renamed mutex var and added comment
  • Loading branch information
cmaglie committed Apr 24, 2025
commit 59e8c0b794304410142ef1a3b8af6fc5406dd8d0
8 changes: 5 additions & 3 deletions serialport.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,13 @@ func (p *serport) writerRaw() {
h.broadcastSys <- []byte(msgstr)
}

var spHandlerLock sync.Mutex
// This lock is used to prevent multiple threads from trying to open the same port at the same time.
// It presents issues with the serial port driver on some OS's: https://github.com/arduino/arduino-create-agent/issues/1031
var spHandlerOpenLock sync.Mutex

func spHandlerOpen(portname string, baud int, buftype string) {
spHandlerLock.Lock()
defer spHandlerLock.Unlock()
spHandlerOpenLock.Lock()
defer spHandlerOpenLock.Unlock()

log.Print("Inside spHandler")

Expand Down
Loading