Skip to content

Commit

Permalink
AP_Mount: Xacti get_param_name_str returns empty string on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
rmackay9 committed Nov 7, 2023
1 parent 53ebad6 commit 434f954
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
10 changes: 2 additions & 8 deletions libraries/AP_Mount/AP_Mount_Xacti.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,12 +569,13 @@ void AP_Mount_Xacti::handle_param_save_response(AP_UAVCAN* ap_dronecan, const ui
}

// get parameter name for a particular param enum value
// returns an empty string if not found (which should never happen)
const char* AP_Mount_Xacti::get_param_name_str(Param param) const
{
// check to avoid reading beyond end of array. This should never happen
if ((uint8_t)param > ARRAY_SIZE(_param_names)) {
INTERNAL_ERROR(AP_InternalError::error_t::invalid_arg_or_result);
return nullptr;
return "";
}
return _param_names[(uint8_t)param];
}
Expand Down Expand Up @@ -619,10 +620,6 @@ bool AP_Mount_Xacti::get_param_string(Param param)

// convert param to string
const char* param_name_str = get_param_name_str(param);
if (param_name_str == nullptr) {
return false;
}

if (_detected_modules[_instance].ap_dronecan->get_parameter_on_node(_detected_modules[_instance].node_id, param_name_str, &param_string_cb)) {
last_send_getset_param_ms = AP_HAL::millis();
return true;
Expand All @@ -641,9 +638,6 @@ bool AP_Mount_Xacti::process_set_param_int32_queue()
if (_set_param_int32_queue->pop(param_to_set)) {
// convert param to string
const char* param_name_str = get_param_name_str(param_to_set.param);
if (param_name_str == nullptr) {
return false;
}
if (_detected_modules[_instance].ap_dronecan->set_parameter_on_node(_detected_modules[_instance].node_id, param_name_str, param_to_set.value, &param_int_cb)) {
last_send_getset_param_ms = AP_HAL::millis();
return true;
Expand Down
1 change: 1 addition & 0 deletions libraries/AP_Mount/AP_Mount_Xacti.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class AP_Mount_Xacti : public AP_Mount_Backend
static const char* _param_names[]; // array of Xacti parameter strings

// get parameter name for a particular param enum value
// returns an empty string if not found (which should never happen)
const char* get_param_name_str(Param param) const;

// helper function to get and set parameters
Expand Down

0 comments on commit 434f954

Please sign in to comment.