本文整理汇总了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();
}
}
}
}
示例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);
}
}
示例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;
}
示例4: usbServices
import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public static UsbServices usbServices() {
try {
return UsbHostManager.getUsbServices();
} catch (Exception e) {
throw new UsbRuntimeException(e);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例11: getUsbServices
import javax.usb.UsbHostManager; //导入方法依赖的package包/类
public UsbServices getUsbServices() throws UsbException {
return UsbHostManager.getUsbServices();
}
示例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());
}
示例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);
}