?? hubdescriptor.java
字號:
/*
* $Id: HubDescriptor.java,v 1.1 2003/11/25 11:42:24 epr Exp $
*/
package org.jnode.driver.usb.hub;
import org.jnode.driver.usb.AbstractDescriptor;
import org.jnode.util.NumberUtils;
/**
* @author Ewout Prangsma (epr@users.sourceforge.net)
*/
public class HubDescriptor extends AbstractDescriptor implements USBHubConstants {
/**
* Initialize this instance.
*/
public HubDescriptor() {
super(USB_DT_HUB_NONVAR_SIZE + (256 / 8) * 2);
}
/**
* Gets the number of downstream ports
*/
public final int getNumPorts() {
return getByte(2);
}
/**
* Gets the HUB characteristics
*/
public final int getCharacteristics() {
return getShort(3);
}
/**
* Gets the logical power switching mode.
* @return 0=all at once, 1=individual ports, 2=3=reserved
*/
public final int getLogicalPowerSwitchingMode() {
return getShort(3) & HUB_CHAR_LPSM;
}
/**
* Gets the number of milliseconds between a power on and a power good situation on a port. The
* HUB descriptor gives this number in 2ms intervals, the value returned is in ms, which
* implies that the descriptor value has already been multiplied by 2.
*/
public final int getPowerOn2PowerGood() {
return getByte(5) << 1;
}
/**
* Gets the maximum current requirements of the HUB controller in mA.
*/
public final int getHubControllerCurrent() {
return getByte(6);
}
/**
* Is the device connected to the given port removable.
*
* @param port
*/
public final boolean isRemovableDevice(int port) {
return ((getByte(7 + (port + 1) / 8) & (1 << ((port + 1) % 8))) == 0);
}
/**
* Convert to a String representation.
*
* @see java.lang.Object#toString()
*/
public String toString() {
final StringBuffer b = new StringBuffer();
final int ports = getNumPorts();
final int chars = getCharacteristics();
b.append("HUB[");
b.append("length:");
b.append(getLength());
b.append(", #ports:");
b.append(ports);
b.append(", char:0x");
b.append(NumberUtils.hex(chars, 4));
b.append(", pon2pg:");
b.append(getPowerOn2PowerGood());
b.append("maxCtrlCur:");
b.append(getHubControllerCurrent());
if ((chars & HUB_CHAR_COMPOUND) != 0) {
b.append(", devs:");
for (int i = 0; i < ports; i++) {
b.append(isRemovableDevice(i) ? 'R' : 'F');
}
}
return b.toString();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -