本文整理汇总了Java中javax.usb.UsbDevice.getUsbDeviceDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java UsbDevice.getUsbDeviceDescriptor方法的具体用法?Java UsbDevice.getUsbDeviceDescriptor怎么用?Java UsbDevice.getUsbDeviceDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.usb.UsbDevice
的用法示例。
在下文中一共展示了UsbDevice.getUsbDeviceDescriptor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
* Find the device with vendorId and productId
*
* @param hub
* @param vendorId
* @param productId
* @return USB device or null if not found.
*/
private static UsbDevice find(UsbHub hub, short vendorId, short productId) {
UsbDevice launcher = null;
for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
if (device.isUsbHub()) {
launcher = find((UsbHub) device, vendorId, productId);
if (launcher != null)
return launcher;
} else {
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
if (desc.idVendor() == vendorId && desc.idProduct() == productId)
return device;
}
}
return null;
}
示例2: findUsbDevices
import javax.usb.UsbDevice; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static List<UsbDevice> findUsbDevices(UsbHub hub, short vendorId, short productId) {
List<UsbDevice> usbDeviceList = new ArrayList<UsbDevice>();
if (hub != null) {
for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
if (desc.idVendor() == vendorId && desc.idProduct() == productId){
mLogger.debug("Found USB device!");
usbDeviceList.add(device);
}
if (device.isUsbHub()) {
usbDeviceList.addAll(findUsbDevices((UsbHub) device, vendorId, productId));
}
}
}
return usbDeviceList;
}
示例3: findUsb
import javax.usb.UsbDevice; //导入方法依赖的package包/类
private static UsbDevice findUsb(UsbHub hub) {
UsbDevice launcher = null;
for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices()) {
if (device.isUsbHub()) {
launcher = findUsb((UsbHub) device);
if (launcher != null) return launcher;
} else {
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
System.out.println("Found on USB: idVendor: "+desc.idVendor()+", idProduct: "+desc.idProduct());
if (desc.idVendor() == VENDOR_ID && desc.idProduct() == product_id) {
System.out.println("Got our printer.");
return device;
}
}
}
return null;
}
示例4: dump
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
*
*
* @param device
*/
public static void dump(UsbDevice device)
{
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
System.out.format("%04x:%04x%n", desc.idVendor() & 0xffff,
desc.idProduct() & 0xffff);
if (device.isUsbHub())
{
UsbHub hub = (UsbHub) device;
for (UsbDevice child : (List<UsbDevice>) hub.getAttachedUsbDevices())
{
dump(child);
}
}
}
示例5: findDevice
import javax.usb.UsbDevice; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private UsbDevice findDevice(UsbHub usbHub, Module definition) throws UsbException {
List<UsbDevice> attachedUsbDevices = usbHub.getAttachedUsbDevices();
for (UsbDevice usbDevice : attachedUsbDevices) {
UsbDeviceDescriptor desc = usbDevice.getUsbDeviceDescriptor();
if (definition.isBasedOn(desc.idVendor(), desc.idProduct())) {
LOGGER.info("found device: {}", definition);
return usbDevice;
}
if (usbDevice.isUsbHub()) {
usbDevice = findDevice((UsbHub) usbDevice, definition);
if (usbDevice != null) {
return usbDevice;
}
}
}
return null;
}
示例6: findMissileLauncher
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
* Recursively searches for the missile launcher device on the specified USB
* hub and returns it. If there are multiple missile launchers attached then
* this simple demo only returns the first one.
*
* @param hub
* The USB hub to search on.
* @return The missile launcher USB device or null if not found.
*/
public static UsbDevice findMissileLauncher(UsbHub hub)
{
UsbDevice launcher = null;
for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices())
{
if (device.isUsbHub())
{
launcher = findMissileLauncher((UsbHub) device);
if (launcher != null) return launcher;
}
else
{
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
if (desc.idVendor() == VENDOR_ID &&
desc.idProduct() == PRODUCT_ID) return device;
}
}
return null;
}
示例7: findUsb
import javax.usb.UsbDevice; //导入方法依赖的package包/类
public static UsbDevice findUsb(UsbHub hub) {
UsbDevice launcher = null;
for (UsbDevice device: (List<UsbDevice>) hub.getAttachedUsbDevices()) {
if (device.isUsbHub()) {
launcher = findUsb((UsbHub) device);
if (launcher != null) return launcher;
} else {
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
System.out.println("idVendor: "+desc.idVendor()+", idProduct: "+desc.idProduct());
if (desc.idVendor() == VENDOR_ID && desc.idProduct() == PRODUCT_ID) return device;
}
}
return null;
}
示例8: findDevice
import javax.usb.UsbDevice; //导入方法依赖的package包/类
private static UsbDevice findDevice(UsbHub hub, short vendorId, short productId) {
for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices()) {
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
if (desc.idVendor() == vendorId && desc.idProduct() == productId) {
return device;
}
if (device.isUsbHub()) {
device = findDevice((UsbHub) device, vendorId, productId);
if (device != null) {
return device;
}
}
}
return null;
}
示例9: findDevice
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
*
*
* @param hub
* @param vendorId
* @param productId
* @return
*/
public static UsbDevice findDevice(UsbHub hub, int vendorId, int productId)
{
for (UsbDevice device : (List<UsbDevice>) hub.getAttachedUsbDevices())
{
if (device == null)
{
continue;
}
UsbDeviceDescriptor descriptor;
descriptor = device.getUsbDeviceDescriptor();
if (descriptor.idVendor() == vendorId
&& descriptor.idProduct() == productId)
{
return device;
}
if (device.isUsbHub())
{
device = findDevice((UsbHub) device, vendorId, productId);
if (device != null)
{
return device;
}
}
}
return null;
}
示例10: dumpName
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
* Dumps the name of the specified device to stdout.
*
* @param device
* The USB device.
* @throws UnsupportedEncodingException
* When string descriptor could not be parsed.
* @throws UsbException
* When string descriptor could not be read.
*/
private static void dumpName(final UsbDevice device)
throws UnsupportedEncodingException, UsbException
{
// Read the string descriptor indices from the device descriptor.
// If they are missing then ignore the device.
final UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
final byte iManufacturer = desc.iManufacturer();
final byte iProduct = desc.iProduct();
if (iManufacturer == 0 || iProduct == 0) return;
// Dump the device name
System.out.println(device.getString(iManufacturer) + " "
+ device.getString(iProduct));
}
示例11: isGeneratedByAKnownDevice
import javax.usb.UsbDevice; //导入方法依赖的package包/类
protected Boolean isGeneratedByAKnownDevice(UsbDevice device) {
UsbDeviceDescriptor descriptor = device.getUsbDeviceDescriptor();
return Module.isValidDevice(descriptor.idVendor(), descriptor.idProduct());
}
示例12: checkDevice
import javax.usb.UsbDevice; //导入方法依赖的package包/类
/**
* Checks if the specified USB device is a ADB device and adds it to the
* list if it is.
*
* @param usbDevice
* The USB device to check.
* @param adbDevices
* The list of ADB devices to add the USB device to when it is an
* ADB device.
*/
private static void checkDevice(UsbDevice usbDevice,
List<AdbDevice> adbDevices)
{
UsbDeviceDescriptor deviceDesc = usbDevice.getUsbDeviceDescriptor();
// Ignore devices from Non-ADB vendors
if (!isAdbVendor(deviceDesc.idVendor())) return;
// Check interfaces of device
UsbConfiguration config = usbDevice.getActiveUsbConfiguration();
for (UsbInterface iface: (List<UsbInterface>) config.getUsbInterfaces())
{
List<UsbEndpoint> endpoints = iface.getUsbEndpoints();
// Ignore interface if it does not have two endpoints
if (endpoints.size() != 2) continue;
// Ignore interface if it does not match the ADB specs
if (!isAdbInterface(iface)) continue;
UsbEndpointDescriptor ed1 =
endpoints.get(0).getUsbEndpointDescriptor();
UsbEndpointDescriptor ed2 =
endpoints.get(1).getUsbEndpointDescriptor();
// Ignore interface if endpoints are not bulk endpoints
if (((ed1.bmAttributes() & UsbConst.ENDPOINT_TYPE_BULK) == 0) ||
((ed2.bmAttributes() & UsbConst.ENDPOINT_TYPE_BULK) == 0))
continue;
// Determine which endpoint is in and which is out. If both
// endpoints are in or out then ignore the interface
byte a1 = ed1.bEndpointAddress();
byte a2 = ed2.bEndpointAddress();
byte in, out;
if (((a1 & UsbConst.ENDPOINT_DIRECTION_IN) != 0) &&
((a2 & UsbConst.ENDPOINT_DIRECTION_IN) == 0))
{
in = a1;
out = a2;
}
else if (((a2 & UsbConst.ENDPOINT_DIRECTION_IN) != 0) &&
((a1 & UsbConst.ENDPOINT_DIRECTION_IN) == 0))
{
out = a1;
in = a2;
}
else continue;
// Create ADB device and add it to the list
AdbDevice adbDevice = new AdbDevice(iface, in, out);
adbDevices.add(adbDevice);
}
}