/*
|
/*
|
* Java libusb wrapper
|
* Java libusb wrapper
|
* Copyright (c) 2005-2006 Andreas Schläpfer <spandi at users.sourceforge.net>
|
* Copyright (c) 2005-2006 Andreas Schläpfer <spandi at users.sourceforge.net>
|
*
|
*
|
* http://libusbjava.sourceforge.net
|
* http://libusbjava.sourceforge.net
|
* This library is covered by the LGPL, read LGPL.txt for details.
|
* This library is covered by the LGPL, read LGPL.txt for details.
|
*/
|
*/
|
package ch.ntb.usb;
|
package ch.ntb.usb;
|
|
|
/**
|
/**
|
* Represents the descriptor of a USB interface.<br>
|
* Represents the descriptor of a USB interface.<br>
|
* The interface descriptor could be seen as a header or grouping of the
|
* The interface descriptor could be seen as a header or grouping of the
|
* endpoints into a functional group performing a single feature of the device.<br>
|
* endpoints into a functional group performing a single feature of the device.<br>
|
* <br>
|
* <br>
|
* The length of the interface descriptor is
|
* The length of the interface descriptor is
|
* {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
|
* {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE_SIZE} and the type is
|
* {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE}.
|
* {@link ch.ntb.usb.Usb_Descriptor#USB_DT_INTERFACE}.
|
*
|
*
|
*/
|
*/
|
public class Usb_Interface_Descriptor extends Usb_Descriptor {
|
public class Usb_Interface_Descriptor extends Usb_Descriptor {
|
|
|
/**
|
/**
|
* Maximum number of interfaces
|
* Maximum number of interfaces
|
*/
|
*/
|
public static final int USB_MAXINTERFACES = 32;
|
public static final int USB_MAXINTERFACES = 32;
|
|
|
private byte bInterfaceNumber;
|
private byte bInterfaceNumber;
|
|
|
private byte bAlternateSetting;
|
private byte bAlternateSetting;
|
|
|
private byte bNumEndpoints;
|
private byte bNumEndpoints;
|
|
|
private byte bInterfaceClass;
|
private byte bInterfaceClass;
|
|
|
private byte bInterfaceSubClass;
|
private byte bInterfaceSubClass;
|
|
|
private byte bInterfaceProtocol;
|
private byte bInterfaceProtocol;
|
|
|
private byte iInterface;
|
private byte iInterface;
|
|
|
private Usb_Endpoint_Descriptor[] endpoint;
|
private Usb_Endpoint_Descriptor[] endpoint;
|
|
|
private byte[] extra; /* Extra descriptors */
|
private byte[] extra; /* Extra descriptors */
|
|
|
private int extralen;
|
private int extralen;
|
|
|
@Override
|
@Override
|
public String toString() {
|
public String toString() {
|
return "Usb_Interface_Descriptor bNumEndpoints: 0x"
|
return "Usb_Interface_Descriptor bNumEndpoints: 0x"
|
+ Integer.toHexString(bNumEndpoints);
|
+ Integer.toHexString(bNumEndpoints);
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(int, int)}).<br>
|
* Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(long, int)}).<br>
|
*
|
*
|
* @return the alternate setting
|
* @return the alternate setting
|
*/
|
*/
|
public byte getBAlternateSetting() {
|
public byte getBAlternateSetting() {
|
return bAlternateSetting;
|
return bAlternateSetting;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the class code (Assigned by <a
|
* Returns the class code (Assigned by <a
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
*
|
*
|
* @return the class code
|
* @return the class code
|
*/
|
*/
|
public byte getBInterfaceClass() {
|
public byte getBInterfaceClass() {
|
return bInterfaceClass;
|
return bInterfaceClass;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the number (identifier) of this interface.<br>
|
* Returns the number (identifier) of this interface.<br>
|
*
|
*
|
* @return the number (identifier) of this interface
|
* @return the number (identifier) of this interface
|
*/
|
*/
|
public byte getBInterfaceNumber() {
|
public byte getBInterfaceNumber() {
|
return bInterfaceNumber;
|
return bInterfaceNumber;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the protocol code (Assigned by <a
|
* Returns the protocol code (Assigned by <a
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
*
|
*
|
* @return the protocol code
|
* @return the protocol code
|
*/
|
*/
|
public byte getBInterfaceProtocol() {
|
public byte getBInterfaceProtocol() {
|
return bInterfaceProtocol;
|
return bInterfaceProtocol;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the subclass code (Assigned by <a
|
* Returns the subclass code (Assigned by <a
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
* href="http://www.usb.org">www.usb.org</a>).<br>
|
*
|
*
|
* @return the subclass code
|
* @return the subclass code
|
*/
|
*/
|
public byte getBInterfaceSubClass() {
|
public byte getBInterfaceSubClass() {
|
return bInterfaceSubClass;
|
return bInterfaceSubClass;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the number of endpoints used for this interface.<br>
|
* Returns the number of endpoints used for this interface.<br>
|
*
|
*
|
* @return the number of endpoints used for this interface
|
* @return the number of endpoints used for this interface
|
*/
|
*/
|
public byte getBNumEndpoints() {
|
public byte getBNumEndpoints() {
|
return bNumEndpoints;
|
return bNumEndpoints;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns an array of endpoint descriptors.<br>
|
* Returns an array of endpoint descriptors.<br>
|
*
|
*
|
* @return an array of endpoint descriptors
|
* @return an array of endpoint descriptors
|
*/
|
*/
|
public Usb_Endpoint_Descriptor[] getEndpoint() {
|
public Usb_Endpoint_Descriptor[] getEndpoint() {
|
return endpoint;
|
return endpoint;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the data of extra descriptor(s) if available.<br>
|
* Returns the data of extra descriptor(s) if available.<br>
|
*
|
*
|
* @return null or a byte array with the extra descriptor data
|
* @return null or a byte array with the extra descriptor data
|
*/
|
*/
|
public byte[] getExtra() {
|
public byte[] getExtra() {
|
return extra;
|
return extra;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the number of bytes of the extra descriptor.<br>
|
* Returns the number of bytes of the extra descriptor.<br>
|
*
|
*
|
* @return the number of bytes of the extra descriptor
|
* @return the number of bytes of the extra descriptor
|
*/
|
*/
|
public int getExtralen() {
|
public int getExtralen() {
|
return extralen;
|
return extralen;
|
}
|
}
|
|
|
/**
|
/**
|
* Returns the index of the String descriptor describing this interface.<br>
|
* Returns the index of the String descriptor describing this interface.<br>
|
*
|
*
|
* @return the index of the String descriptor
|
* @return the index of the String descriptor
|
*/
|
*/
|
public byte getIInterface() {
|
public byte getIInterface() {
|
return iInterface;
|
return iInterface;
|
}
|
}
|
}
|
}
|
|
|