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!