/** * For testing. Requires the <code>LEDremoteControl.ino</code> Arduino sketch on a USB connected * UNO. * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { final String mn = "main"; st = new SerialTransport(SerialPort.BAUDRATE_115200); logger.logp(Level.INFO, "SerialTransport", mn, ">"); lastRun = System.currentTimeMillis(); blink(0, 0); blink(1, 0); blink(0, 0); blink(3, 500); blink(0, 500); blink(5, 500); blink(0, 500); blink(7, 500); blink(0, 500); for (int i = 0; i < 1000; i++) { System.out.print(i + ": "); blink(1, 500); blink(0, 500); } st.close(); logger.logp(Level.INFO, "SerialTransport", mn, "<"); }
/** * For testing * * @param value * @param time * @throws DisplayException * @throws SerialPortException * @throws InterruptedException */ private static void blink(int value, int time) throws DisplayException, SerialPortException, InterruptedException { final String mn = "blink"; logger.logp( Level.INFO, "SerialTransport", mn, "> Sending " + value + ", waiting for " + time + "ms: "); st.writeByte((byte) value); String msg = st.getMessage(); Thread.sleep(time); logger.logp( Level.INFO, "SerialTransport", mn, "< '" + msg + "' time total = " + (System.currentTimeMillis() - lastRun) + "ms"); lastRun = System.currentTimeMillis(); }