From 7434215409d8bfcea1ac2ce0d2a3a8052ff04e44 Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Wed, 18 Oct 2023 14:46:36 +0200 Subject: [PATCH] Implement remote param updates --- cflib/crazyflie/param.py | 68 +++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/cflib/crazyflie/param.py b/cflib/crazyflie/param.py index bc339eb9..77d474a3 100644 --- a/cflib/crazyflie/param.py +++ b/cflib/crazyflie/param.py @@ -62,15 +62,16 @@ MISC_CHANNEL = 3 MISC_SETBYNAME = 0 +MISC_VALUE_UPDATED = 1 MISC_GET_EXTENDED_TYPE = 2 - -PersistentParamState = namedtuple('PersistentParamState', 'is_stored default_value stored_value') - MISC_PERSISTENT_STORE = 3 MISC_PERSISTENT_GET_STATE = 4 MISC_PERSISTENT_CLEAR = 5 MISC_GET_DEFAULT_VALUE = 6 +PersistentParamState = namedtuple('PersistentParamState', 'is_stored default_value stored_value') + + # One element entry in the TOC @@ -186,32 +187,39 @@ def _check_if_all_updated(self): def _param_updated(self, pk): """Callback with data for an updated parameter""" + + # This method handles both param value packets as well as misc param updated packets + # The Misc packets have a command byte first and the variable id is shifted one byte + # Misc packets are not supported for V1 + if pk.channel == MISC_CHANNEL: + id_index = 1 + else: + id_index = 0 + if self._useV2: - var_id = struct.unpack('