diff --git a/CopterController/TCPexample/EchoServer.java b/CopterController/TCPexample/EchoServer.java new file mode 100644 index 0000000..e6983bc --- /dev/null +++ b/CopterController/TCPexample/EchoServer.java @@ -0,0 +1,51 @@ +/** + * + */ + +import java.lang.*; +import java.io.*; +import java.net.*; + +/** + * Echo server. if receives "DISCONNECT", will shut down server properly + */ +class EchoServer { + public static void main(String args[]) { + ServerSocket srvr; + Socket skt; + BufferedReader in; + PrintWriter out; + + try { + System.out.print( "Setting up server\n" ); + srvr = new ServerSocket( 51717 ); + skt = srvr.accept(); + System.out.print( "Server has connected!\n" ); + + in = new BufferedReader( new InputStreamReader( skt.getInputStream() ) ); + out = new PrintWriter( skt.getOutputStream(), true); + + while( true ) { + System.out.print( "waiting for message...\n" ); + while( !in.ready() ) {} + String rx = in.readLine(); + System.out.print( "message received: " + rx + "\n" ); + + if( rx.equals( "DISCONNECT" ) ) { + System.out.print( "disconnecting\n" ); + break; + } + + System.out.print("Sending string: '" + rx + "'\n"); + out.println( rx ); + } + out.close(); + in.close(); + skt.close(); + srvr.close(); + } + catch(Exception e) { + System.out.print("Whoops! It didn't work!\n"); + } + } +} \ No newline at end of file diff --git a/CopterController/TCPexample/Server.java b/CopterController/TCPexample/Server.java index fbd1eda..5c5dcc9 100644 --- a/CopterController/TCPexample/Server.java +++ b/CopterController/TCPexample/Server.java @@ -4,6 +4,7 @@ import java.net.*; /** * Echo server. if receives "DISCONNECT", will shut down server properly + * Used for testing GroundStation communications */ class Server { public static void main(String args[]) { diff --git a/GroundStation/v1/GroundStation.class b/GroundStation/v1/GroundStation.class index 5719b8a..eee6072 100644 Binary files a/GroundStation/v1/GroundStation.class and b/GroundStation/v1/GroundStation.class differ