From 9a18196a6ad83dd3d8cc948b43e33b2285f437f5 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 8 Aug 2019 17:51:38 +0200 Subject: [PATCH 1/4] mavlink_parameters: workaround for param mismatch This could workaround a potential problem with E90 where the MAVLink parameter type does not match the xml type. --- src/core/mavlink_parameters.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/core/mavlink_parameters.cpp b/src/core/mavlink_parameters.cpp index d8052da8ac..0226b88b36 100644 --- a/src/core/mavlink_parameters.cpp +++ b/src/core/mavlink_parameters.cpp @@ -363,6 +363,14 @@ void MAVLinkParameters::process_param_ext_value(const mavlink_message_t& message if (work->get_param_callback) { work->get_param_callback(MAVLinkParameters::Result::SUCCESS, value); } + } else if (value.is_uint8() && work->param_value.is_uint16()) { + // FIXME: workaround for mismatching type uint8_t which should be uint16_t. + ParamValue correct_type_value; + correct_type_value.set_uint16(uint16_t(value.get_uint8())); + _cache[work->param_name] = correct_type_value; + if (work->get_param_callback) { + work->get_param_callback(MAVLinkParameters::Result::SUCCESS, correct_type_value); + } } else { LogErr() << "Param types don't match"; ParamValue no_value; From b0c94fe6fd24fd9d747267e81af53e2d984286a8 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 12 Aug 2019 14:20:38 +0200 Subject: [PATCH 2/4] core: fix style, use static_cast --- src/core/mavlink_parameters.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/mavlink_parameters.cpp b/src/core/mavlink_parameters.cpp index 0226b88b36..3fccd43851 100644 --- a/src/core/mavlink_parameters.cpp +++ b/src/core/mavlink_parameters.cpp @@ -366,10 +366,11 @@ void MAVLinkParameters::process_param_ext_value(const mavlink_message_t& message } else if (value.is_uint8() && work->param_value.is_uint16()) { // FIXME: workaround for mismatching type uint8_t which should be uint16_t. ParamValue correct_type_value; - correct_type_value.set_uint16(uint16_t(value.get_uint8())); + correct_type_value.set_uint16(static_cast(value.get_uint8())); _cache[work->param_name] = correct_type_value; if (work->get_param_callback) { - work->get_param_callback(MAVLinkParameters::Result::SUCCESS, correct_type_value); + work->get_param_callback( + MAVLinkParameters::Result::SUCCESS, correct_type_value); } } else { LogErr() << "Param types don't match"; From eaeb646e5de6276382c8ec15a035989a917d933a Mon Sep 17 00:00:00 2001 From: Dmitry Malakhov Date: Tue, 13 Aug 2019 11:39:08 -0700 Subject: [PATCH 3/4] workaround for the problem with E10T where the MAVLink the MAVLink parameter type does not match the xml type. > Comparison type mismatch between uint8_t and uint32_t (mavlink_parameters.h:407) --- src/core/mavlink_parameters.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/mavlink_parameters.cpp b/src/core/mavlink_parameters.cpp index 3fccd43851..97f243236c 100644 --- a/src/core/mavlink_parameters.cpp +++ b/src/core/mavlink_parameters.cpp @@ -372,6 +372,15 @@ void MAVLinkParameters::process_param_ext_value(const mavlink_message_t& message work->get_param_callback( MAVLinkParameters::Result::SUCCESS, correct_type_value); } + } else if (value.is_uint8() && work->param_value.is_uint32()) { + // FIXME: workaround for mismatching type uint8_t which should be uint32_t. + ParamValue correct_type_value; + correct_type_value.set_uint32(static_cast(value.get_uint8())); + _cache[work->param_name] = correct_type_value; + if (work->get_param_callback) { + work->get_param_callback( + MAVLinkParameters::Result::SUCCESS, correct_type_value); + } } else { LogErr() << "Param types don't match"; ParamValue no_value; From a060a6f75cc0d4f46ba869e842463493851513e8 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Tue, 10 Sep 2019 11:40:14 +0200 Subject: [PATCH 4/4] core: fix style --- src/core/mavlink_parameters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/mavlink_parameters.cpp b/src/core/mavlink_parameters.cpp index 97f243236c..f4b81e44a7 100644 --- a/src/core/mavlink_parameters.cpp +++ b/src/core/mavlink_parameters.cpp @@ -379,7 +379,7 @@ void MAVLinkParameters::process_param_ext_value(const mavlink_message_t& message _cache[work->param_name] = correct_type_value; if (work->get_param_callback) { work->get_param_callback( - MAVLinkParameters::Result::SUCCESS, correct_type_value); + MAVLinkParameters::Result::SUCCESS, correct_type_value); } } else { LogErr() << "Param types don't match";