Removed the TCP video streaming code.

This commit is contained in:
2014-01-21 12:19:23 -04:30
parent f865c39cb7
commit 1c7430edd6
3 changed files with 15 additions and 12 deletions

View File

@@ -26,7 +26,7 @@ public class LCPThread extends Thread{
private BTCommunicator btComm; private BTCommunicator btComm;
private MotorControlThread motorControl; private MotorControlThread motorControl;
private SensorReportThread sensorReport; private SensorReportThread sensorReport;
public LCPThread(String serverIp){ public LCPThread(String serverIp){
super("Robot Control Main Thread"); super("Robot Control Main Thread");
btComm = BTCommunicator.getInstance(); btComm = BTCommunicator.getInstance();
@@ -34,7 +34,7 @@ public class LCPThread extends Thread{
motorControl = new MotorControlThread(serverIp); motorControl = new MotorControlThread(serverIp);
sensorReport = new SensorReportThread(serverIp); sensorReport = new SensorReportThread(serverIp);
} }
public void run(){ public void run(){
if(!motorControl.connectToServer()){ if(!motorControl.connectToServer()){
Logger.log_e(TAG, CLASS_NAME + ".run() :: Thread motorControl could not connect to the server."); Logger.log_e(TAG, CLASS_NAME + ".run() :: Thread motorControl could not connect to the server.");
@@ -44,7 +44,7 @@ public class LCPThread extends Thread{
Logger.log_e(TAG, CLASS_NAME + ".run() :: Thread sensorReport could not connect to the server."); Logger.log_e(TAG, CLASS_NAME + ".run() :: Thread sensorReport could not connect to the server.");
Logger.log_e(TAG, CLASS_NAME + ".run() :: Sensor data will not be reported to server app."); Logger.log_e(TAG, CLASS_NAME + ".run() :: Sensor data will not be reported to server app.");
} }
while(!done){ while(!done){
if(btComm.isBTEnabled() && btComm.isConnected()){ if(btComm.isBTEnabled() && btComm.isConnected()){
Logger.log_d(TAG, CLASS_NAME + ".run() :: Connected."); Logger.log_d(TAG, CLASS_NAME + ".run() :: Connected.");
@@ -53,7 +53,7 @@ public class LCPThread extends Thread{
} }
} }
} }
public void finish(){ public void finish(){
done = true; done = true;
} }

View File

@@ -35,7 +35,10 @@ public class MotorControlThread extends Thread {
return; return;
}else{ }else{
while(!done){ while(!done){
Object msg = readMessage();
MotorEvent event = verifyMessage(msg);
if(event != null)
queue.addEvent(event);
} }
} }
} }

View File

@@ -182,21 +182,21 @@ public class VideoStreamingThread extends Thread{
}*/ }*/
public void run(){ public void run(){
connectToServer(); //connectToServer();
try{ try{
udpSocket = new DatagramSocket(); udpSocket = new DatagramSocket();
udpSocket.setSendBufferSize(Integer.MAX_VALUE); //udpSocket.setSendBufferSize(Integer.MAX_VALUE);
}catch(IOException io){ }catch(IOException io){
Logger.log_e(TAG, CLASS_NAME + ".run() :: IOException received creating socket " + io.getMessage()); Logger.log_e(TAG, CLASS_NAME + ".run() :: IOException received creating socket " + io.getMessage());
System.exit(1); System.exit(1);
} }
if(!socket.isConnected()){ /*if(!socket.isConnected()){
Logger.log_e(TAG, CLASS_NAME + ".run() :: Not connected to a server. Finishing thread."); Logger.log_e(TAG, CLASS_NAME + ".run() :: Not connected to a server. Finishing thread.");
return; return;
}else{ }else{*/
while(!done){ while(!done){
//sendImage(); //sendImage();
sendUdp(); sendUdp();
@@ -204,7 +204,7 @@ public class VideoStreamingThread extends Thread{
sleep(50L); sleep(50L);
}catch(InterruptedException ie){} }catch(InterruptedException ie){}
} }
} //}
Logger.log_d(TAG, CLASS_NAME + ".run() :: Thread finish reached."); Logger.log_d(TAG, CLASS_NAME + ".run() :: Thread finish reached.");
} }
@@ -260,10 +260,10 @@ public class VideoStreamingThread extends Thread{
size = int2ByteArray(bufferSize); size = int2ByteArray(bufferSize);
try{ try{
packet = new DatagramPacket(size, 4, InetAddress.getByName(serverIp), ProjectConstants.SERVER_TCP_PORT_2); packet = new DatagramPacket(size, 4, InetAddress.getByName(serverIp), ProjectConstants.SERVER_TCP_PORT_1);
udpSocket.send(packet); udpSocket.send(packet);
packet = new DatagramPacket(buffer, buffer.length, InetAddress.getByName(serverIp), ProjectConstants.SERVER_TCP_PORT_2); packet = new DatagramPacket(buffer, buffer.length, InetAddress.getByName(serverIp), ProjectConstants.SERVER_TCP_PORT_1);
udpSocket.send(packet); udpSocket.send(packet);
}catch(UnknownHostException uo){ }catch(UnknownHostException uo){