Im trying to get my tracking code to work i can send a pwm value over tcp to robot with roborealm but it updates so slow even know on roborealm it is sending it at 50ms on the robot it takes about 500ms to register, here is the code, Roborealm sends it as an int, we have a competition tomorrow so ASAP would be great PLEASE AND THANKYOU
Code:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Gus.Team228.Final;
import edu.wpi.first.wpilibj.Timer;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import javax.microedition.io.Connector;
import javax.microedition.io.ServerSocketConnection;
import javax.microedition.io.SocketConnection;
/**
*
* @author Matt Smith
*/
public class Socket extends Thread {
private ServerSocketConnection socket;
private SocketConnection connection;
DataInputStream instream;
DataOutputStream outstream;
int datain;
public void run() {
try {
socket = (ServerSocketConnection) Connector.open("socket://:1234");
connection = (SocketConnection) socket.acceptAndOpen();
instream = connection.openDataInputStream();
outstream = connection.openDataOutputStream();
while (true) {
datain = instream.read();
instream.read();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
//Teleop code:
motor.setRaw(socket.datain);