From 1259561298cea7ad6b1bfeaa6e5117adb112060a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Leborne?= Date: Thu, 12 Dec 2024 11:49:33 +0100 Subject: [PATCH] Remove sending of empty JSON to accelerate device setup --- pyluos/device.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pyluos/device.py b/pyluos/device.py index 3480fda..82c6465 100644 --- a/pyluos/device.py +++ b/pyluos/device.py @@ -144,14 +144,12 @@ def play(self): self._pause = False def _setup(self): - self.logger.info('Sending detection signal.') - self._send({}) - time.sleep(0.01) + startTime = time.time() + retry = 0 + self.logger.info(f'Sending detection signal ({retry=})') self._send({'detection': {}}) self.logger.info('Waiting for routing table...') - startTime = time.time() state = self._poll_once() - retry = 0 while ('routing_table' not in state): if ('route_table' in state): self.logger.info("Watch out the Luos revision you are using on your board is too old to work with this revision of pyluos.\n Please consider updating Luos on your boards") @@ -162,6 +160,7 @@ def _setup(self): if retry > 5: # detection is not working sys.exit("Detection failed.") + self.logger.info(f'Sending detection signal ({retry=})') self._send({'detection': {}}) startTime = time.time() # Save routing table data