add new urjtag-based code, fjmem
[fleet.git] / src / edu / berkeley / fleet / fpga / Server.java
index 2e6c5ac..eb017ba 100644 (file)
@@ -15,7 +15,7 @@ public class Server {
     static {
         try {
             jarFileTime = new File("fleet.jar").lastModified();
-            bitFileTime = new File("build/fpga/main.bit").lastModified();
+            bitFileTime = new File("./main.bit").lastModified();
         } catch (Exception e) { throw new RuntimeException(e); }
     }
 
@@ -23,8 +23,8 @@ public class Server {
     public static void main(String[] args) throws Exception {
         System.err.println("programming...");
         Process proc = Runtime.getRuntime().exec(new String[] {
-                "misc/program.sh",
-                "build/fpga/main.bit"
+                "./misc/program.sh",
+                "./main.bit"
             });
         BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
         String str = null;
@@ -46,7 +46,7 @@ public class Server {
                             System.err.println("jarfile modified; exiting...");
                             System.exit(0);
                         }
-                        if (bitFileTime != new File("build/fpga/main.bit").lastModified()) {
+                        if (bitFileTime != new File("./main.bit").lastModified()) {
                             System.err.println("bitfile modified; exiting...");
                             System.exit(0);
                         }
@@ -77,10 +77,14 @@ public class Server {
             synchronized(Server.class) {
                 System.err.println("   (got it)");
                 try {
-                    this.sp = new RXTXPort("/dev/ttyS0");
+                    if (new File("/dev/cu.usbserial-FTCBWI2P").exists())
+                        this.sp = new RXTXPort("/dev/cu.usbserial-FTCBWI2P");
+                    else
+                        this.sp = new RXTXPort("/dev/ttyS0");
                     sp.setInputBufferSize(0);
                     sp.setOutputBufferSize(0);
-                    sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
+                    //sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
+                    sp.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
                     //sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_IN | sp.FLOWCONTROL_RTSCTS_OUT);
                     sp.setFlowControlMode(0);
                     try {
@@ -98,6 +102,8 @@ public class Server {
                 final OutputStream fos = sp.getOutputStream();
                 final InputStream fis = new BufferedInputStream(sp.getInputStream());
 
+                sp.sendBreak(100);
+
                 // read login string
                 byte[] buf = new byte[1024];
                 StringBuffer sb = new StringBuffer();