Jump to content

DCS Bios UDP Export detect Strings or Integers


Recommended Posts

I hope you guys can help me on this one.

 

 

I currently try to write a parser of the DCS BIOS UDP Export in C# to use my Surface (or any other Windows-Touchscreen) as a UFC Panel (or any other Panel ofc.).

 

 

While sending commands to DCS via UDP is no problem at all, I have some trouble with the Export of stuff.

 

 

I think I solved the Integer Information stuff, as I was able to read the status of the Gear-LEDs.

 

But it did not worked always as expected, because the Address (0x5428 ) is used for a lot of LEDs but also for sending a String Value (UFC_Cueing 5 iirc).

 

 

Here are the two Strings I have filtered out as an example:

 

 

Integer Content where parsing works fine:

 

55-55-55-55-08-00-02-00-6F-72-00-04-02-00-29-09-0A-04-02-00-D8-04-28-54-04-00-20-38-20-20-FE-FF-02-00-8C-00

Here, detection works fine, because I am able to find the address, then read out the data length (04-00 -> 0x0004) and then use the next 4 Bytes in binary representation to read the status of each LED (and ofc. using the Mask to know which bit is relevant).

 

 

And here is the String where things go horribly wrong, because I receive the 0x5428 Address, but cant work out how the Chars that follow it have to be interpreted, or how I even check, whether its the above Integer Content, or this one:

 

 

55-55-55-55-00-00-02-00-46-41-06-04-04-00-58-99-26-00-00-54-02-00-00-00-28-54-04-00-20-00-20-20-9A-54-06-00-20-08-20-20-20-00-EE-54-02-00-78-A7-FE-FF-02-00-30-00

I am not sure if my explanation made things even worse to understand for you. I just give you the interesting parts of my Code as well (though it does not yet work as intendet).

 

 

So, my question is, how do I know whether I have to interpret the Incoming UDP Line as Integer Values or as String Values?

 

Reference Thread:

https://forums.eagle.ru/showpost.php?p=4031843&postcount=2

 

 

How does he know, whether he has a case "i" or a case "s", as he uses it in his JS Code and I can´t configure out, how he gets this Value.

 

 

 

 

 

 

private void Receive(IAsyncResult ar)
       {
           IPEndPoint ip = new IPEndPoint(IPAddress.Any, 5010);
           byte[] bytes = udp.EndReceive(ar, ref ip);
           StringBuilder sb = new StringBuilder();
           int c = 0;
           
           sb.Append(BitConverter.ToString(bytes));

           string[] substrings = sb.ToString().Split('-');

           sb.Clear();

           foreach (string s in substrings)
           {
               sb.Append(s);
           }
           if (BitConverter.ToUInt32(bytes, 0) != 0x55555555)
           {
               Console.WriteLine("Invalid String");
               string message = sb.ToString();
               Console.WriteLine("From {0} received: {1} ", ip.Address.ToString(), message);
           }
           else
           {
               int offset = 4;
               while (bytes.Length - offset -4> 0)
               {
                   Int16 startAddress = BitConverter.ToInt16(bytes, offset);

                   offset += 2;
                   
                   UInt16 dataLenB = BitConverter.ToUInt16(bytes, offset);
                   
                   offset += 2;

                   int nextoffset = offset + dataLenB;
                   StringBuilder sbraw = new StringBuilder();
                   while (dataLenB > 0)
                   {
                       sbraw.Append(Convert.ToString(bytes[offset + dataLenB - 1], 2).PadLeft(8, '0'));
                       dataLenB--;
                   }
                   offset = nextoffset;
                   string rawdata = sbraw.ToString();

                   foreach (LEDElement l in ledElements)
                   {
                       if (startAddress == l.getAddress())
                       {
                           Console.WriteLine(l.getValue(rawdata)); //this using the Mask to give the correct state for the LED
                       }
                   }
               }

           }
           
           StartListening();
       }


Edited by donald_42
removed smiley and confusing explanations
Link to comment
Share on other sites

  • 2 months later...

Hey wondering how far you got with getting this going on your surface. I too am trying a similar thing and am having trouble decoding the export stream from DCS BIOS. Are you able to share some of your code?

 

 

Thanks

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...