File: Usb_Interface_Descriptor.java

package info (click to toggle)
libusb-java 0.8%2Bztex20090101-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 416 kB
  • ctags: 810
  • sloc: java: 1,102; ansic: 605; makefile: 98; sh: 29
file content (145 lines) | stat: -rw-r--r-- 3,303 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* 
 * Java libusb wrapper
 * Copyright (c) 2005-2006 Andreas Schlaepfer <spandi at users.sourceforge.net>
 *
 * http://libusbjava.sourceforge.net
 * This library is covered by the LGPL, read LGPL.txt for details.
 */
package ch.ntb.usb;

/**
 * Represents the descriptor of a USB interface.<br>
 * 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>
 * <br>
 * 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}.
 * 
 */
public class Usb_Interface_Descriptor extends Usb_Descriptor {

	/**
	 * Maximum number of interfaces
	 */
	public static final int USB_MAXINTERFACES = 32;

	private byte bInterfaceNumber;

	private byte bAlternateSetting;

	private byte bNumEndpoints;

	private byte bInterfaceClass;

	private byte bInterfaceSubClass;

	private byte bInterfaceProtocol;

	private byte iInterface;

	private Usb_Endpoint_Descriptor[] endpoint;

	private byte[] extra; /* Extra descriptors */

	private int extralen;

	@Override
	public String toString() {
		return "Usb_Interface_Descriptor bNumEndpoints: 0x"
				+ Integer.toHexString(bNumEndpoints);
	}

	/**
	 * Returns the value used to select the alternate setting ({@link LibusbJava#usb_set_altinterface(long, int)}).<br>
	 * 
	 * @return the alternate setting
	 */
	public byte getBAlternateSetting() {
		return bAlternateSetting;
	}

	/**
	 * Returns the class code (Assigned by <a
	 * href="http://www.usb.org">www.usb.org</a>).<br>
	 * 
	 * @return the class code
	 */
	public byte getBInterfaceClass() {
		return bInterfaceClass;
	}

	/**
	 * Returns the number (identifier) of this interface.<br>
	 * 
	 * @return the number (identifier) of this interface
	 */
	public byte getBInterfaceNumber() {
		return bInterfaceNumber;
	}

	/**
	 * Returns the protocol code (Assigned by <a
	 * href="http://www.usb.org">www.usb.org</a>).<br>
	 * 
	 * @return the protocol code
	 */
	public byte getBInterfaceProtocol() {
		return bInterfaceProtocol;
	}

	/**
	 * Returns the subclass code (Assigned by <a
	 * href="http://www.usb.org">www.usb.org</a>).<br>
	 * 
	 * @return the subclass code
	 */
	public byte getBInterfaceSubClass() {
		return bInterfaceSubClass;
	}

	/**
	 * Returns the number of endpoints used for this interface.<br>
	 * 
	 * @return the number of endpoints used for this interface
	 */
	public byte getBNumEndpoints() {
		return bNumEndpoints;
	}

	/**
	 * Returns an array of endpoint descriptors.<br>
	 * 
	 * @return an array of endpoint descriptors
	 */
	public Usb_Endpoint_Descriptor[] getEndpoint() {
		return endpoint;
	}

	/**
	 * Returns the data of extra descriptor(s) if available.<br>
	 * 
	 * @return null or a byte array with the extra descriptor data
	 */
	public byte[] getExtra() {
		return extra;
	}

	/**
	 * Returns the number of bytes of the extra descriptor.<br>
	 * 
	 * @return the number of bytes of the extra descriptor
	 */
	public int getExtralen() {
		return extralen;
	}

	/**
	 * Returns the index of the String descriptor describing this interface.<br>
	 * 
	 * @return the index of the String descriptor
	 */
	public byte getIInterface() {
		return iInterface;
	}
}