Send MAVLink Packet with C# NuGet

Hi everyone,

I would like to send commands to my drone and I tried to do so using the C# MAVLink NuGet with the following code as a test :


MAVLink.MavlinkParse mp = new MAVLink.MavlinkParse();

var buffer = mp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.COMMAND_INT,
                            new MAVLink.mavlink_command_int_t()
                            {
                                command = 511,
                                param1 = MAVLink.MAVLINK_MSG_ID.SCALED_IMU.GetHashCode(),
                                param2 = 100000,
                                target_system = 0
                            }, false, 255, 1, -1);

port.Write(buffer, 0, buffer.Length);

The command is a MAV_CMD_SET_MESSAGE_INTERVAL (511) supposed to ask my drone to send me a SCALED_IMU(#26) message at an interval of 1 second (100000 us).

The thing is, even when I send this command multiple times, I do not receive any SCALED_IMU (#26) message in return.

I also tried with the GenerateMAVLinkPacket10 method and with MAVLink.mavlink_command_long_t() instead, but still nothing.

Is there anyone to help me on this ?

I understood what went wrong : It was the broadcasting (target_system = 0) not working so I had to put it to 1 (corresponding to the sysid of my drone).

However I have a second issue : it seems that the C# MAVLink librairy has a bug because everything I put in value or parameter of a message/command is interpreted as the int equivalent of the float, not the float itself, ie :
When i put for example 1.0f as a param_value, I see on QGroundControl that my value has been changed to 1065353216, which is the int equivalent of my float (as described here : https://stackoverflow.com/questions/24356579/why-is-1-0f-in-c-code-represented-as-1065353216-in-the-generated-assembly)

var buffer = mp.GenerateMAVLinkPacket20(MAVLink.MAVLINK_MSG_ID.PARAM_SET,
                            new MAVLink.mavlink_param_set_t()
                            {
                                param_id = bytes,
                                param_value = 1.0f,
                                param_type = (byte) MAVLink.MAV_PARAM_TYPE.INT32,
                                target_component = 1,
                                target_system = 1
                            }, false, 255, 1, seq++);

image

Is there anyone to help me on this please ?