This site is being deprecated.

Please see the official X‑Plane Support page for help.

0 votes
asked by (33 points)
Where can I get X-Plane 11 complete UDP Protocol ?

At present,  there are only part of UDP protocol in X-Plane 11 directory.

I wish I can get the complete UDP protocol document for X-Plane 11.

Request for Help!

Dengxie

1 Answer

0 votes
answered by (14 points)

I'm super late to reply but, for reference, and hopefully help the future.

The UDP "DATA" protocol is super simple.

In data output preference you have a bunch of data you can send, in the first column you have the "index" (it's actually important), you check "network via udp" in the last column to send it via udp. and there you go.

Now, the protocol : 

  • The first 4 byte are the header. if xplane send data (stuff you selected in the data output) they read, in ASCII : "DATA".
  • followed by 1 byte you can ignore
  • followed by 4 byte, but only the first of the four is important : it's the index (the stuff in the 1st column)
  • followed by 8*4 byte : they are the data. For more inforation also check "show in cockpit" in the preference so you'll now more about what the data are.
  • then you have another pack of 4 + 8*4 until the end of the datagram.
  • rince, repeat
It's the complete protocole, there isn't anything else.
Now, if you want to know what the data actually mean, it's another story...
The simpliest C# code i made to read the data (it's the full code of my WPF app. it's my MainWindow.xaml.cs) : 
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)}");
                        }
                    }
                }
            });
        }
    }
}
If you want to know about other kind of data (the non-"DATA"), NASA maintain a documentation, as far as i know it's still up to date. https://github.com/nasa/XPlaneConnect/wiki/Network-Information
commented by (14 points)
PS : if there is no data it will read "-999"

ex :

index 0

data 1 : 37.58728

data 2 : 31.40605

data 3 : -999 <- no data

data 4 : 0.02660474

data 5 : 0.02571171

data 6 : 0.01100269

data 7 : 1

data 8 : 1
...