From dabbb56ccaa96a5d3d97e869b8a2e918c129b600 Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Tue, 10 Jun 2025 11:50:04 +0200 Subject: [PATCH 1/4] Add logging for more info --- cflib/crazyflie/param.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cflib/crazyflie/param.py b/cflib/crazyflie/param.py index bfc4e254b..3f8248a0b 100644 --- a/cflib/crazyflie/param.py +++ b/cflib/crazyflie/param.py @@ -295,6 +295,7 @@ def _connection_requested(self, uri): self._initialized.clear() def _disconnected(self, uri): + logger.info('Disconnected, cleaning up threads') """Disconnected callback from Crazyflie API""" if self.param_updater is not None: self.param_updater.close() From 300ef5c74c130a861be7c7d7ef75a40aed9496d6 Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Wed, 11 Jun 2025 09:03:07 +0200 Subject: [PATCH 2/4] Incoming packet thread should also be daemon --- cflib/crazyflie/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cflib/crazyflie/__init__.py b/cflib/crazyflie/__init__.py index cc4868e50..db6ba79bd 100644 --- a/cflib/crazyflie/__init__.py +++ b/cflib/crazyflie/__init__.py @@ -393,7 +393,8 @@ class _IncomingPacketHandler(Thread): """Handles incoming packets and sends the data to the correct receivers""" def __init__(self, cf): - Thread.__init__(self) + Thread.__init__(self, name='IncomingPacketHandlerThread') + self.daemon = True self.cf = cf self.cb = [] From 4866badbb61c04c4188a0f7d7ebba28c028c0128 Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Wed, 11 Jun 2025 09:04:27 +0200 Subject: [PATCH 3/4] Radiodriver should be daemon --- cflib/crtp/radiodriver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cflib/crtp/radiodriver.py b/cflib/crtp/radiodriver.py index b2b280ddd..3f0894fb6 100644 --- a/cflib/crtp/radiodriver.py +++ b/cflib/crtp/radiodriver.py @@ -542,6 +542,7 @@ def __init__(self, radio, inQueue, outQueue, self._has_safelink = False self._link = link + self.daemon = True def stop(self): """ Stop the thread """ From 998a6a748c0f206b9c46b5fb6d36c4c9369a04b3 Mon Sep 17 00:00:00 2001 From: Tove Rumar Date: Wed, 11 Jun 2025 13:57:52 +0200 Subject: [PATCH 4/4] Start the ParamUpdater thread only when opening a connection --- cflib/crazyflie/param.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cflib/crazyflie/param.py b/cflib/crazyflie/param.py index 3f8248a0b..605b543d8 100644 --- a/cflib/crazyflie/param.py +++ b/cflib/crazyflie/param.py @@ -155,9 +155,6 @@ def __init__(self, crazyflie): self.all_update_callback = Caller() self.param_updater = None - self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) - self.param_updater.start() - self.cf.disconnected.add_callback(self._disconnected) self.cf.connection_requested.add_callback(self._connection_requested) @@ -289,6 +286,8 @@ def refresh_done(): def _connection_requested(self, uri): # Reset the internal state on connect to make sure we have a clean state + self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) + self.param_updater.start() self.is_updated = False self.toc = Toc() self.values = {} @@ -312,8 +311,7 @@ def request_param_update(self, complete_name): Request an update of the value for the supplied parameter. """ if self.param_updater is None: - self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) - self.param_updater.start() + raise Exception('Param updater not initialized, did you call open_connection?') self.param_updater.request_param_update( self.toc.get_element_id(complete_name))