Browse Source

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.
sbg
Julian Oes 6 years ago committed by Lorenz Meier
parent
commit
428c2f72bd
  1. 10
      src/modules/mavlink/mavlink_parameters.cpp

10
src/modules/mavlink/mavlink_parameters.cpp

@ -149,15 +149,9 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg)
_mavlink->send_statustext_info(buf); _mavlink->send_statustext_info(buf);
} else { } else {
// Load current value before setting it // According to the mavlink spec we should always acknowledge a write operation.
float curr_val;
param_get(param, &curr_val);
param_set(param, &(set.param_value)); param_set(param, &(set.param_value));
send_param(param);
// 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);
}
} }
} }

Loading…
Cancel
Save