namespace XPlanePilot
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
public bool udpListen = true;
public MainWindow()
{
InitializeComponent();
Debug.WriteLine("Starting");
Debug.WriteLine("listening for messages");
Task.Run(async () =>
{
using (var udpClient = new UdpClient(new IPEndPoint(IPAddress.Loopback, 50000)))
{
while (true)
{
UdpReceiveResult receiveResult = await udpClient.ReceiveAsync();
Debug.WriteLine($"data received length : {receiveResult.Buffer.Length.ToString()}");
var preambule = Encoding.ASCII.GetString(receiveResult.Buffer, 0, 4);
for (int i = 5; i < receiveResult.Buffer.Length; i += (4+32))
{
Debug.WriteLine($"index {receiveResult.Buffer[i]}");
Debug.WriteLine($"data 1 : {BitConverter.ToSingle(receiveResult.Buffer, i+4)}");
Debug.WriteLine($"data 2 : {BitConverter.ToSingle(receiveResult.Buffer, i + 8)}");
Debug.WriteLine($"data 3 : {BitConverter.ToSingle(receiveResult.Buffer, i + 12)}");
Debug.WriteLine($"data 4 : {BitConverter.ToSingle(receiveResult.Buffer, i + 16)}");
Debug.WriteLine($"data 5 : {BitConverter.ToSingle(receiveResult.Buffer, i + 20)}");
Debug.WriteLine($"data 6 : {BitConverter.ToSingle(receiveResult.Buffer, i + 24)}");
Debug.WriteLine($"data 7 : {BitConverter.ToSingle(receiveResult.Buffer, i + 28)}");
Debug.WriteLine($"data 8 : {BitConverter.ToSingle(receiveResult.Buffer, i + 32)}");
}
}
}
});
}
}
}