Skip to content

Commit cfa71c3

Browse files
committed
modify serial close() routine
1 parent 4fcacd2 commit cfa71c3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

serialport.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ func (p *serport) reader() {
186186
}
187187
}
188188
}
189-
p.portIo.Close()
189+
spCloseReal(p)
190190
}
191191

192192
// this method runs as its own thread because it's instantiated
@@ -322,7 +322,7 @@ func spHandlerOpen(portname string, baud int, buftype string, isSecondary bool)
322322
mode := &serial.Mode{
323323
BaudRate: baud,
324324
Vmin: 0,
325-
Vtimeout: 10,
325+
Vtimeout: 1,
326326
}
327327

328328
sp, err := serial.OpenPort(portname, mode)
@@ -359,15 +359,10 @@ func spHandlerOpen(portname string, baud int, buftype string, isSecondary bool)
359359

360360
func spHandlerClose(p *serport) {
361361
p.isClosing = true
362-
//close the port
363-
//elicit response from hardware to close out p.reader()
364-
_, _ = p.portIo.Write([]byte("?"))
362+
h.broadcastSys <- []byte("Closing serial port " + p.portConf.Name)
363+
}
365364

365+
func spCloseReal(p *serport) {
366366
p.bufferwatcher.Close()
367367
p.portIo.Close()
368-
// unregister myself
369-
// we already have a deferred unregister in place from when
370-
// we opened. the only thing holding up that thread is the p.reader()
371-
// so if we close the reader we should get an exit
372-
h.broadcastSys <- []byte("Closing serial port " + p.portConf.Name)
373368
}

0 commit comments

Comments
 (0)