cbox.comm
Interface CommPort

All Known Implementing Classes:
UARTCommPort

public interface CommPort

Communication port abstraction class.
Used with USB or Bluetooth communication classes

Author:
Martin Wolf
See Also:
cbox.comm.USBCommPort, UARTCommPort

Field Summary
static int BR_115200
          Baudrate 115200 bauds
static int BR_1200
          Baudrate 1200 bauds
static int BR_19200
          Baudrate 19200 bauds
static int BR_2400
          Baudrate 2400 bauds
static int BR_38400
          Baudrate 38400 bauds
static int BR_4800
          Baudrate 4800 bauds
static int BR_57600
          Baudrate 57600 bauds
static int BR_9600
          Baudrate 9600 bauds
static int DATABITS_EIGHT
          8 databits
static int DATABITS_SEVEN
          7 databits
static int PARITY_EVEN
          Even parity
static int PARITY_MARK
          Mark parity
static int PARITY_NONE
          None parity
static int PARITY_ODD
          Odd parity
static int PARITY_SPACE
          Space parity
static int STOPBIT_1_5
          1.5 stopbits
static int STOPBIT_ONE
          one stopbit
static int STOPBIT_TWO
          2 stopbits
 
Method Summary
 void close()
          Open port with comm speed baudrate, parity, databits and stopbits.
 int getStatus()
          Returns interface status.
 boolean open(int baudrate, int parity, int databits, int stopbits)
          Open communication port with comm speed baudrate, parity, databits and stopbits.
 int read(byte[] buffer, int offset, int len)
          Reads len bytes to buffer at offset from communication interface.
 int write(byte[] buffer, int offset, int len)
          Writes len bytes from buffer starting from offset to communication interface.
 

Field Detail

BR_115200

static final int BR_115200
Baudrate 115200 bauds

See Also:
Constant Field Values

BR_57600

static final int BR_57600
Baudrate 57600 bauds

See Also:
Constant Field Values

BR_38400

static final int BR_38400
Baudrate 38400 bauds

See Also:
Constant Field Values

BR_19200

static final int BR_19200
Baudrate 19200 bauds

See Also:
Constant Field Values

BR_9600

static final int BR_9600
Baudrate 9600 bauds

See Also:
Constant Field Values

BR_4800

static final int BR_4800
Baudrate 4800 bauds

See Also:
Constant Field Values

BR_2400

static final int BR_2400
Baudrate 2400 bauds

See Also:
Constant Field Values

BR_1200

static final int BR_1200
Baudrate 1200 bauds

See Also:
Constant Field Values

PARITY_NONE

static final int PARITY_NONE
None parity

See Also:
Constant Field Values

PARITY_ODD

static final int PARITY_ODD
Odd parity

See Also:
Constant Field Values

PARITY_EVEN

static final int PARITY_EVEN
Even parity

See Also:
Constant Field Values

PARITY_MARK

static final int PARITY_MARK
Mark parity

See Also:
Constant Field Values

PARITY_SPACE

static final int PARITY_SPACE
Space parity

See Also:
Constant Field Values

DATABITS_EIGHT

static final int DATABITS_EIGHT
8 databits

See Also:
Constant Field Values

DATABITS_SEVEN

static final int DATABITS_SEVEN
7 databits

See Also:
Constant Field Values

STOPBIT_ONE

static final int STOPBIT_ONE
one stopbit

See Also:
Constant Field Values

STOPBIT_1_5

static final int STOPBIT_1_5
1.5 stopbits

See Also:
Constant Field Values

STOPBIT_TWO

static final int STOPBIT_TWO
2 stopbits

See Also:
Constant Field Values
Method Detail

open

boolean open(int baudrate,
             int parity,
             int databits,
             int stopbits)
Open communication port with comm speed baudrate, parity, databits and stopbits.

NOTE: This does not apply to USB communication.
USB settings are 115200 bauds, 8 databits, 1 stopbit and none parity.

Returns:
true if operation succeed

close

void close()
Open port with comm speed baudrate, parity, databits and stopbits.

NOTE: This does not apply to USB communication.
USB settings are 115200 bauds, 8 databits, 1 stopbit and none parity.


write

int write(byte[] buffer,
          int offset,
          int len)
Writes len bytes from buffer starting from offset to communication interface.

Returns:
Number of bytes written

read

int read(byte[] buffer,
         int offset,
         int len)
Reads len bytes to buffer at offset from communication interface.

Returns:
Number of bytes readen

getStatus

int getStatus()
Returns interface status.