View Full Version : UDP Streaming data analysis

11-11-2016, 08:40
Hello,everyone! I have a probelm about UDP streaming data analysis .
I can get 1367 bytes of data through the UDP broadcast transmission. But I don't know how to parse the data.For example:I konw "sWorldVelocity[3]" statrts from 160th byte to 171th byte.I have gotten 12 bytes Hex data. But I don't know how to calculate the sWorldVelocity[0],sWorldVelocity[1] and sWorldVelocity[2].Can you provide some relevant documentation or examples? Thanks you very much!

11-11-2016, 08:57
Moved to Third Party Apps & API Discussion subforum.

Please check out this sticky thread (http://forum.projectcarsgame.com/showthread.php?40113-HowTo-Companion-App-UDP-Streaming) for more info.

11-11-2016, 09:06
Thank you for your replying.I have read this passage,but I still don't know how to parse the data.

11-11-2016, 11:26
you have to convert the raw binary data into the relevant types - e.g. 4 contiguous bytes into a float type. How you do this will depend on what language you're using. C# provides a handy 'struct' type which maps the binary data to usable types - my Crew Chief application is open source so you can see how this works here: https://github.com/mrbelowski/CrewChiefV4/blob/master/CrewChiefV4/PCars/PCarsUDPTelemetryDataStruct.cs

This is the struct onto which the binary data (byte array) are mapped, so you get lots of already-created floats and things.

If you're using Java you have to do all the conversions manually. My Android app does this, and uses lots of little utility methods like

private float getFloat(byte[] data, int offset) {
return ByteBuffer.wrap(data, offset, 4).order(BYTE_ORDER).getFloat();

Basically I have to iterate over the byte array that's come from the UDP packet and call methods like this to convert one or more bytes to their proper native types. I'm happy to share the Java class with all this in if you want it, but obviously it's no use if you're not using Java