Forum

Decoding UDP packages from LSF

Hi guys, i need some help with a simple task to achive a bigger project
i want to do something like this

the game is LFS, and it have the feature to send by udp all the dashboardboard information, and the kinectik information of the card, with this and arduino and a few actuators its quite simple to build a simlulator

i have the arduino working with servos, firmdata plugin, a 2x16 lcd dysplay for fuel, and a few more things, but i dont know how to interpret ate the packages

please check the example file

osc lfs (26.3 kB)

a little more info that i found that it might help

Each update sends the following UDP packet :

unsigned int Time; // time in milliseconds (to check order)
char Car4; // Car name
word Flags; // Combination of OG_FLAGS, see below
byte Gear; // Reverse:0, Neutral:1, First:2…
byte SpareB;
float Speed; // M/S
float RPM; // RPM
float Turbo; // BAR
float EngTemp; // C
float Fuel; // 0 to 1
float OilPress; // BAR
float Spare1;
float Spare2;
float Spare3;
float Throttle; // 0 to 1
float Brake; // 0 to 1
float Clutch; // 0 to 1
char Display116; // Usually Fuel
char Display216; // Usually Settings
int ID; // (optional ID - if specified in cfg.txt)

int = 32 bits = 4 bytes
unsigned = unsigned int = 32 bits = 4 bytes
float = 32 bits = 4 bytes
double = 64 bits = 8 bytes
char = 8 bits = 1 byte
byte = unsigned char = 8 bits = 1 byte
short = 16 bits = 2 bytes
word = unsigned short = 16 bits = 2 bytes

i guess i need to use the separate, substitute, and which other string nodes ?

guess you’re faster if you’d decode it in a plugin.

it’s possible patchingwise though with Ord (String) :
int32 = Signed32Bit :: uint32 = Unsigned32Bit
float = IEEESingle
double = IEEEDouble
char is as it is
byte = Unsigned8Bit
short = Unsigned16bit :: word = Signed16bit

@woei : hey tanks a lot for the tip, we were able to do it with ordstring as you told me. How do i start doing a plugin for that? what kind of plug in ?

we were able to decode almost all the outgage fields, exepts some flags that are 1 bit only,
here is some of the results

we send the rpm to arduino and from there to a 9g servo and to touchosc, seems to work without delay…
and i already started with outsim to get the car movements to build a simulator, I’m waiting a few servos that i ordered to build the scale version, but up to now seems to work just fine. Latter my friend will post the full patch