Skip to content

Commit eae0887

Browse files
committed
Synchronize multiple open commands coming together.
1 parent b717430 commit eae0887

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

serialport.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"encoding/base64"
2121
"io"
2222
"strconv"
23+
"sync"
2324
"sync/atomic"
2425
"time"
2526
"unicode/utf8"
@@ -273,7 +274,11 @@ func (p *serport) writerRaw() {
273274
h.broadcastSys <- []byte(msgstr)
274275
}
275276

277+
var spHandlerLock sync.Mutex
278+
276279
func spHandlerOpen(portname string, baud int, buftype string) {
280+
spHandlerLock.Lock()
281+
defer spHandlerLock.Unlock()
277282

278283
log.Print("Inside spHandler")
279284

0 commit comments

Comments
 (0)