feat: 添加 CH9329 HID 芯片断联自动重试功能

- 当 CH9329 芯片通信异常时自动发送复位命令
- 增加 2 秒延迟等待芯片恢复连接
- 防止 HID 功能因芯片断联而失效

代码来自 https://github.com/mofeng-git/One-KVM/pull/164
代码作者 https://github.com/snltty
This commit is contained in:
mofeng-git 2025-08-21 17:29:11 +08:00
parent 19d1c52ac4
commit e87942a5a9

View File

@ -232,7 +232,11 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
led_byte = conn.xfer(cmd)
except ChipResponseError as ex:
self.__set_state_online(False)
get_logger(0).error("Invalid chip response: %s", tools.efmt(ex))
get_logger(0).error("Invalid chip response: %s%s", self.__device_path, tools.efmt(ex))
try:
conn.xfer(b"\x00\x0F\x00")
except Exception:
return False
time.sleep(2)
else:
if led_byte >= 0: