util: delay in between communication attempts

main
Ilya Zhuravlev 2021-01-07 13:09:11 -05:00
parent e8a6a4eab0
commit 98a37b3d60
1 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,5 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import time
from PyQt5.QtCore import QCoreApplication
@ -22,9 +23,13 @@ def hid_send(dev, msg, retries=1):
msg += b"\x00" * (MSG_LEN - len(msg))
data = b""
first = True
while retries > 0:
retries -= 1
if not first:
time.sleep(0.5)
first = False
try:
# add 00 at start for hidapi report id
if dev.write(b"\x00" + msg) != MSG_LEN + 1: