本文整理汇总了Java中javax.usb.UsbDeviceDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java UsbDeviceDescriptor类的具体用法?Java UsbDeviceDescriptor怎么用?Java UsbDeviceDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsbDeviceDescriptor类属于javax.usb包,在下文中一共展示了UsbDeviceDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: find
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:loreii,项目名称:jLedStripe,代码行数:25,代码来源:LedStripe.java
示例2: findUsbDevices
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:fredg02,项目名称:se.bitcraze.crazyflie.lib,代码行数:18,代码来源:UsbLinkJava.java
示例3: findUsb
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:pierre-muth,项目名称:selfpi,代码行数:19,代码来源:EpsonESCPOSPrinter.java
示例4: usbDeviceAttached
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
/**
*
*
* @param use
*/
@Override
public void usbDeviceAttached(UsbServicesEvent use)
{
// If we are not already attached see if the device was the robot arm.
if (this.usbDevice == null)
{
UsbDeviceDescriptor descriptor = use.getUsbDevice().
getUsbDeviceDescriptor();
if (descriptor.idVendor() == VENDOR_ID)
{
if (descriptor.idProduct() == PRODUCT_ID)
{
// It is the robot arm, connect it.
this.usbDevice = use.getUsbDevice();
this.init();
this.fireRobotArmAttached();
Logger.getLogger(UsbRobotArm.class.getName()).log(Level.INFO,
"Robotic Arm attached.\n", use);
}
}
}
}
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:31,代码来源:UsbRobotArm.java
示例5: dump
import javax.usb.UsbDeviceDescriptor; //导入依赖的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);
}
}
}
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:22,代码来源:DeviceManager.java
示例6: findDevice
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:quirinobrizi,项目名称:jax10,代码行数:19,代码来源:X10UsbControllerProvider.java
示例7: testProvideControllerFromDefinition
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Test
public void testProvideControllerFromDefinition() throws UsbException {
Module expectedControllerDefinition = Module.CM15;
// setup
UsbServices usbServices = mock(UsbServices.class);
UsbHub usbHub = mock(UsbHub.class);
UsbDevice usbDevice = mock(UsbDevice.class);
UsbDeviceDescriptor usbDeviceDescriptor = mock(UsbDeviceDescriptor.class);
when(usbDeviceDescriptor.idVendor()).thenReturn(expectedControllerDefinition.getVendorId());
when(usbDeviceDescriptor.idProduct()).thenReturn(expectedControllerDefinition.getProductId());
when(usbDevice.getUsbDeviceDescriptor()).thenReturn(usbDeviceDescriptor);
List<UsbDevice> attachedDevices = Arrays.asList(usbDevice);
when(usbHub.getAttachedUsbDevices()).thenReturn(attachedDevices);
when(usbServices.getRootUsbHub()).thenReturn(usbHub);
when(this.usbServicesProvider.retrieveUsbHub()).thenReturn(usbHub);
// act
X10Controller actual = testObj.provideControllerBy(expectedControllerDefinition);
// assert
assertNotNull(actual);
assertEquals(expectedControllerDefinition.getProductId(), actual.productId());
assertEquals(expectedControllerDefinition.getVendorId(), actual.vendorId());
}
开发者ID:quirinobrizi,项目名称:jax10,代码行数:23,代码来源:UsbScannerTest.java
示例8: findMissileLauncher
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:30,代码来源:MissileLauncher.java
示例9: findUsb
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:pierre-muth,项目名称:selfpi,代码行数:16,代码来源:TMT20.java
示例10: findDevice
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:RaspberryPiWithJava,项目名称:JavaScale,代码行数:16,代码来源:UsbScaleTest.java
示例11: findDevice
import javax.usb.UsbDeviceDescriptor; //导入依赖的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;
}
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:41,代码来源:DeviceManager.java
示例12: testBuildControllerFor_validDefinition
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Test
public void testBuildControllerFor_validDefinition() {
Module definition = Module.CM15;
UsbDevice usbDevice = mock(UsbDevice.class);
UsbDeviceDescriptor usbDeviceDescriptor = mock(UsbDeviceDescriptor.class);
when(usbDevice.getUsbDeviceDescriptor()).thenReturn(usbDeviceDescriptor);
when(usbDeviceDescriptor.idVendor()).thenReturn(definition.getVendorId());
when(usbDeviceDescriptor.idProduct()).thenReturn(definition.getProductId());
// act
Controller controller = Module.buildControllerFor(usbDevice);
// assert
assertNotNull(controller);
assertTrue(controller instanceof CM15);
}
开发者ID:quirinobrizi,项目名称:jax10,代码行数:15,代码来源:DefinitionTest.java
示例13: testBuildControllerFor_invalidDefinition
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Test
public void testBuildControllerFor_invalidDefinition() {
UsbDevice usbDevice = mock(UsbDevice.class);
UsbDeviceDescriptor usbDeviceDescriptor = mock(UsbDeviceDescriptor.class);
when(usbDevice.getUsbDeviceDescriptor()).thenReturn(usbDeviceDescriptor);
when(usbDeviceDescriptor.idVendor()).thenReturn((short) 0x12ab4);
when(usbDeviceDescriptor.idProduct()).thenReturn((short) 0x3c44);
// act
Controller controller = Module.buildControllerFor(usbDevice);
// assert
assertNull(controller);
}
开发者ID:quirinobrizi,项目名称:jax10,代码行数:13,代码来源:DefinitionTest.java
示例14: dumpName
import javax.usb.UsbDeviceDescriptor; //导入依赖的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));
}
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:25,代码来源:DumpNames.java
示例15: usbDeviceDetached
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Override
public void usbDeviceDetached(UsbServicesEvent usbServicesEvent) {
UsbDeviceDescriptor deviceDescriptor = usbServicesEvent.getUsbDevice().getUsbDeviceDescriptor();
if (this.deviceFilter.isHighlander(deviceDescriptor)) {
LOGGER.info("Dexcom disconnected!");
} else {
String message = format("Device unplugged was ignore: vendor id [%d], product id [%d]",
deviceDescriptor.idVendor(), deviceDescriptor.idProduct());
LOGGER.debug(message);
}
}
开发者ID:alexandre-normand,项目名称:blood-shepherd,代码行数:12,代码来源:DexcomWatcher.java
示例16: getUsbDeviceDescriptor
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Override
public UsbDeviceDescriptor getUsbDeviceDescriptor() {
return device.getUsbDeviceDescriptor();
}
开发者ID:IAmContent,项目名称:public,代码行数:5,代码来源:EasedUsbDevice.java
示例17: vendorAndProductIdsMatch
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
public static boolean vendorAndProductIdsMatch(short vendorId, short productId, UsbDeviceDescriptor descriptor) {
return vendorId == descriptor.idVendor() && productId == descriptor.idProduct();
}
开发者ID:IAmContent,项目名称:public,代码行数:4,代码来源:UsbDevicePredicates.java
示例18: getUsbDeviceDescriptor
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Override
public final UsbDeviceDescriptor getUsbDeviceDescriptor()
{
return this.id.getDeviceDescriptor();
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:AbstractDevice.java
示例19: getUsbDeviceDescriptor
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
@Override
public UsbDeviceDescriptor getUsbDeviceDescriptor()
{
return this.descriptor;
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHub.java
示例20: isGeneratedByAKnownDevice
import javax.usb.UsbDeviceDescriptor; //导入依赖的package包/类
protected Boolean isGeneratedByAKnownDevice(UsbDevice device) {
UsbDeviceDescriptor descriptor = device.getUsbDeviceDescriptor();
return Module.isValidDevice(descriptor.idVendor(), descriptor.idProduct());
}
开发者ID:quirinobrizi,项目名称:jax10,代码行数:5,代码来源:AbstractX10Listener.java
注:本文中的javax.usb.UsbDeviceDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论