From e6bedd1ffef08eb12b9ebf960fa24258cb57d63b Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 2 Nov 2021 14:44:45 -0400 Subject: [PATCH] paneldue: use component_init for post initialization Signed-off-by: Eric Callahan --- moonraker/components/paneldue.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/moonraker/components/paneldue.py b/moonraker/components/paneldue.py index 9b5d369..0e9cb2e 100644 --- a/moonraker/components/paneldue.py +++ b/moonraker/components/paneldue.py @@ -60,7 +60,6 @@ class SerialConnection: self.send_busy: bool = False self.send_buffer: bytes = b"" self.attempting_connect: bool = True - self.event_loop.register_callback(self._connect) def disconnect(self, reconnect: bool = False) -> None: if self.connected: @@ -77,9 +76,10 @@ class SerialConnection: logging.info("PanelDue Disconnected") if reconnect and not self.attempting_connect: self.attempting_connect = True - self.event_loop.delay_callback(1., self._connect) + self.event_loop.delay_callback(1., self.connect) - async def _connect(self) -> None: + async def connect(self) -> None: + self.attempting_connect = True start_time = connect_time = time.time() while not self.connected: if connect_time > start_time + 30.: @@ -266,6 +266,9 @@ class PanelDue: 'M999': lambda args: "FIRMWARE_RESTART" } + async def component_init(self) -> None: + await self.ser_conn.connect() + async def _process_klippy_ready(self) -> None: # Request "info" and "configfile" status retries = 10