My goal is to programmatically update the UAV’s LLA coordinates with a function call. I found the function InjectGPSData and it seems it would do what I want. I could not figure out how to get this function to be called with the normal GUI so I could not get a breakpoint in to see what the byte[] is supposed to look like. Could someone explain what formatting this function is expecting? If this will not do what I want is there another function call or method to achieve direct control of the LLA of the UAV? Here is my code so far.
string mes = "lat = 50.46, lon = -91.01, Alt = 1000"; // Needs to be formatted correctly
byte[] data = Encoding.ASCII.GetBytes(mes);
foreach (var port in MainV2.Comports)
{
foreach (var MAV in port.MAVlist)
{
port.InjectGpsData(MAV.sysid, MAV.compid, data, (ushort)data.Length, true);
}
}
This code under MainV2.cs caught my eye.
if (cmds.ContainsKey("rtk"))
{
var inject = new ConfigSerialInjectGPS();
if (cmds["rtk"].ToLower().Contains("http"))
{
inject.CMB_serialport.Text = "NTRIP";
var nt = new CommsNTRIP();
ConfigSerialInjectGPS.comPort = nt;
Task.Run(() =>
{
try
{
nt.Open(cmds["rtk"]);
nt.lat = MainV2.comPort.MAV.cs.PlannedHomeLocation.Lat;
nt.lng = MainV2.comPort.MAV.cs.PlannedHomeLocation.Lng;
nt.alt = MainV2.comPort.MAV.cs.PlannedHomeLocation.Alt;
this.BeginInvokeIfRequired(() => { inject.DoConnect(); });
}
catch (Exception ex)
{
this.BeginInvokeIfRequired(() => { CustomMessageBox.Show(ex.ToString()); });
}
});
}
}