CCAZE31 / ardupilot-mega

Automatically exported from code.google.com/p/ardupilot-mega
0 stars 0 forks source link

improper implementation of mavlink parameter protocol #872

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Although the Common MAVLink Message Documentation 
(https://pixhawk.ethz.ch/mavlink/#PARAM_VALUE) suggests that all data types 
defined in enum MAV_PARAM_TYPE can be transmitted, the parameter protocol only 
supports the three 32 bit types uint32_t, int32_t and float. 
(http://qgroundcontrol.org/mavlink/parameter_protocol#supported_data_types)

(This becomes clear when you look at the implementation of the 
mavlink_msg_param_*_pack functions that do the potential byte swapping of the 
param_value field according to a 4 byte type completely ignoring param_type)

Fix:
modify GCS_Mavlink.pde

param_value messages:
don't use the cast_to_float method (that static_casts all values to float):
1. static_cast< (u)int32_t >( (u)int_x value )
2. store this value with either a reinterpret_cast or the mavlink_param_union_t 
struct in a float
3. change param_type accordingly 

param_set messages:
- reverse the above steps
- between 1. & 2. a check for to small/big values probably wouldn't hurt (like 
the constrain_.. methods in AP_Math do but preferably with meaningful arguments 
like std::numeric_limits::max() instead of just plain numbers)

Original issue reported on code.google.com by eilstach...@googlemail.com on 13 Feb 2013 at 6:49