From 3556fedfdd3607ef019b1dec33a6b76c592216f1 Mon Sep 17 00:00:00 2001 From: Matthias Fulz Date: Sat, 2 Jul 2022 13:50:36 +0200 Subject: [PATCH] Open / Closing device added to sendData --- qmk-cmd.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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)