|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlejos.pc.comm.NXTCommUSB
public abstract class NXTCommUSB
Base Implementation of NXTComm for USB This module implements two types of I/O over USB. 1. The standard Lego LCP format used for LCP command processing. 2. A Simple packet based protocol that can be used to transport a simple byte stream. Protocol 2 is required (rather then using raw USB operations), to allow the signaling of things like open, and close over the connection. Notes This module assumes that the device read and write functions have a built in timeout period of approx 20 seconds. This module assumes that this timeout exists and uses it to timeout some requests. Should not be used directly - use NXTCommFactory to create an appropriate NXTComm object for your system and the protocol you are using.
| Field Summary |
|---|
| Fields inherited from interface lejos.pc.comm.NXTComm |
|---|
LCP, PACKET, RAW |
| Constructor Summary | |
|---|---|
NXTCommUSB()
|
|
| Method Summary | |
|---|---|
int |
available()
The number of bytes that can be read without blocking. |
void |
close()
Close the current device. |
protected void |
finalize()
|
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 name and address. |
boolean |
open(NXTInfo nxtInfo,
int mode)
Open a connection to the specified device, and make it available for use. |
byte[] |
read()
Read bytes from the device |
NXTInfo[] |
search(java.lang.String name)
Locate available nxt devices and return them. |
byte[] |
sendRequest(byte[] data,
int replyLen)
Send a Lego Command Protocol (LCP) request to the device. |
void |
write(byte[] data)
Write bytes to the device. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NXTCommUSB()
| Method Detail |
|---|
public NXTInfo[] search(java.lang.String name)
search in interface NXTCommname - The name to search for. If null return all devices.
public boolean open(NXTInfo nxtInfo,
int mode)
open in interface NXTCommnxtInfo - The device to connect to.mode - the I/O mode to be used on this connection.
public boolean open(NXTInfo nxt)
throws NXTCommException
NXTComm
open in interface NXTCommnxt - the NXTInfo object for the NXT
true if the open succeeded
NXTCommException
public void close()
throws java.io.IOException
close in interface NXTCommRequestjava.io.IOException
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
public byte[] sendRequest(byte[] data,
int replyLen)
throws java.io.IOException
sendRequest in interface NXTCommRequestdata - The command to send.replyLen - How many bytes in the optional reply.
java.io.IOException - Thrown on errors.
public byte[] read()
throws java.io.IOException
read in interface NXTCommjava.io.IOException
public int available()
throws java.io.IOException
available in interface NXTCommjava.io.IOException
public void write(byte[] data)
throws java.io.IOException
write in interface NXTCommdata - Data to be written.
java.io.IOExceptionpublic java.io.OutputStream getOutputStream()
NXTCommOutputStream for writing a stream of data to the NXT over this connection.
getOutputStream in interface NXTCommOutputStream objectpublic java.io.InputStream getInputStream()
NXTCommInputStream for reading a stream of data from the NXT over this connection.
getInputStream in interface NXTCommInputStream object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||