You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
fix: Serial Monitor corrupted output in some rare cases (#1032)
* Synchronize multiple open commands coming together.* Allow re-opening of already opened ports* Renamed mutex var and added comment* Error out if baudrate and buftype of already opened port do not match
Copy file name to clipboardExpand all lines: serial.go
+6-13Lines changed: 6 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ import (
31
31
32
32
typeserialhubstruct {
33
33
// Opened serial ports.
34
-
portsmap[*serport]bool
34
+
portsmap[string]*serport
35
35
36
36
mu sync.Mutex
37
37
}
@@ -60,15 +60,15 @@ type SpPortItem struct {
60
60
varserialPortsSerialPortList
61
61
62
62
varsh=serialhub{
63
-
ports:make(map[*serport]bool),
63
+
ports:make(map[string]*serport),
64
64
}
65
65
66
66
// Register serial ports from the connections.
67
67
func (sh*serialhub)Register(port*serport) {
68
68
sh.mu.Lock()
69
69
//log.Print("Registering a port: ", p.portConf.Name)
70
70
h.broadcastSys<- []byte("{\"Cmd\":\"Open\",\"Desc\":\"Got register/open on port.\",\"Port\":\""+port.portConf.Name+"\",\"Baud\":"+strconv.Itoa(port.portConf.Baud)+",\"BufferType\":\""+port.BufferType+"\"}")
//log.Print("Unregistering a port: ", p.portConf.Name)
79
79
h.broadcastSys<- []byte("{\"Cmd\":\"Close\",\"Desc\":\"Got unregister/close on port.\",\"Port\":\""+port.portConf.Name+"\",\"Baud\":"+strconv.Itoa(port.portConf.Baud)+"}")