re-arrange some code in Server.java
authoradam <adam@megacz.com>
Sat, 12 Apr 2008 13:00:37 +0000 (14:00 +0100)
committeradam <adam@megacz.com>
Sat, 12 Apr 2008 13:00:37 +0000 (14:00 +0100)
src/edu/berkeley/fleet/fpga/Server.java

index 15aaa1b..ba311f1 100644 (file)
@@ -75,9 +75,8 @@ public class Server {
                     this.sp = new RXTXPort("/dev/ttyS0");
                     sp.setInputBufferSize(0);
                     sp.setOutputBufferSize(0);
-                    sp.sendBreak(100);
-                    Thread.sleep(100);
-                    sp.sendBreak(100);
+                    sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
+                    sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_IN | sp.FLOWCONTROL_RTSCTS_OUT);
                     try {
                         _run();
                     } finally {
@@ -100,17 +99,20 @@ public class Server {
                 System.err.println("login string: " + sb.toString());
                 if (!sb.toString().startsWith(pass_string)) return;
 
-                //try { Thread.sleep(2000); } catch(Exception e) { }
+                //try { Thread.sleep(500); } catch(Exception e) { }
                 final OutputStream os = socket.getOutputStream();
-                System.err.println("sending instructions...");
 
-                sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
-                sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_IN | sp.FLOWCONTROL_RTSCTS_OUT);
+                System.out.println("sending breaks");
+                for(int i=0; i<2; i++) {
+                    sp.sendBreak(100);
+                    Thread.sleep(100);
+                }
+                System.out.println("done sending breaks");
+
                 final OutputStream fos = sp.getOutputStream();
                 final InputStream fis = sp.getInputStream();
-                while(fis.available() > 0)
-                    is.read();
 
+                System.err.println("sending instructions...");
                 new Thread() {
                     public void run() {
                         try {