lejos.pc.comm
Interface NXTComm

All Superinterfaces:
NXTCommRequest
All Known Implementing Classes:
NXTCommBluecove, NXTCommBluez, NXTCommFantom, NXTCommLibnxt, NXTCommUSB

public interface NXTComm
extends NXTCommRequest

Interface that all NXTComm implementation classes must implement for low-level communication with the NXT.


Field Summary
static int LCP
           
static int PACKET
           
static int RAW
           
 
Method Summary
 int available()
          Request the number of bytes available to read.
 java.io.InputStream getInputStream()
          Return an InputStream for reading a stream of data from the NXT over this connection.
 java.io.OutputStream getOutputStream()
          Return an OutputStream for writing a stream of data to the NXT over this connection.
 boolean open(NXTInfo nxt)
          Connect to a NXT found by a search or created from mname and address.
 boolean open(NXTInfo nxt, int mode)
          Connect to a NXT found by a search or created from mname and address.
 byte[] read()
          Read data from a NXT that has an open connection.
 NXTInfo[] search(java.lang.String name, int protocol)
          Search for NXTs over USB, Bluetooth or both
 void write(byte[] data)
          Write data to a NXT that has an open connection.
 
Methods inherited from interface lejos.nxt.remote.NXTCommRequest
close, sendRequest
 

Field Detail

PACKET

static final int PACKET
See Also:
Constant Field Values

LCP

static final int LCP
See Also:
Constant Field Values

RAW

static final int RAW
See Also:
Constant Field Values
Method Detail

search

NXTInfo[] search(java.lang.String name,
                 int protocol)
                 throws NXTCommException
Search for NXTs over USB, Bluetooth or both

Parameters:
name - name of the NXT or null
protocol - bitwise combination of NXTCommFactory.BLUETOOTH and NXTCommFactory.USB
Returns:
a NXTInfo object describing the NXt found and the connection to it
Throws:
NXTCommException

open

boolean open(NXTInfo nxt,
             int mode)
             throws NXTCommException
Connect to a NXT found by a search or created from mname and address.

Parameters:
nxt - the NXTInfo object for the NXT
mode - the mode for the connection
Returns:
true iff the open succeeded
Throws:
NXTCommException

open

boolean open(NXTInfo nxt)
             throws NXTCommException
Connect to a NXT found by a search or created from mname and address.

Parameters:
nxt - the NXTInfo object for the NXT
Returns:
true if the open succeeded
Throws:
NXTCommException

read

byte[] read()
            throws java.io.IOException
Read data from a NXT that has an open connection. Used for stream connections.

Returns:
the data
Throws:
java.io.IOException

available

int available()
              throws java.io.IOException
Request the number of bytes available to read.

Returns:
the number of bytes available
Throws:
java.io.IOException

write

void write(byte[] data)
           throws java.io.IOException
Write data to a NXT that has an open connection.

Parameters:
data - the data to be written. Used for stream connections.
Throws:
java.io.IOException

getOutputStream

java.io.OutputStream getOutputStream()
Return an OutputStream for writing a stream of data to the NXT over this connection.

Returns:
the OutputStream object

getInputStream

java.io.InputStream getInputStream()
Return an InputStream for reading a stream of data from the NXT over this connection.

Returns:
the InputStream object