Received Custom Mavlink message on GCS

I would like to know if we can see custom mavlink message on Mission Planner. I created my own custom message to try. I get his Len and his CRC in the header in C and so now i think i’m sending it (but i’m not sure). I want to know if this kind of Plugin could work when MP received a custom message (of msg id 200).

using System;
using System.Windows.Forms;
using MissionPlanner;
using MissionPlanner.Plugin;
using static MAVLink;

namespace PluginTestCustomMessageMavlink
{
public class PluginCustomMessageMavlink : MissionPlanner.Plugin.Plugin
{
public override string Name => “PluginCustomMessageMavlink”;
public override string Version => “1.0”;
public override string Author => “667 ekip”;

    public override bool Init()
    {
        loopratehz = 1f;
        return true; 
    }

    public override bool Exit()
    {
        foreach (var port in MainV2.Comports)
        {
            port.OnPacketReceived -= OnMavLinkPacketReceived;
        }
        return true;
    }

    public override bool Loaded()
    {
        CustomMessageBox.Show("Enter in Plugin");

        foreach (var port in MainV2.Comports) 
        {
            port.OnPacketReceived += OnMavLinkPacketReceived; 
        }

        return true;
    }

    public override bool Loop()
    {
        return true;
    }

    private void OnMavLinkPacketReceived(object sender, MAVLinkMessage msg)
    {
        if (msg.msgid == 200)
        {
            CustomMessageBox.Show("MSGID 200 Received");
            var customMessage = DecodeCustomMessage(msg);
            if (customMessage != null)
            {
                CustomMessageBox.Show($"Value0: {customMessage.value0}\nValue1: {customMessage.value1}\nValue2: {customMessage.value2}");
            }
        }
    }

    private CustomMessage1 DecodeCustomMessage(MAVLinkMessage msg)
    {
        CustomMessage1 customMessage = new CustomMessage1();
        customMessage.value0 = msg.buffer[0];
        customMessage.value1 = BitConverter.ToSingle(msg.buffer, 1);
        customMessage.value2 = BitConverter.ToSingle(msg.buffer, 5);

        return customMessage;
    }

    public class CustomMessage1
    {
        public byte value0;
        public float value1;
        public float value2;
    }
}

}

Thank you!

No, if you defined your own mavlink messages then you have to rebuild the mavlink libraries on the ground and on the air side as well.

Where can i do this on Mission Planner ? I just have to copy my xml file in ExtLibs/Mavlink/message_definitions ?
Or do i need to have my new mavlink message in Mavlink.cs ( add like this : new message_info(257, “BUTTON_CHANGE”, 131, 9, 9, typeof( mavlink_button_change_t )), for example) ?

I tried to add my custom_message2.xml in message definition and to add this in Mavlink.cs inside the ExtLibs :

    new message_info(202, "CUSTOM_MESSAGE2", 53, 3, 3, typeof( mavlink_custom_message2_t )),

and then :

public struct mavlink_custom_message2_t
{
    /// packet ordered constructor
    public mavlink_custom_message2_t(byte val0, byte val1, byte val2)
    {
        Console.WriteLine("Yes1");
        this.val0 = val0;
        this.val1 = val1;
        this.val2 = val2;

    }

    /// packet xml order
    public static mavlink_custom_message2_t PopulateXMLOrder(byte val0, byte val1, byte val2)
    {
        Console.WriteLine("Yes2");
        var msg = new mavlink_custom_message2_t();

        msg.val0 = val0;
        msg.val1 = val1;
        msg.val2 = val2;

        return msg;
    }


    public byte val0;

    public byte val1;

    public byte val2;

But doesn’t work for the moment (i’m working on it)

But i can reformulate my question in an other way : Since i’m sending a custom message of id = 202, how can i detect it on Mission Planner ?