mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
pikvm/pikvm#1116: fixed tesmart lag, making new tcp connection on every request
This commit is contained in:
parent
8ef73fabc3
commit
1f5ef39135
@ -115,6 +115,7 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
|
|
||||||
async def cleanup(self) -> None:
|
async def cleanup(self) -> None:
|
||||||
await self.__close_device()
|
await self.__close_device()
|
||||||
|
self.__active = -1
|
||||||
|
|
||||||
async def read(self, pin: str) -> bool:
|
async def read(self, pin: str) -> bool:
|
||||||
return (self.__active == int(pin))
|
return (self.__active == int(pin))
|
||||||
@ -125,8 +126,8 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
assert 1 <= channel <= 16
|
assert 1 <= channel <= 16
|
||||||
if state:
|
if state:
|
||||||
await self.__send_command("{:c}{:c}".format(1, channel).encode())
|
await self.__send_command("{:c}{:c}".format(1, channel).encode())
|
||||||
self.__update_notifier.notify()
|
|
||||||
await asyncio.sleep(self.__switch_delay) # Slowdown
|
await asyncio.sleep(self.__switch_delay) # Slowdown
|
||||||
|
self.__update_notifier.notify()
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
@ -149,7 +150,10 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
get_logger(0).error("Can't send command to TESmart KVM [%s]:%d: %s",
|
get_logger(0).error("Can't send command to TESmart KVM [%s]:%d: %s",
|
||||||
self.__host, self.__port, tools.efmt(err))
|
self.__host, self.__port, tools.efmt(err))
|
||||||
await self.__close_device()
|
await self.__close_device()
|
||||||
|
self.__active = -1
|
||||||
raise GpioDriverOfflineError(self)
|
raise GpioDriverOfflineError(self)
|
||||||
|
finally:
|
||||||
|
await self.__close_device()
|
||||||
|
|
||||||
async def __ensure_device(self) -> None:
|
async def __ensure_device(self) -> None:
|
||||||
if self.__reader is None or self.__writer is None:
|
if self.__reader is None or self.__writer is None:
|
||||||
@ -185,7 +189,6 @@ class Plugin(BaseUserGpioDriver): # pylint: disable=too-many-instance-attribute
|
|||||||
await aiotools.close_writer(self.__writer)
|
await aiotools.close_writer(self.__writer)
|
||||||
self.__reader = None
|
self.__reader = None
|
||||||
self.__writer = None
|
self.__writer = None
|
||||||
self.__active = -1
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user