From c8b547a8e45bdc17c770156a95f737f1570c70f4 Mon Sep 17 00:00:00 2001 From: Bill Geyer Date: Mon, 5 Aug 2019 10:23:55 -0400 Subject: [PATCH] Copter: tradheli-remove snprintf statements --- ArduCopter/Parameters.cpp | 56 +++++++++++++-------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index d98f841ea2..489bb62b6a 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -1351,21 +1351,14 @@ void Copter::convert_tradheli_parameters(void) // convert to known swash type for setups that match AP_Int16 *swash_pos_1, *swash_pos_2, *swash_pos_3, *swash_phang, *swash_type; - char pname[17]; enum ap_var_type ptype; - snprintf(pname, sizeof(pname), "H_SW_H3_SV1_POS"); - swash_pos_1 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW_H3_SV2_POS"); - swash_pos_2 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW_H3_SV3_POS"); - swash_pos_3 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW_H3_PHANG"); - swash_phang = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW_TYPE"); - swash_type = (AP_Int16 *)AP_Param::find(pname, &ptype); + swash_pos_1 = (AP_Int16 *)AP_Param::find("H_SW_H3_SV1_POS", &ptype); + swash_pos_2 = (AP_Int16 *)AP_Param::find("H_SW_H3_SV2_POS", &ptype); + swash_pos_3 = (AP_Int16 *)AP_Param::find("H_SW_H3_SV3_POS", &ptype); + swash_phang = (AP_Int16 *)AP_Param::find("H_SW_H3_PHANG", &ptype); + swash_type = (AP_Int16 *)AP_Param::find("H_SW_TYPE", &ptype); if (swash_pos_1->get() == -60 && swash_pos_2->get() == 60 && swash_pos_3->get() == 180 && swash_phang->get() == 0 && swash_type->get() == 0) { - snprintf(pname, sizeof(pname), "H_SW_TYPE"); - AP_Param::set_default_by_name(pname, SwashPlateType::SWASHPLATE_TYPE_H3_120); + AP_Param::set_default_by_name("H_SW_TYPE", SwashPlateType::SWASHPLATE_TYPE_H3_120); } } else if (g2.frame_class.get() == AP_Motors::MOTOR_FRAME_HELI_DUAL) { @@ -1391,37 +1384,24 @@ void Copter::convert_tradheli_parameters(void) // convert swashplate 1 to known swash type for setups that match AP_Int16 *swash_pos_1, *swash_pos_2, *swash_pos_3, *swash_phang, *swash_type; - char pname[17]; enum ap_var_type ptype; - snprintf(pname, sizeof(pname), "H_SW1_H3_SV1_POS"); - swash_pos_1 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW1_H3_SV2_POS"); - swash_pos_2 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW1_H3_SV3_POS"); - swash_pos_3 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW1_H3_PHANG"); - swash_phang = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW1_TYPE"); - swash_type = (AP_Int16 *)AP_Param::find(pname, &ptype); + swash_pos_1 = (AP_Int16 *)AP_Param::find("H_SW1_H3_SV1_POS", &ptype); + swash_pos_2 = (AP_Int16 *)AP_Param::find("H_SW1_H3_SV2_POS", &ptype); + swash_pos_3 = (AP_Int16 *)AP_Param::find("H_SW1_H3_SV3_POS", &ptype); + swash_phang = (AP_Int16 *)AP_Param::find("H_SW1_H3_PHANG", &ptype); + swash_type = (AP_Int16 *)AP_Param::find("H_SW1_TYPE", &ptype); if (swash_pos_1->get() == -60 && swash_pos_2->get() == 60 && swash_pos_3->get() == 180 && swash_phang->get() == 0 && swash_type->get() == 0) { - snprintf(pname, sizeof(pname), "H_SW1_TYPE"); - AP_Param::set_default_by_name(pname, SwashPlateType::SWASHPLATE_TYPE_H3_120); + AP_Param::set_default_by_name("H_SW1_TYPE", SwashPlateType::SWASHPLATE_TYPE_H3_120); } // convert swashplate 2 to known swash type for setups that match - snprintf(pname, sizeof(pname), "H_SW2_H3_SV1_POS"); - swash_pos_1 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW2_H3_SV2_POS"); - swash_pos_2 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW2_H3_SV3_POS"); - swash_pos_3 = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW2_H3_PHANG"); - swash_phang = (AP_Int16 *)AP_Param::find(pname, &ptype); - snprintf(pname, sizeof(pname), "H_SW2_TYPE"); - swash_type = (AP_Int16 *)AP_Param::find(pname, &ptype); + swash_pos_1 = (AP_Int16 *)AP_Param::find("H_SW2_H3_SV1_POS", &ptype); + swash_pos_2 = (AP_Int16 *)AP_Param::find("H_SW2_H3_SV2_POS", &ptype); + swash_pos_3 = (AP_Int16 *)AP_Param::find("H_SW2_H3_SV3_POS", &ptype); + swash_phang = (AP_Int16 *)AP_Param::find("H_SW2_H3_PHANG", &ptype); + swash_type = (AP_Int16 *)AP_Param::find("H_SW2_TYPE", &ptype); if (swash_pos_1->get() == -60 && swash_pos_2->get() == 60 && swash_pos_3->get() == 180 && swash_phang->get() == 0 && swash_type->get() == 0) { - snprintf(pname, sizeof(pname), "H_SW2_TYPE"); - AP_Param::set_default_by_name(pname, SwashPlateType::SWASHPLATE_TYPE_H3_120); + AP_Param::set_default_by_name("H_SW2_TYPE", SwashPlateType::SWASHPLATE_TYPE_H3_120); } }