From a694cbd240a436bb1de8c4647977c3ae47e7c73b Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Thu, 3 Dec 2020 06:13:13 +0300 Subject: serial fixes --- kvmd/plugins/hid/serial.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'kvmd/plugins/hid/serial.py') diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index da61f2c6..843be58f 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -52,9 +52,13 @@ class _SerialPhyConnection(BasePhyConnection): self.__tty.read_all() assert self.__tty.write(request) == 8 data = self.__tty.read(4) - if data[0] == 0x34: # New response protocol - data += self.__tty.read(4) - return data + if len(data) == 4: + if data[0] == 0x34: # New response protocol + data += self.__tty.read(4) + if len(data) != 8: + return b"" + return data + return b"" class _SerialPhy(BasePhy): @@ -81,7 +85,10 @@ class _SerialPhy(BasePhy): # ===== class Plugin(BaseMcuHid): def __init__(self, **kwargs: Any) -> None: - phy_kwargs: Dict = {key: kwargs.pop(key) for key in self.__get_phy_options()} + phy_kwargs: Dict = { + (option.unpack_as or key): kwargs.pop(option.unpack_as or key) + for (key, option) in self.__get_phy_options().items() + } super().__init__(phy=_SerialPhy(**phy_kwargs), **kwargs) @classmethod -- cgit v1.2.3