From 5f24bec955137b32c511f1d1c1c392fed0db37cf Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 24 Apr 2017 09:40:13 -0700 Subject: [PATCH] Fix issue #27, failed open prevents other open attempts from succeeding * If open fails, set spIsOpening to false and unlock the mutex --- serialport.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serialport.go b/serialport.go index ccfb160..fb9d5cf 100755 --- a/serialport.go +++ b/serialport.go @@ -437,7 +437,8 @@ func spHandlerOpen(portname string, baud int, buftype string, isSecondary bool) log.Print("Error opening port " + err.Error()) //h.broadcastSys <- []byte("Error opening port. " + err.Error()) h.broadcastSys <- []byte("{\"Cmd\":\"OpenFail\",\"Desc\":\"Error opening port. " + err.Error() + "\",\"Port\":\"" + conf.Name + "\",\"Baud\":" + strconv.Itoa(conf.Baud) + "}") - + spIsOpening = false + spmutex.Unlock() return } log.Print("Opened port successfully")