From 428c2f72bded828499e4113d4392be258d114e2f Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 31 Oct 2018 14:18:54 +0100 Subject: [PATCH] mavlink: always acknowledge a param write This change has two effects: 1. We always acknowledge a param write no matter if the value was actually changed or not. This is according to the spec: https://mavlink.io/en/services/parameter.html#write-parameters 2. This fixes the bug where int32 parameters were not actually acked because the memory of the param value was casted directly to float and then compared. In the case of a int32 parameter set from 0 to 1 it would mean that the cast to float of the memory representation was still 0 and therefore it was assumed to be "no change" and the ack was omitted. --- src/modules/mavlink/mavlink_parameters.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index 08d0e2e901..b853648c22 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -149,15 +149,9 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg) _mavlink->send_statustext_info(buf); } else { - // Load current value before setting it - float curr_val; - param_get(param, &curr_val); + // According to the mavlink spec we should always acknowledge a write operation. param_set(param, &(set.param_value)); - - // Check if the parameter changed. If it didn't change, send current value back - if (!(fabsf(curr_val - set.param_value) > 0.0f)) { - send_param(param); - } + send_param(param); } }