using System;
using System.IO;
internal class Program
{
static void Main(string[] args)
{
// 设置输出重定向到文件
string outputPath = @"C:\Users\lx192\Desktop\555555.txt";
FileStream fileStream = new FileStream(outputPath, FileMode.Create);
StreamWriter streamWriter = new StreamWriter(fileStream);
Console.SetOut(streamWriter);
FileStream fs = new FileStream(@"C:\Users\lx192\Desktop\NetAssist.bin", FileMode.Open);
MAVLink.MavlinkParse parse = new MAVLink.MavlinkParse();
while (fs.Position < fs.Length)
{
var msg = parse.ReadPacket(fs);
if (msg != null && msg.msgid == 33)
{
MAVLink.mavlink_global_position_int_t p = (MAVLink.mavlink_global_position_int_t)msg.data;
double latitude = p.lat / 1E7; // 将纬度除以1E7得到经度值
double longitude = p.lon / 1E7; // 将经度除以1E7得到纬度值
Console.WriteLine("经度{0},纬度{1}", latitude, longitude);
// 还可以执行其他操作...
}
}
fs.Close();
// 关闭文件流
streamWriter.Close();
fileStream.Close();
}
}