diff --git a/qmk-cmd.go b/qmk-cmd.go index f766b1b..021a619 100644 --- a/qmk-cmd.go +++ b/qmk-cmd.go @@ -285,8 +285,13 @@ func setCfg(dev *QEncDevice, cfg QEncCfg, val uint8) (err error) { } func sendDataWrapper(dev *QEncDevice, data []byte, cmd QEncCmd, id uint32) (ret []byte, err error) { - dev.Lock() - defer dev.UnLock() + if err = dev.Open(); err != nil { + return nil, err + } + if err = dev.Lock(); err != nil { + return nil, err + } + defer dev.Close() done := make(chan bool) msgc := make(chan string)