package org.ioio;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class UART {

	// Define some known good constants? 
	public static final int NO_PARITY = 0;
	public static final int ODD_PARITY = 1;
	public static final int EVEN_PARITY = 2;

	public static final int BAUD_2400 = 2400;
	public static final int BAUD_4800 = 4800;
	public static final int BAUD_9600 = 9600;
	public static final int BAUD_19200 = 19200;
	public static final int BAUD_24400 = 24400;
	public static final int BAUD_48000 = 48000;
	
	public static final float ONE_STOP_BIT = 1;
	public static final float TWO_STOP_BITS = 2;
	public static final float ONE_AND_HALF_STOP_BITS = 1.5f; 
	
	// Support all standard bauds
	private int baud = 0;
	
	// even/odd/no
	private int parity = 0;
	
	// 1/1.5/2
	private int stop_bits = 0;
	
	// 7/8/9
	private int data_bits = 0;
	
	public UART(int Rx, int Tx) {		
		//TBI waiting on protocol spec
	}
	
	
	public UARTOutputStream openOutputStream() {
		return new UARTOutputStream(this);
	}
	
	public UARTInputStream openInputStream() {
		return new UARTInputStream(this);
	}
	
	// override the input/output streams? 
	public void close() {
		
	}
	
	public class UARTOutputStream extends OutputStream {

		protected UARTOutputStream(UART uart) {
			
		}
		
		@Override
		public void write(int arg0) throws IOException {
			// TODO Auto-generated method stub
			
		}
		
	}

	public class UARTInputStream extends InputStream {

		
		protected UARTInputStream(UART uart) {
			
		}
		
		@Override
		public int read() throws IOException {
			// TODO Auto-generated method stub
			return 0;
		}
		
	}
	

}

@@ -491,18 +491,18 @@
 UD_2
-44
+88
 00 = 2
-44
+88
 00;%0A
@@ -535,19 +535,19 @@
 AUD_
-480
+336
 00 = 
-480
+336
 00;%0A

fix bad bauds, I blame doing this on the shuttle at 6am :)