com.acces.aiousb
Class USBDevice

java.lang.Object
  extended by com.acces.aiousb.USBDevice
Direct Known Subclasses:
USB_AI16_Family, USB_AO16_Family, USB_CTR_15_Family, USB_DA12_8A_Family, USB_DA12_8E_Family, USB_DIO_16_Family, USB_DIO_32_Family, USB_DIO_Family

public abstract class USBDevice
extends java.lang.Object

Class USBDevice is the abstract super class of all USB device families.


Field Summary
static int CLEAR_FIFO_METHOD_AUTO
          Enable auto-clear FIFO every falling edge of DIO port D bit 1 (on digital boards, analog boards treat as 0).
static int CLEAR_FIFO_METHOD_IMMEDIATE
          Clear FIFO as soon as command received (and disable auto-clear).
static int CLEAR_FIFO_METHOD_IMMEDIATE_AND_ABORT
          Clear FIFO as soon as command received (and disable auto-clear), and abort stream.
static int CLEAR_FIFO_METHOD_WAIT
          Clear FIFO and wait for it to be emptied.
static int CUSTOM_EEPROM_SIZE
          Size of custom EEPROM area (bytes).
 
Method Summary
 byte[] customEEPROMRead(int address, int numBytes)
          Reads data from the custom programming area of the device EEPROM.
 USBDevice customEEPROMWrite(int address, byte[] data)
          Writes data to the custom programming area of the device EEPROM.
 int getCommTimeout()
          Gets the current timeout setting for USB communications.
 int getDeviceIndex()
          Gets the device's index on the USB bus.
 java.lang.String getName()
          Gets the device's name.
 int getProductID()
          Gets the device's product ID.
 long getSerialNumber()
          Gets the device's serial number.
 java.io.PrintStream print(java.io.PrintStream stream)
          Prints the properties of this device and all of its subsystems.
 USBDevice reset()
          Perform a USB port reset to reinitialize the device.
 USBDevice setCommTimeout(int timeout)
          Sets the timeout for USB communications.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUSTOM_EEPROM_SIZE

public static final int CUSTOM_EEPROM_SIZE
Size of custom EEPROM area (bytes).

See Also:
Constant Field Values

CLEAR_FIFO_METHOD_IMMEDIATE

public static final int CLEAR_FIFO_METHOD_IMMEDIATE
Clear FIFO as soon as command received (and disable auto-clear).

See Also:
Constant Field Values

CLEAR_FIFO_METHOD_AUTO

public static final int CLEAR_FIFO_METHOD_AUTO
Enable auto-clear FIFO every falling edge of DIO port D bit 1 (on digital boards, analog boards treat as 0).

See Also:
Constant Field Values

CLEAR_FIFO_METHOD_IMMEDIATE_AND_ABORT

public static final int CLEAR_FIFO_METHOD_IMMEDIATE_AND_ABORT
Clear FIFO as soon as command received (and disable auto-clear), and abort stream.

See Also:
Constant Field Values

CLEAR_FIFO_METHOD_WAIT

public static final int CLEAR_FIFO_METHOD_WAIT
Clear FIFO and wait for it to be emptied.

See Also:
Constant Field Values
Method Detail

print

public java.io.PrintStream print(java.io.PrintStream stream)
Prints the properties of this device and all of its subsystems. Mainly useful for diagnostic purposes.

Parameters:
stream - the print stream where properties will be printed.
Returns:
The print stream.

getDeviceIndex

public int getDeviceIndex()
Gets the device's index on the USB bus. The device index isn't used within this Java class library, but is used in the underlying AIOUSB library. The device index is somewhat useful within this Java class library to differentiate between multiple devices of the same type.

Returns:
The index of the device on the USB bus.

getProductID

public int getProductID()
Gets the device's product ID.

Returns:
The device product ID.
See Also:
Product IDs

getName

public java.lang.String getName()
Gets the device's name.

Returns:
The device name.

getSerialNumber

public long getSerialNumber()
Gets the device's serial number.

Returns:
The device serial number (a 64-bit integer).
Throws:
OperationFailedException

getCommTimeout

public int getCommTimeout()
Gets the current timeout setting for USB communications.

Returns:
Current timeout setting (in milliseconds).
See Also:
setCommTimeout()

setCommTimeout

public USBDevice setCommTimeout(int timeout)
Sets the timeout for USB communications.

Parameters:
timeout - the new timeout setting (in milliseconds; default is 5,000).
Returns:
This device, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

reset

public USBDevice reset()
Perform a USB port reset to reinitialize the device.

Returns:
This device, useful for chaining together multiple operations.
Throws:
OperationFailedException

customEEPROMWrite

public USBDevice customEEPROMWrite(int address,
                                   byte[] data)
Writes data to the custom programming area of the device EEPROM. Beware that writing to the EEPROM is particularly slow. Writing the entire EEPROM may take several seconds. Before initiating a lengthy EEPROM write procedure, it is recommended that the communication timeout be increased to at least five seconds, if not ten (see setCommTimeout()). Otherwise, a timeout error will occur before the write procedure finishes. Once the write procedure is finished, you can restore the timeout to a more reasonable value. If you are writing a smaller amount of data to the EEPROM, you may reduce the timeout proportionately.

Parameters:
address - starting address from 0x000 to 0x1FF within the EEPROM.
data - an array of bytes containing the data to write to the EEPROM, beginning at the starting address. The starting address plus the data size may not exceed the maximum address of 0x1FF.
Returns:
This device, useful for chaining together multiple operations.
Throws:
java.lang.IllegalArgumentException
OperationFailedException

customEEPROMRead

public byte[] customEEPROMRead(int address,
                               int numBytes)
Reads data from the custom programming area of the device EEPROM.

Parameters:
address - starting address from 0x000 to 0x1FF within the EEPROM.
numBytes - the number of bytes to read from the EEPROM, beginning at the starting address. The starting address plus the number of bytes to read may not exceed the maximum address of 0x1FF.
Returns:
An array of bytes containing the data read from the EEPROM. The length of the array will be equal to numBytes.
Throws:
java.lang.IllegalArgumentException
OperationFailedException