Logging APVar saves

This commit is contained in:
Jason Short 2011-11-19 16:58:20 -08:00
parent 3a62f9dbd8
commit c762abdd00

View File

@ -1367,6 +1367,7 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
// find the requested parameter
vp = AP_Var::find(key);
if ((NULL != vp) && // exists
!isnan(packet.param_value) && // not nan
!isinf(packet.param_value)) { // not inf
@ -1382,19 +1383,27 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
// handle variables with standard type IDs
if (var_type == AP_Var::k_typeid_float) {
((AP_Float *)vp)->set_and_save(packet.param_value);
Log_Write_Data(1, (float)((AP_Float *)vp)->get());
} else if (var_type == AP_Var::k_typeid_float16) {
((AP_Float16 *)vp)->set_and_save(packet.param_value);
Log_Write_Data(2, (float)((AP_Float *)vp)->get());
} else if (var_type == AP_Var::k_typeid_int32) {
if (packet.param_value < 0) rounding_addition = -rounding_addition;
((AP_Int32 *)vp)->set_and_save(packet.param_value+rounding_addition);
Log_Write_Data(3, (int32_t)((AP_Float *)vp)->get());
} else if (var_type == AP_Var::k_typeid_int16) {
if (packet.param_value < 0) rounding_addition = -rounding_addition;
((AP_Int16 *)vp)->set_and_save(packet.param_value+rounding_addition);
Log_Write_Data(4, (int32_t)((AP_Float *)vp)->get());
} else if (var_type == AP_Var::k_typeid_int8) {
if (packet.param_value < 0) rounding_addition = -rounding_addition;
((AP_Int8 *)vp)->set_and_save(packet.param_value+rounding_addition);
Log_Write_Data(5, (int32_t)((AP_Float *)vp)->get());
} else {
// we don't support mavlink set on this parameter
break;
@ -1410,6 +1419,7 @@ void GCS_MAVLINK::handleMessage(mavlink_message_t* msg)
vp->cast_to_float(),
_count_parameters(),
-1); // XXX we don't actually know what its index is...
}
break;