本文整理汇总了Java中org.usb4java.DescriptorUtils类的典型用法代码示例。如果您正苦于以下问题:Java DescriptorUtils类的具体用法?Java DescriptorUtils怎么用?Java DescriptorUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DescriptorUtils类属于org.usb4java包,在下文中一共展示了DescriptorUtils类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import org.usb4java.DescriptorUtils; //导入依赖的package包/类
@Override
public String toString()
{
return String.format(
"Interface Descriptor:%n" +
" bLength %18d%n" +
" bDescriptorType %10d%n" +
" bInterfaceNumber %9d%n" +
" bAlternateSetting %8d%n" +
" bNumEndpoints %12d%n" +
" bInterfaceClass %10d %s%n" +
" bInterfaceSubClass %7d%n" +
" bInterfaceProtocol %7d%n" +
" iInterface %15d%n",
bLength() & 0xff,
bDescriptorType() & 0xff,
bInterfaceNumber() & 0xff,
bAlternateSetting() & 0xff,
bNumEndpoints() & 0xff,
bInterfaceClass() & 0xff,
DescriptorUtils.getUSBClassName(bInterfaceClass()),
bInterfaceSubClass() & 0xff,
bInterfaceProtocol() & 0xff,
iInterface() & 0xff);
}
示例2: toString
import org.usb4java.DescriptorUtils; //导入依赖的package包/类
@Override
public String toString()
{
return String.format(
"Endpoint Descriptor:%n" +
" bLength %18d%n" +
" bDescriptorType %10d%n" +
" bEndpointAddress %9s EP %d %s%n" +
" bmAttributes %13d%n" +
" Transfer Type %s%n" +
" Synch Type %s%n" +
" Usage Type %s%n" +
" wMaxPacketSize %11d%n" +
" bInterval %16d%n",
bLength() & 0xff,
bDescriptorType() & 0xff,
String.format("0x%02x", bEndpointAddress() & 0xff),
bEndpointAddress() & 0x0f,
DescriptorUtils.getDirectionName(bEndpointAddress()),
bmAttributes() & 0xff,
DescriptorUtils.getTransferTypeName(bmAttributes()),
DescriptorUtils.getSynchTypeName(bmAttributes()),
DescriptorUtils.getUsageTypeName(bmAttributes()),
wMaxPacketSize() & 0xffff,
bInterval() & 0xff);
}
示例3: toString
import org.usb4java.DescriptorUtils; //导入依赖的package包/类
@Override
public String toString()
{
return String.format(
"Device Descriptor:%n" +
" bLength %18d%n" +
" bDescriptorType %10d%n" +
" bcdUSB %19s%n" +
" bDeviceClass %13d %s%n" +
" bDeviceSubClass %10d%n" +
" bDeviceProtocol %10d%n" +
" bMaxPacketSize0 %10d%n" +
" idVendor %17s%n" +
" idProduct %16s%n" +
" bcdDevice %16s%n" +
" iManufacturer %12d%n" +
" iProduct %17d%n" +
" iSerial %18d%n" +
" bNumConfigurations %7d%n",
bLength() & 0xff,
bDescriptorType() & 0xff,
DescriptorUtils.decodeBCD(bcdUSB()),
bDeviceClass() & 0xff,
DescriptorUtils.getUSBClassName(bDeviceClass()),
bDeviceSubClass() & 0xff,
bDeviceProtocol() & 0xff,
bMaxPacketSize0() & 0xff,
String.format("0x%04x", idVendor() & 0xffff),
String.format("0x%04x", idProduct() & 0xffff),
DescriptorUtils.decodeBCD(bcdDevice()),
iManufacturer() & 0xff,
iProduct() & 0xff,
iSerialNumber() & 0xff,
bNumConfigurations() & 0xff);
}
示例4: fullDescription
import org.usb4java.DescriptorUtils; //导入依赖的package包/类
public String fullDescription() {
getStringDescriptors();
final StringBuilder desc = new StringBuilder();
desc.append(String.format("%s%n", toString()));
desc.append(String.format("Device VID: %04X, PID: %04X%n", devVID & 0xFFFF, devPID & 0xFFFF));
desc.append(String.format("Device Speed: %s%n", DescriptorUtils.getSpeedName(LibUsb.getDeviceSpeed(dev))));
desc.append(DescriptorUtils.dump(devDesc, devManufacturer, devProduct, devSerialNumber));
return (desc.toString());
}
示例5: dumpDevice
import org.usb4java.DescriptorUtils; //导入依赖的package包/类
/**
* Dumps the specified device to stdout.
*
* @param device
* The device to dump.
*/
public static void dumpDevice(final Device device)
{
// Dump device address and bus number
final int address = LibUsb.getDeviceAddress(device);
final int busNumber = LibUsb.getBusNumber(device);
System.out.println(String
.format("Device %03d/%03d", busNumber, address));
// Dump port number if available
final int portNumber = LibUsb.getPortNumber(device);
if (portNumber != 0)
System.out.println("Connected to port: " + portNumber);
// Dump parent device if available
final Device parent = LibUsb.getParent(device);
if (parent != null)
{
final int parentAddress = LibUsb.getDeviceAddress(parent);
final int parentBusNumber = LibUsb.getBusNumber(parent);
System.out.println(String.format("Parent: %03d/%03d",
parentBusNumber, parentAddress));
}
// Dump the device speed
System.out.println("Speed: "
+ DescriptorUtils.getSpeedName(LibUsb.getDeviceSpeed(device)));
// Read the device descriptor
final DeviceDescriptor descriptor = new DeviceDescriptor();
int result = LibUsb.getDeviceDescriptor(device, descriptor);
if (result < 0)
{
throw new LibUsbException("Unable to read device descriptor",
result);
}
// Try to open the device. This may fail because user has no
// permission to communicate with the device. This is not
// important for the dumps, we are just not able to resolve string
// descriptor numbers to strings in the descriptor dumps.
DeviceHandle handle = new DeviceHandle();
result = LibUsb.open(device, handle);
if (result < 0)
{
System.out.println(String.format("Unable to open device: %s. "
+ "Continuing without device handle.",
LibUsb.strError(result)));
handle = null;
}
// Dump the device descriptor
System.out.print(descriptor.dump(handle));
// Dump all configuration descriptors
dumpConfigurationDescriptors(device, descriptor.bNumConfigurations());
// Close the device if it was opened
if (handle != null)
{
LibUsb.close(handle);
}
}