ztex
Class ZtexDevice1

java.lang.Object
  extended by ztex.ZtexDevice1

public class ZtexDevice1
extends java.lang.Object

A class representing an EZ-USB device that supports the ZTEX descriptor 1 or an unconfigured EZ-USB device.
Instances of this class are usually created by ZtexScanBus1. The following table describes the ZTEX descriptor 1.

Field name Offset Size Description
ZTEX_DESCRIPTOR_SIZE 0 1 Size of the descriptor in bytes; must be 40 for descriptor version 1
ZTEX_DESCRIPTOR_VERSION 1 1 Descriptor version; 1 for version 1
ZTEXID 2 4 ID; must be "ZTEX"
PRODUCT_ID 6 4 Four numbers (0..255) representing the product ID and firmware compatibility information.
A firmware can overwrite an installed one
if ( INSTALLED.PRODUCTID[0]==0 || PRODUCTID[0]==0 || INSTALLED.PRODUCTID[0]==PRODUCTID[0] ) && 
   ( INSTALLED.PRODUCTID[1]==0 || PRODUCTID[1]==0 || INSTALLED.PRODUCTID[1]==PRODUCTID[1] ) && 
   ( INSTALLED.PRODUCTID[2]==0 || PRODUCTID[2]==0 || INSTALLED.PRODUCTID[2]==PRODUCTID[2] ) && 
   ( INSTALLED.PRODUCTID[3]==0 || PRODUCTID[3]==0 || INSTALLED.PRODUCTID[3]==PRODUCTID[3] ) 
Here is a list of the preserved product ID's:
 
0.0.0.0 default Product ID (no product specified)
1.*.*.* may be used for experimental purposes
10.*.*.* used for ZTEX products
10.11.*.* ZTEX USB-FPGA-Module 1.2
10.12.*.* ZTEX USB-FPGA-Module 1.11
10.13.*.* ZTEX USB-FPGA-Module 1.15 (not 1.15y)
10.14.*.* ZTEX USB-FPGA-Module 1.15x
10.15.*.* ZTEX USB-FPGA-Module 1.15y
10.20.*.* ZTEX USB-Module 1.0
10.30.*.* ZTEX USB-XMEGA-Module 1.0
10.0.1.1 ZTEX BTCMiner firmware
Please contact us (http://www.ztex.de/contact.e.html) if you want to register or reserve a Product ID (range).
FW_VERSION 10 1 May be used to specify the firmware version.
INTERFACE_VERSION 11 1 The interface version. This number specifies the protocol that is used for interfacing the host software. A description of interface version 1 can be found in Ztex1v1
INTERFACE_CAPABILITIES 12 6 6 bytes, each bit represents a capability. If set, the capability is supported. A description of the capabilities of interface version 1 can be found in Ztex1v1
MODULE_RESERVED 18 12 12 bytes for application specific use, i.e. they depend from the PRODUCT_ID
SN_STRING 30 10 A serial number string of 10 characters. The default SN is "0000000000"

See Also:
Ztex1, Ztex1v1, ZtexScanBus1

Field Summary
static int cypressProductId
          EZ-USB USB product ID: 0x8613
static int cypressVendorId
          Cypress vendor ID: 0x4b4
static int ztexProductId
          USB product ID for ZTEX devices that support ZTEX descriptor 1: 0x100.
static int ztexProductIdMax
          Largest USB product ID for ZTEX devices that support ZTEX descriptor 1: 0x1ff.
static int ztexVendorId
          ZTEX vendor ID: 0x221a
 
Constructor Summary
ZtexDevice1(Usb_Device p_dev, int pUsbVendorId, int pUsbProductId, boolean allowUnconfigured)
          Constructs an instance from a given USB device.
 
Method Summary
static java.lang.String byteArrayString(byte[] buf)
          Produces a nice string representation of an array of bytes.
 boolean compatible(int productId0, int productId1, int productId2, int productId3)
          Checks whether the given product ID is compatible to the device.
 Usb_Device dev()
          Returns the USB device.
 int fwVersion()
          Returns the firmware version.
 byte[] interfaceCapabilities()
          Returns the interface capabilities (all 6 bytes).
 int interfaceCapabilities(int i)
          Returns byte i of the interface capabilities.
 boolean interfaceCapabilities(int i, int j)
          Returns byte i, bit j of the interface capabilities.
 int interfaceVersion()
          Returns the interface version.
 java.lang.String manufacturerString()
          Returns the manufacturer string of the device.
 byte[] moduleReserved()
          Returns the application specific information (all 12 bytes).
 int moduleReserved(int i)
          Returns byte i of the application specific information.
 byte[] productId()
          Returns the product ID (all 4 bytes).
 int productId(int i)
          Returns byte i of the product ID.
 java.lang.String productString()
          Returns the product string of the device.
 java.lang.String snString()
          Returns the serial number string of the device.
 java.lang.String toString()
          Returns a string representation if the device with a lot of useful information.
 int usbProductId()
          Returns the USB product ID of the device.
 int usbVendorId()
          Returns the USB vendor ID of the device.
 boolean valid()
          Returns true if ZTEX descriptor 1 is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cypressVendorId

public static final int cypressVendorId
Cypress vendor ID: 0x4b4

See Also:
Constant Field Values

cypressProductId

public static final int cypressProductId
EZ-USB USB product ID: 0x8613

See Also:
Constant Field Values

ztexVendorId

public static final int ztexVendorId
ZTEX vendor ID: 0x221a

See Also:
Constant Field Values

ztexProductId

public static final int ztexProductId
USB product ID for ZTEX devices that support ZTEX descriptor 1: 0x100. This product ID is intended for general purpose use and can be shared by all devices that base on ZTEX modules. Different products are identified by a second product ID, namely the PRODUCT_ID field of the ZTEX descriptor 1.

Please read the informations about USB vendor and product ID's.

See Also:
ztexProductIdMax, Constant Field Values

ztexProductIdMax

public static final int ztexProductIdMax
Largest USB product ID for ZTEX devices that support ZTEX descriptor 1: 0x1ff. USB product ID's from ztexProductId+1 to ztexProductIdMax (0x101 to 0x1ff) are reserved for ZTEX devices and allow to identify products without reading the ZTEX descriptor.

Please read the informations about USB vendor and product ID's.

See Also:
ztexProductId, Constant Field Values
Constructor Detail

ZtexDevice1

public ZtexDevice1(Usb_Device p_dev,
                   int pUsbVendorId,
                   int pUsbProductId,
                   boolean allowUnconfigured)
            throws UsbException,
                   InvalidFirmwareException,
                   DeviceNotSupportedException
Constructs an instance from a given USB device.
If the given vendor and product id's match to the vendor and product id's of the given USB device, the ZTEX descriptor 1 is attempted to read. If this fails, an InvalidFirmwareException is thrown. To suppress this behavior (e.g. if the EZ-USB device is known to be unconfigured) the vendor and product id's can be set to -1.

Parameters:
p_dev - The USB device.
pUsbVendorId - The given vendor ID.
pUsbProductId - The given product ID.
allowUnconfigured - If true, unconfigured devices are allowed.
Throws:
UsbException - if an USB communication error occurs.
InvalidFirmwareException - if no valid ZTEX descriptor 1 is found.
DeviceNotSupported - if the device has the wrong USB ID's.
DeviceNotSupportedException
Method Detail

byteArrayString

public static java.lang.String byteArrayString(byte[] buf)
Produces a nice string representation of an array of bytes.

Parameters:
buf - A byte array.
Returns:
a nice string

toString

public java.lang.String toString()
Returns a string representation if the device with a lot of useful information.

Overrides:
toString in class java.lang.Object
Returns:
a string representation if the device with a lot of useful information.

compatible

public final boolean compatible(int productId0,
                                int productId1,
                                int productId2,
                                int productId3)
Checks whether the given product ID is compatible to the device.
The given product ID is compatible
if ( this.productId(0)==0 || productId0<=0 || this.productId(0)==productId0 ) && 
   ( this.productId(0)==0 || productId1<=0 || this.productId(1)==productId1 ) && 
   ( this.productId(2)==0 || productId2<=0 || this.productId(2)==productId2 ) && 
   ( this.productId(3)==0 || productId3<=0 || this.productId(3)==productId3 ) 

Parameters:
productId0 - Byte 0 of the given product ID
productId1 - Byte 1 of the given product ID
productId2 - Byte 2 of the given product ID
productId3 - Byte 3 of the given product ID
Returns:
true if the given product ID is compatible

dev

public final Usb_Device dev()
Returns the USB device.

Returns:
the USB device.

valid

public final boolean valid()
Returns true if ZTEX descriptor 1 is available.

Returns:
true if ZTEX descriptor 1 is available.

usbVendorId

public final int usbVendorId()
Returns the USB vendor ID of the device.

Returns:
the USB vendor ID of the device.

usbProductId

public final int usbProductId()
Returns the USB product ID of the device.

Returns:
the USB product ID of the device.

manufacturerString

public final java.lang.String manufacturerString()
Returns the manufacturer string of the device.

Returns:
the manufacturer string of the device.

productString

public final java.lang.String productString()
Returns the product string of the device.

Returns:
the product string of the device.

snString

public final java.lang.String snString()
Returns the serial number string of the device.

Returns:
the serial number string of the device.

productId

public final byte[] productId()
Returns the product ID (all 4 bytes).

Returns:
PRODUCT_ID, see above.

productId

public int productId(int i)
Returns byte i of the product ID.

Parameters:
i - index
Returns:
PRODUCT_ID[i], see above.

fwVersion

public final int fwVersion()
Returns the firmware version.

Returns:
FW_VERSION, see above.

interfaceVersion

public final int interfaceVersion()
Returns the interface version.

Returns:
INTERFACE_VERSION, see above.

interfaceCapabilities

public final byte[] interfaceCapabilities()
Returns the interface capabilities (all 6 bytes).

Returns:
INTERFACE_CAPABILITIES, see above.

interfaceCapabilities

public final int interfaceCapabilities(int i)
Returns byte i of the interface capabilities.

Parameters:
i - index
Returns:
INTERFACE_CAPABILITIES[i], see above.

interfaceCapabilities

public final boolean interfaceCapabilities(int i,
                                           int j)
Returns byte i, bit j of the interface capabilities.

Parameters:
i - byte index
j - bit index
Returns:
INTERFACE_CAPABILITIES[i].j, see above.

moduleReserved

public final byte[] moduleReserved()
Returns the application specific information (all 12 bytes).

Returns:
MODULE_RESERVED, see above.

moduleReserved

public final int moduleReserved(int i)
Returns byte i of the application specific information.

Parameters:
i - index
Returns:
MODULE_RESERVED[i], see above.