Hello everyone, I’m working with UDP for the first time, using a program called opentrack which sends out packets of bytes over UDP. I can receive the packets in processing, but I’m having trouble figuring out to convert them into floats so that I can do what I want with them.
Here is the code thus far:
import hypermedia.net.*;
int PORT_RX= 6000; //port : set in opentrack
String HOST_IP="192.168.86.28"; // must be computer IP address, use ipconfig to find
UDP udp;
String receivedFromUDP = "";
void setup() {
size(1000,100);
udp= new UDP(this,PORT_RX,HOST_IP);
udp.log(true);
udp.listen(true);
super.start();
}
void draw() {
background(0);
text(receivedFromUDP, 50, 50);
delay(500);
}
void receive(byte[] data, String HOST_IP, int PORT_RX) {
receivedFromUDP ="";
for (int i = 0; i < data.length; i++) {
receivedFromUDP += str(data[i]) + " ";
}
}
And here is a an example of the output:
102 10 -27 -86 92 17 40 64 -120 9 -9 104 -19 55 -48 -65 48 -76 -8 -105 66 -105 47 -64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Any help would be greatly appreciated, thank you!