lejos.nxt.comm
Class USB

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

public class USB
extends NXTCommDevice

Low-level USB access.

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

Field Summary
static int RESET
           
static byte USB_CONFIGURED
           
static byte USB_READABLE
           
static byte USB_UNCONFIGURED
           
static byte USB_WRITEABLE
           
 
Fields inherited from class lejos.nxt.comm.NXTCommDevice
ADDRESS_LEN, cs, NAME, NAME_LEN, SERIAL_NO
 
Method Summary
static boolean cancelConnect()
          Cancel a long running command issued on another thread.
static NXTCommConnector getConnector()
          Provides access to the singleton connection object.
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.
 
Methods inherited from class lejos.nxt.comm.NXTCommDevice
addressToString, getAddress, getName, isAddress, loadSettings, nameToString, setAddress, setName, stringToAddress, stringToName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESET

public static final int RESET
See Also:
Constant Field Values

USB_READABLE

public static final byte USB_READABLE
See Also:
Constant Field Values

USB_WRITEABLE

public static final byte USB_WRITEABLE
See Also:
Constant Field Values

USB_CONFIGURED

public static final byte USB_CONFIGURED
See Also:
Constant Field Values

USB_UNCONFIGURED

public static final byte USB_UNCONFIGURED
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 NXTConnection)
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.

cancelConnect

public static boolean cancelConnect()
Cancel a long running command issued on another thread. NOTE: Currently only the WaitForConnection calls can be cancelled.

Returns:
true if the command was cancelled, false otherwise.

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)

getConnector

public static NXTCommConnector getConnector()
Provides access to the singleton connection object. This object can be used to create new connections.

Returns:
the connector object