The online racing simulator
Outgauge udp Packets
(4 posts, started )
Outgauge udp Packets
Hello !

I'm trying to make a controller for real gauges , using outsim and processing ( java-like environement )

I'm able to connect and recieve UDP packets from the game, but i've got some troubles to make them understandable.

I've already done the 7 segment driver, and got it work with the corect outgauge value since it's a byte.

I can correctly read the Speed , but most of the time my code returns me " NaN " which means " not a number " , especially from 70 to 130 kph.

Here's the debug code :

void receive(byte[] data, String HOST_IP, int PORT_RX)
{

byte[] rawSpeed = new byte[4];
rawSpeed[0] = data[12];
rawSpeed[1] = data[13];
rawSpeed[2] = data[14];
rawSpeed[3] = data[15];
int bits = 0;

for(int i = 3; i >= 0; i--)
{
bits |= rawSpeed[i] << 8*i;
}

float speed = Float.intBitsToFloat(bits);
println(speed*3.6);
}

What am i doing wrong ?

Thanks !


edit : I've already looked the insim.txt, and others threads on the forum , nothing helped me
Here are the bytes i'm receiving :

-104 // -114 // 16 // 0 // 88 // 70 // 82 // 0 // 0 // -64 // 6 // 1 // 121 // 104 // -125 // 65 // 74 // 29 // 9 // 69 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // -111 // -8 // 19 // 62 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // -113 // 3 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // 0 // -23 // 119 // 44 // 62 // 70 // 117 // 101 // 108 // 32 // 49 // 52 // 46 // 53 // 37 // 32 // 32 // 32 // 0 // 0 // 0 // 66 // 114 // 97 // 107 // 101 // 32 // 66 // 97 // 108 // 32 // 70 // 114 // 32 // 56 // 53 // 37 // 1 // 0 // 0 // 0 //


The red number, at the 10th place means 5th speed ( n+1)

The green numbers shoud be the speed.


Here is a more understandable :

byte number 0 has a value of 90
byte number 1 has a value of 125
byte number 2 has a value of 5
byte number 3 has a value of 0
byte number 4 has a value of 88 X
byte number 5 has a value of 70 F
byte number 6 has a value of 82 R
byte number 7 has a value of 0
byte number 8 has a value of 0
byte number 9 has a value of -64
byte number 10 has a value of 2
byte number 11 has a value of 1
byte number 12 has a value of -78
byte number 13 has a value of -125
byte number 14 has a value of -84
byte number 15 has a value of 65
byte number 16 has a value of 88
byte number 17 has a value of -75
byte number 18 has a value of -14
byte number 19 has a value of 69
byte number 20 has a value of 0
byte number 21 has a value of 0
byte number 22 has a value of 0
byte number 23 has a value of 0
byte number 24 has a value of 0
byte number 25 has a value of 0
byte number 26 has a value of 0
byte number 27 has a value of 0
byte number 28 has a value of 16
byte number 29 has a value of 4
byte number 30 has a value of 14
byte number 31 has a value of 62
byte number 32 has a value of 0
byte number 33 has a value of 0
byte number 34 has a value of 0
byte number 35 has a value of 0
byte number 36 has a value of 0
byte number 37 has a value of 0
byte number 38 has a value of 0
byte number 39 has a value of 0
byte number 40 has a value of -113
byte number 41 has a value of 3
byte number 42 has a value of 0
byte number 43 has a value of 0
byte number 44 has a value of 0
byte number 45 has a value of 0
byte number 46 has a value of 0
byte number 47 has a value of 0
byte number 48 has a value of 0
byte number 49 has a value of 0
byte number 50 has a value of 0
byte number 51 has a value of 0
byte number 52 has a value of 0
byte number 53 has a value of 0
byte number 54 has a value of 0
byte number 55 has a value of 0
byte number 56 has a value of 0
byte number 57 has a value of 0
byte number 58 has a value of 0
byte number 59 has a value of 0
byte number 60 has a value of 70 F
byte number 61 has a value of 117 u
byte number 62 has a value of 101 e
byte number 63 has a value of 108 l
byte number 64 has a value of 32
byte number 65 has a value of 49 1
byte number 66 has a value of 51 3
byte number 67 has a value of 46 .
byte number 68 has a value of 57 9
byte number 69 has a value of 37 %
byte number 70 has a value of 32
byte number 71 has a value of 32
byte number 72 has a value of 32
byte number 73 has a value of 0
byte number 74 has a value of 0
byte number 75 has a value of 0
byte number 76 has a value of 66 B
byte number 77 has a value of 114 r
byte number 78 has a value of 97 a
byte number 79 has a value of 107 k
byte number 80 has a value of 101 e
byte number 81 has a value of 32
byte number 82 has a value of 66 B
byte number 83 has a value of 97 a
byte number 84 has a value of 108 l
byte number 85 has a value of 32
byte number 86 has a value of 70 F
byte number 87 has a value of 114 r
byte number 88 has a value of 32
byte number 89 has a value of 56 8
byte number 90 has a value of 53 5
byte number 91 has a value of 37 %
byte number 92 has a value of 1
byte number 93 has a value of 0
byte number 94 has a value of 0
byte number 95 has a value of 0


Byte 44 is the shift light.

For those who want to know, I used expand(data, 96); to see the entire sequence.

float speed = ByteBuffer.wrap(packet, 12, 4).order(ByteOrder.LITTLE_ENDIAN).getFloat();

The oldschool bitshifting and ORing method doesn't seem to be working with Java 7.
I've found a solution ! Everything is working now !

It's a bit late, i'll show you tomorrow !

Outgauge udp Packets
(4 posts, started )
FGED GREDG RDFGDR GSFDG