com.amarula.rp1600.sdk.util

## Class SerialPort

- java.lang.Object
- - com.amarula.rp1600.sdk.util.SerialPort

- Direct Known Subclasses:
    ICcardport, RfidPort, ScannerPort

      public class SerialPort
      extends java.lang.Object

  Manages Low level communication with Serial ports

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected int` | `mFd`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SerialPort()`
    `` | `SerialPort(java.lang.String serialPath, int baudrate)`
    `` | `SerialPort(java.lang.String serialPath, int baudrate, boolean flowcontrol)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `close()` Close a previously opened file descriptor
    `protected int` | `open(java.lang.String serialPath, int baudrate, boolean flowcontrol)`
    `int` | `read(byte[] buff, int count, int timeout)` Read data from a serial port
    `int` | `read(byte[] buff, int from, int count, int timeout)` Read data from a serial port
    `int` | `readln(byte[] buff, int count, int timeout)` Read data from a serial port until a \n is found
    `int` | `setRTS(boolean value)` Set RTS level
    `java.lang.String` | `version()` Return the version string
    `int` | `write(byte[] buff, int count)` Write data to a serial port

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### mFd

          protected int mFd

  - ### Constructor Detail

    - #### SerialPort

          public SerialPort(java.lang.String serialPath,
                            int baudrate)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### SerialPort

          public SerialPort(java.lang.String serialPath,
                            int baudrate,
                            boolean flowcontrol)
                     throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### SerialPort

          protected SerialPort()

  - ### Method Detail

    - #### open

          protected int open(java.lang.String serialPath,
                             int baudrate,
                             boolean flowcontrol)

    - #### close

          public int close()

      Close a previously opened file descriptor
      Returns:
        0 on success

    - #### write

          public int write(byte[] buff,
                           int count)

      Write data to a serial port
      Parameters:
        `buff` - Buffer containing the data
        `count` - How many bytes to write
      Returns:
        The number of bytes written or a negative error

    - #### read

          public int read(byte[] buff,
                          int count,
                          int timeout)

      Read data from a serial port
      Parameters:
        `buff` - Buffer containing the data
        `count` - How many bytes to read
        `timeout` - Read timeout in milliseconds
      Returns:
        The number of bytes written or a negative error

    - #### read

          public int read(byte[] buff,
                          int from,
                          int count,
                          int timeout)

      Read data from a serial port
      Parameters:
        `buff` - Buffer containing the data
        `from` - Fill buffer starting from this index
        `count` - How many bytes to write
        `timeout` - Read timeout in milliseconds
      Returns:
        The number of bytes written or a negative error

    - #### readln

          public int readln(byte[] buff,
                            int count,
                            int timeout)

      Read data from a serial port until a \n is found
      Parameters:
        `buff` - Buffer containing the data
        `count` - How many bytes to write
        `timeout` - Read timeout in milliseconds
      Returns:
        The number of bytes written or a negative error

    - #### setRTS

          public int setRTS(boolean value)

      Set RTS level
      Parameters:
        `value` - Set true to assert RTS
      Returns:
        The number of bytes written or a negative error

    - #### version

          public java.lang.String version()

      Return the version string