Skip to content

Commit

Permalink
mavlink: add protection against setting wrong type of parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
BazookaJoe1900 authored and dagar committed Oct 14, 2019
1 parent 5324c37 commit 3007b08
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/modules/mavlink/mavlink_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ MavlinkParametersManager::handle_message(const mavlink_message_t *msg)
sprintf(buf, "[pm] unknown param: %s", name);
_mavlink->send_statustext_info(buf);

} else if (!((param_type(param) == PARAM_TYPE_INT32 && set.param_type == MAV_PARAM_TYPE_INT32) ||
(param_type(param) == PARAM_TYPE_FLOAT && set.param_type == MAV_PARAM_TYPE_REAL32))) {
char buf[MAVLINK_MSG_STATUSTEXT_FIELD_TEXT_LEN];
sprintf(buf, "[pm] param types mismatch param: %s", name);
_mavlink->send_statustext_info(buf);

} else {
// According to the mavlink spec we should always acknowledge a write operation.
param_set(param, &(set.param_value));
Expand Down

0 comments on commit 3007b08

Please sign in to comment.