Skip to content

Commit

Permalink
Commander: lock down mav_sys_id and mav_comp_id
Browse files Browse the repository at this point in the history
only allow to set when initializing commander
  • Loading branch information
mrpollo committed Aug 22, 2024
1 parent 00c3017 commit efb4ef9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,18 @@ Commander::Commander() :
_param_mav_type = param_find("MAV_TYPE");
_param_rc_map_fltmode = param_find("RC_MAP_FLTMODE");

int32_t value_int32 = 0;

// MAV_SYS_ID => vehicle_status.system_id
if ((_param_mav_sys_id != PARAM_INVALID) && (param_get(_param_mav_sys_id, &value_int32) == PX4_OK)) {
_vehicle_status.system_id = value_int32;
}

// MAV_COMP_ID => vehicle_status.component_id
if ((_param_mav_comp_id != PARAM_INVALID) && (param_get(_param_mav_comp_id, &value_int32) == PX4_OK)) {
_vehicle_status.component_id = value_int32;
}

updateParameters();
}

Expand Down Expand Up @@ -1682,15 +1694,8 @@ void Commander::updateParameters()

int32_t value_int32 = 0;

// MAV_SYS_ID => vehicle_status.system_id
if ((_param_mav_sys_id != PARAM_INVALID) && (param_get(_param_mav_sys_id, &value_int32) == PX4_OK)) {
_vehicle_status.system_id = value_int32;
}

// MAV_COMP_ID => vehicle_status.component_id
if ((_param_mav_comp_id != PARAM_INVALID) && (param_get(_param_mav_comp_id, &value_int32) == PX4_OK)) {
_vehicle_status.component_id = value_int32;
}
// NOTE: The system can't handle changing the system_id, and component_id in the same session
// you need to reboot the vehicle for settings to change

// MAV_TYPE -> vehicle_status.system_type
if ((_param_mav_type != PARAM_INVALID) && (param_get(_param_mav_type, &value_int32) == PX4_OK)) {
Expand Down

0 comments on commit efb4ef9

Please sign in to comment.