diff options
author | David Shay <[email protected]> | 2021-05-18 06:11:05 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2021-05-18 13:11:05 +0300 |
commit | 20c88b21703ce0266c0f550cd200772fa908a9bf (patch) | |
tree | 62e3f8bec40539bc2872f08fc7dc4209427b93f9 | |
parent | 274d609b71de508d66b96baa24ad80ad8b4885eb (diff) |
fix socket timeout/zero based issues in tesmart (#49)
-rw-r--r-- | kvmd/plugins/ugpio/tesmart.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kvmd/plugins/ugpio/tesmart.py b/kvmd/plugins/ugpio/tesmart.py index 6fd1f702..8c0e457c 100644 --- a/kvmd/plugins/ugpio/tesmart.py +++ b/kvmd/plugins/ugpio/tesmart.py @@ -80,12 +80,12 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute } def register_input(self, pin: int, debounce: float) -> None: - if not (0 < pin < 16): + if not (0 <= pin < 16): raise RuntimeError(f"Unsupported port number: {pin}") _ = debounce def register_output(self, pin: int, initial: Optional[bool]) -> None: - if not (0 < pin < 16): + if not (0 <= pin < 16): raise RuntimeError(f"Unsupported port number: {pin}") _ = initial @@ -112,7 +112,7 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute async def write(self, pin: int, state: bool) -> None: if state: - await self.__send_command(b"\x01%.2x" % (pin - 1)) + await self.__send_command("{:c}{:c}".format(1, pin + 1).encode()) await self.__update_notifier.notify() await asyncio.sleep(self.__switch_delay) # Slowdown @@ -136,7 +136,8 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute try: (reader, writer) = await asyncio.open_connection(self.__host, self.__port) sock = writer.get_extra_info("socket") - sock.settimeout(self.__timeout) +# sock.settimeout(self.__timeout) + sock.settimeout(0) except Exception as err: get_logger(0).error("Can't connect to Tesmart KVM [%s]:%d: %s", self.__host, self.__port, tools.efmt(err)) |