Skip to content

Commit fb2220f

Browse files
committed
Error out if baudrate and buftype of already opened port do not match
1 parent 59e8c0b commit fb2220f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

serialport.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,8 @@ func spHandlerOpen(portname string, baud int, buftype string) {
302302
sp, err := serial.Open(portname, mode)
303303
log.Print("Just tried to open port")
304304
if err != nil {
305-
if existingPort, ok := sh.FindPortByName(portname); ok {
305+
existingPort, ok := sh.FindPortByName(portname)
306+
if ok && existingPort.portConf.Baud == baud && existingPort.BufferType == buftype {
306307
log.Print("Port already opened")
307308
h.broadcastSys <- []byte("{\"Cmd\":\"Open\",\"Desc\":\"Port already opened.\",\"Port\":\"" + existingPort.portConf.Name + "\",\"Baud\":" + strconv.Itoa(existingPort.portConf.Baud) + ",\"BufferType\":\"" + existingPort.BufferType + "\"}")
308309
} else {

0 commit comments

Comments
 (0)