lejos.nxt.comm
Class USB

java.lang.Object
  extended by lejos.nxt.comm.USB

public class USB
extends Object

Low-level USB access.

Author:
Lawrie Griffiths, extended to support streams by Andy Shaw

Field Summary
static String NAME
           
static int RAW
           
static int RESET
           
static String SERIAL_NO
           
 
Method Summary
static String getName()
          Return the current USB name.
static String getSerialNo()
          Return the current USB serial number.
static void loadSettings()
          Load the current system settings associated with this class.
static void setName(String nam)
          Set the USB name.
static void setSerialNo(String sn)
          Set the USB serial number.
static void usbDisable()
           
static void usbEnable(int reset)
           
static int usbRead(byte[] buf, int off, int len)
           
static void usbReset()
           
static void usbSetName(String name)
           
static void usbSetSerialNo(String serNo)
           
static int usbStatus()
           
static int usbWrite(byte[] buf, int off, int len)
           
static USBConnection waitForConnection()
          Wait for ever for the USB connection to become available.
static USBConnection waitForConnection(int timeout, int mode)
          Wait for the USB interface to become available and for a PC side program to attach to it.
static void waitForDisconnect(int timeout)
          Wait for the remote side of the connection to close down.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait
 

Field Detail

RESET

public static final int RESET
See Also:
Constant Field Values

RAW

public static final int RAW
See Also:
Constant Field Values

SERIAL_NO

public static final String SERIAL_NO
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values
Method Detail

waitForConnection

public static USBConnection waitForConnection(int timeout,
                                              int mode)
Wait for the USB interface to become available and for a PC side program to attach to it.

Parameters:
timeout - length of time to wait (in ms), if 0 wait for ever
mode - The IO mode to be used for the connection. (see USBConnection)
Returns:
a connection object or null if no connection.

waitForConnection

public static USBConnection waitForConnection()
Wait for ever for the USB connection to become available.

Returns:
a connection object or null if no connection.

waitForDisconnect

public static void waitForDisconnect(int timeout)
Wait for the remote side of the connection to close down.

Parameters:
timeout -

setSerialNo

public static void setSerialNo(String sn)
Set the USB serial number. Should be a unique 12 character String

Parameters:
sn -

getSerialNo

public static String getSerialNo()
Return the current USB serial number.

Returns:
the serial number

setName

public static void setName(String nam)
Set the USB name. Can be up to 16 character String

Parameters:
nam - the mame

getName

public static String getName()
Return the current USB name.

Returns:
the name

loadSettings

public static void loadSettings()
Load the current system settings associated with this class. Called automatically to initialize the class. May be called if it is required to reload any settings.


usbEnable

public static void usbEnable(int reset)

usbDisable

public static void usbDisable()

usbReset

public static void usbReset()

usbRead

public static int usbRead(byte[] buf,
                          int off,
                          int len)

usbWrite

public static int usbWrite(byte[] buf,
                           int off,
                           int len)

usbStatus

public static int usbStatus()

usbSetSerialNo

public static void usbSetSerialNo(String serNo)

usbSetName

public static void usbSetName(String name)