当前位置: 首页>>代码示例>>Java>>正文


Java UsbHostManager.getUsbServices方法代码示例

本文整理汇总了Java中javax.usb.UsbHostManager.getUsbServices方法的典型用法代码示例。如果您正苦于以下问题:Java UsbHostManager.getUsbServices方法的具体用法?Java UsbHostManager.getUsbServices怎么用?Java UsbHostManager.getUsbServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.usb.UsbHostManager的用法示例。


在下文中一共展示了UsbHostManager.getUsbServices方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
protected void initialize() throws SecurityException, UsbException {
	UsbServices services = UsbHostManager.getUsbServices();
	UsbHub usbHub = services.getRootUsbHub();

	UsbDevice theDevice = findDevice(usbHub, targetVendor, targetProduct);

	if (theDevice == null) {
		logger.warn("Could not find the device. The driver is not operable.");
		return;
	}
	
	for (Object i : theDevice.getActiveUsbConfiguration().getUsbInterfaces()) {
		UsbInterface intf = (UsbInterface) i;
		for (Object e : intf.getUsbEndpoints()) {
			UsbEndpoint endp = (UsbEndpoint) e;
			if (endp.getDirection() == UsbConst.ENDPOINT_DIRECTION_IN) {
				this.pipe = endp.getUsbPipe();
			}
		}
	}
}
 
开发者ID:yadarts,项目名称:yadarts,代码行数:22,代码来源:SimplifiedEmprexUSBDriver.java

示例2: findScale

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public static Scale findScale() {
  try {
    UsbServices services = UsbHostManager.getUsbServices();
    UsbHub rootHub = services.getRootUsbHub();
    // Dymo M10 Scale:
    UsbDevice device = findDevice(rootHub, (short) 0x0922, (short) 0x8003);
    // Dymo M25 Scale:
    if (device == null) {
      device = findDevice(rootHub, (short) 0x0922, (short) 0x8004);
    }
    if (device == null) {
      return null;
    }
    return new UsbScale(device);
  } catch (UsbException ex) {
    throw new IllegalStateException("Unable to find devices", ex);
  }
}
 
开发者ID:RaspberryPiWithJava,项目名称:JavaScale,代码行数:19,代码来源:UsbScale.java

示例3: getDevices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Returns a List of currently connected usb devices
 */
public static List<UsbDevice> getDevices() 
		throws SecurityException, UsbException, UnsupportedEncodingException
{
	ArrayList<UsbDevice> devices = new ArrayList<UsbDevice>();
	
	UsbServices services = UsbHostManager.getUsbServices();

	UsbHub root = services.getRootUsbHub();
	
	devices.addAll( getHubDevices( root ) );

	return devices;
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:17,代码来源:USBUtils.java

示例4: usbServices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public static UsbServices usbServices() {
    try {
        return UsbHostManager.getUsbServices();
    } catch (Exception e) {
        throw new UsbRuntimeException(e);
    }
}
 
开发者ID:IAmContent,项目名称:public,代码行数:8,代码来源:Usb.java

示例5: findScale

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public static UsbScaleTest findScale() throws UsbException {
  UsbServices services = UsbHostManager.getUsbServices();
  UsbHub rootHub = services.getRootUsbHub();
  // Dymo M10 Scale:
  UsbDevice device = findDevice(rootHub, (short) 0x0922, (short) 0x8003);
  // Dymo M25 Scale:
  if (device == null) {
    device = findDevice(rootHub, (short) 0x0922, (short) 0x8004);
  }
  if (device == null) {
    return null;
  }
  return new UsbScaleTest(device);
}
 
开发者ID:RaspberryPiWithJava,项目名称:JavaScale,代码行数:15,代码来源:UsbScaleTest.java

示例6: UsbRobotArm

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Creates a new UsbRobotArm, if no device is attached an exception is
 * thrown. This is a singleton constructor.
 */
private UsbRobotArm()
{
    try
    {
        // Get a list of the attached USB devices.
        this.usbServices = UsbHostManager.getUsbServices();
        this.usbServices.addUsbServicesListener(this);

        UsbHub rootHub = this.usbServices.getRootUsbHub();
        //DeviceManager.dump(rootHub);

        // Look for the robot arm in that list.
        this.usbDevice = DeviceManager.findDevice(rootHub,
                VENDOR_ID,
                PRODUCT_ID);

        // If we haven't found it then throw an exception.
        if (this.usbDevice == null)
        {
            throw new UsbException("Robot Arm Edge not found.");
        }
        else
        {
            init();
        }
    }
    catch (UsbException | SecurityException ex)
    {
        Logger.getLogger(UsbRobotArm.class.getName()).log(Level.SEVERE,
                null, ex);
    }
}
 
开发者ID:swordmaster2k,项目名称:robotarmedge,代码行数:37,代码来源:UsbRobotArm.java

示例7: findDevices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Returns the list of all available ADB devices.
 * 
 * @return The list of available ADB devices.
 * @throws UsbException
 *             When USB communication failed.
 */
public static List<AdbDevice> findDevices() throws UsbException
{
    UsbServices services = UsbHostManager.getUsbServices();
    List<AdbDevice> usbDevices = new ArrayList<AdbDevice>();
    findDevices(services.getRootUsbHub(), usbDevices);
    return usbDevices;
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:15,代码来源:Adb.java

示例8: main

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Main method.
 * 
 * @param args
 *            Command-line arguments (Ignored)
 * @throws UsbException
 *             When an USB error was reported which wasn't handled by this
 *             program itself.
 */
public static void main(final String[] args) throws UsbException
{
    // Get the USB services and dump information about them
    final UsbServices services = UsbHostManager.getUsbServices();
    System.out.println("USB Service Implementation: "
        + services.getImpDescription());
    System.out.println("Implementation version: "
        + services.getImpVersion());
    System.out.println("Service API version: " + services.getApiVersion());
    System.out.println();

    // Dump the root USB hub
    dumpDevice(services.getRootUsbHub());
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:24,代码来源:DumpDevices.java

示例9: provideUsbServices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
@Provides
UsbServices provideUsbServices() {
  UsbServices usbServices = null;
  try {
    usbServices = UsbHostManager.getUsbServices();
  } catch (UsbException e) {
    throw Throwables.propagate(e);
  }
  return usbServices;
}
 
开发者ID:alexandre-normand,项目名称:blood-shepherd,代码行数:11,代码来源:DexcomModule.java

示例10: provideUsbServices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
@Provides
UsbServices provideUsbServices() {
  UsbServices usbServices = null;
  try {
    usbServices = UsbHostManager.getUsbServices();
  } catch (UsbException e) {
    Throwables.propagate(e);
  }
  return usbServices;
}
 
开发者ID:alexandre-normand,项目名称:blood-shepherd,代码行数:11,代码来源:DexcomModule.java

示例11: getUsbServices

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public UsbServices getUsbServices() throws UsbException {
	return UsbHostManager.getUsbServices();
}
 
开发者ID:quirinobrizi,项目名称:jax10,代码行数:4,代码来源:UsbServicesProvider.java

示例12: main

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Main method.
 * 
 * @param args
 *            Command-line arguments (Ignored)
 * @throws UsbException
 *             When an USB error was reported which wasn't handled by this
 *             program itself.
 */
public static void main(final String[] args) throws UsbException
{
    // Get the USB services and dump information about them
    final UsbServices services = UsbHostManager.getUsbServices();

    // Dump the root USB hub
    processDevice(services.getRootUsbHub());
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:18,代码来源:DumpNames.java

示例13: main

import javax.usb.UsbHostManager; //导入方法依赖的package包/类
/**
 * Main method.
 * 
 * @param args
 *            Command-line arguments (Ignored).
 * @throws UsbException
 *             When USB communication fails.
 */
public static void main(String[] args) throws UsbException
{
    UsbServices services = UsbHostManager.getUsbServices();
    dump(services.getRootUsbHub(), 0);
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:14,代码来源:DumpDeviceTree.java


注:本文中的javax.usb.UsbHostManager.getUsbServices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。