// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/Uart.java
// public interface Uart extends Closeable {
//     /**
//      * Parity-bit mode.
//      */
//     enum Parity {
//         /**
//          * No parity.
//          */
//         NONE,
//         /**
//          * Even parity.
//          */
//         EVEN,
//         /**
//          * Odd parity.
//          */
//         ODD
//     }
// 
//     /**
//      * Number of stop-bits.
//      */
//     enum StopBits {
//         /**
//          * One stop bit.
//          */
//         ONE,
//         /**
//          * Two stop bits.
//          */
//         TWO
//     }
// 
//     /**
//      * Gets the input stream.
//      *
//      * @return An input stream.
//      */
//     public InputStream getInputStream();
// 
//     /**
//      * Gets the output stream.
//      *
//      * @return An output stream.
//      */
//     public OutputStream getOutputStream();
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/FlowControlledOutputStream.java
// interface Sender {
//     void send(byte[] data, int size);
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/IncomingState.java
// interface DataModuleListener {
//     void dataReceived(byte[] data, int size);
// 
//     void reportAdditionalBuffer(int bytesToAdd);
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/Log.java
// public class Log {
//     public static int println(int priority, String tag, String msg) {
//         return android.util.Log.println(priority, tag, msg);
//     }
// 
//     public static void e(String tag, String message) {
//         android.util.Log.e(tag, message);
//     }
// 
//     public static void e(String tag, String message, Throwable tr) {
//         android.util.Log.e(tag, message, tr);
//     }
// 
//     public static void w(String tag, String message) {
//         android.util.Log.w(tag, message);
//     }
// 
//     public static void w(String tag, String message, Throwable tr) {
//         android.util.Log.w(tag, message);
//     }
// 
//     public static void i(String tag, String message) {
//         android.util.Log.i(tag, message);
//     }
// 
//     public static void d(String tag, String message) {
//         android.util.Log.d(tag, message);
//     }
// 
//     public static void v(String tag, String message) {
//         android.util.Log.v(tag, message);
//     }
// }


import java.io.OutputStream;
import ioio.lib.api.Uart;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.impl.FlowControlledOutputStream.Sender;
import ioio.lib.impl.IncomingState.DataModuleListener;
import ioio.lib.impl.ResourceManager.Resource;
import ioio.lib.spi.Log;
import java.io.IOException;
import java.io.InputStream;
/*
 * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 *
 *    1. Redistributions of source code must retain the above copyright notice, this list of
 *       conditions and the following disclaimer.
 *
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list
 *       of conditions and the following disclaimer in the documentation and/or other materials
 *       provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * The views and conclusions contained in the software and documentation are those of the
 * authors and should not be interpreted as representing official policies, either expressed
 * or implied.
 */
package ioio.lib.impl;



class UartImpl extends AbstractResource implements DataModuleListener, Sender, Uart {
    private static final int MAX_PACKET = 64;

// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/api/Uart.java
// public interface Uart extends Closeable {
//     /**
//      * Parity-bit mode.
//      */
//     enum Parity {
//         /**
//          * No parity.
//          */
//         NONE,
//         /**
//          * Even parity.
//          */
//         EVEN,
//         /**
//          * Odd parity.
//          */
//         ODD
//     }
// 
//     /**
//      * Number of stop-bits.
//      */
//     enum StopBits {
//         /**
//          * One stop bit.
//          */
//         ONE,
//         /**
//          * Two stop bits.
//          */
//         TWO
//     }
// 
//     /**
//      * Gets the input stream.
//      *
//      * @return An input stream.
//      */
//     public InputStream getInputStream();
// 
//     /**
//      * Gets the output stream.
//      *
//      * @return An output stream.
//      */
//     public OutputStream getOutputStream();
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/FlowControlledOutputStream.java
// interface Sender {
//     void send(byte[] data, int size);
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/IncomingState.java
// interface DataModuleListener {
//     void dataReceived(byte[] data, int size);
// 
//     void reportAdditionalBuffer(int bytesToAdd);
// }
// 
// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/spi/Log.java
// public class Log {
//     public static int println(int priority, String tag, String msg) {
//         return android.util.Log.println(priority, tag, msg);
//     }
// 
//     public static void e(String tag, String message) {
//         android.util.Log.e(tag, message);
//     }
// 
//     public static void e(String tag, String message, Throwable tr) {
//         android.util.Log.e(tag, message, tr);
//     }
// 
//     public static void w(String tag, String message) {
//         android.util.Log.w(tag, message);
//     }
// 
//     public static void w(String tag, String message, Throwable tr) {
//         android.util.Log.w(tag, message);
//     }
// 
//     public static void i(String tag, String message) {
//         android.util.Log.i(tag, message);
//     }
// 
//     public static void d(String tag, String message) {
//         android.util.Log.d(tag, message);
//     }
// 
//     public static void v(String tag, String message) {
//         android.util.Log.v(tag, message);
//     }
// }


// Path: IOIO/iOIOLibAndroid/src/main/java/ioio/lib/impl/UartImpl.java
import java.io.OutputStream;
import ioio.lib.api.Uart;
import ioio.lib.api.exception.ConnectionLostException;
import ioio.lib.impl.FlowControlledOutputStream.Sender;
import ioio.lib.impl.IncomingState.DataModuleListener;
import ioio.lib.impl.ResourceManager.Resource;
import ioio.lib.spi.Log;
import java.io.IOException;
import java.io.InputStream;

/*
 * Copyright 2011 Ytai Ben-Tsvi. All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without modification, are
 * permitted provided that the following conditions are met:
 *
 *    1. Redistributions of source code must retain the above copyright notice, this list of
 *       conditions and the following disclaimer.
 *
 *    2. Redistributions in binary form must reproduce the above copyright notice, this list
 *       of conditions and the following disclaimer in the documentation and/or other materials
 *       provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ARSHAN POURSOHI OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * The views and conclusions contained in the software and documentation are those of the
 * authors and should not be interpreted as representing official policies, either expressed
 * or implied.
 */
package ioio.lib.impl;



class UartImpl extends AbstractResource implements DataModuleListener, Sender, Uart {
    private static final int MAX_PACKET = 64;

    private final Resource uart_;