Skip to content

Commit

Permalink
Fix issue chilipeppr#27, failed open prevents other open attempts fro…
Browse files Browse the repository at this point in the history
…m succeeding

* If open fails, set spIsOpening to false and unlock the mutex
  • Loading branch information
daniel committed Apr 24, 2017
1 parent 6952a82 commit 2e5fb03
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion serialport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 2e5fb03

Please sign in to comment.