-
Notifications
You must be signed in to change notification settings - Fork 678
Description
in mavlink; parameter related messages has value field with type float. However mavlink has support for non float parameters as well. this is satisfied by adding a type field in param messages.
For example to send a param with int type (like mav_sys_id) value field of paramsend message should have int encoding instead of float encoding ('01 00 ' instead of '00 00 80 3f' for value 1)
However I think it is not possible incurrent pymavlink.
Below are some relevant code for paramvaluesend. I encountered this problem with param value send, but it probably exist in other parameter related messages aswell.
relevant code:
import struct
def param_value_send(self, param_id, param_value, param_type, param_count, param_index, force_mavlink1=False):
return self.send(self.param_value_encode(param_id, param_value, param_type, param_count, param_index), force_mavlink1=force_mavlink1)
def param_value_encode(self, param_id, param_value, param_type, param_count, param_index):
return MAVLink_param_value_message(param_id, param_value, param_type, param_count, param_index)
class MAVLink_param_value_message(MAVLink_message):
unpacker = struct.Struct("<fHH16sB")
def pack(self, mav, force_mavlink1=False):
return self._pack(mav, self.crc_extra, self.unpacker.pack(self.param_value, self.param_count, self.param_index, self.param_id, self.param_type), force_mavlink1=force_mavlink1)
in short; value field of param_value_send is encoded by struct.Struct("<f").pack(value)
which makes it hard to send int params.
Note: this problem seems to be mavlink related problem instead of library specific problem. (for example node-mavlink has this issue as well)