Skip to content

Commit c76f9e5

Browse files
committed
Inlined spHandlerClose
1 parent 3bcbd96 commit c76f9e5

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

Diff for: serial.go

+3-11
Original file line numberDiff line numberDiff line change
@@ -262,18 +262,10 @@ func spErr(err string) {
262262
}
263263

264264
func spClose(portname string) {
265-
// look up the registered port by name
266-
// then call the close method inside serialport
267-
// that should cause an unregister channel call back
268-
// to myself
269-
270-
myport, isFound := sh.FindPortByName(portname)
271-
272-
if isFound {
273-
// we found our port
274-
spHandlerClose(myport)
265+
if myport, ok := sh.FindPortByName(portname); ok {
266+
h.broadcastSys <- []byte("Closing serial port " + portname)
267+
myport.Close()
275268
} else {
276-
// we couldn't find the port, so send err
277269
spErr("We could not find the serial port " + portname + " that you were trying to close.")
278270
}
279271
}

Diff for: serialport.go

-5
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,6 @@ func spHandlerOpen(portname string, baud int, buftype string) {
347347
serialPorts.List()
348348
}
349349

350-
func spHandlerClose(p *serport) {
351-
h.broadcastSys <- []byte("Closing serial port " + p.portConf.Name)
352-
p.Close()
353-
}
354-
355350
func (p *serport) Close() {
356351
p.isClosing = true
357352
p.bufferwatcher.Close()

0 commit comments

Comments
 (0)