• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java UsbInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.usb.UsbInterface的典型用法代码示例。如果您正苦于以下问题:Java UsbInterface类的具体用法?Java UsbInterface怎么用?Java UsbInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: LedStripe

import javax.usb.UsbInterface; //导入依赖的package包/类
private LedStripe() throws UsbException {

		device = find(UsbHostManager.getUsbServices().getRootUsbHub(), VENDOR_ID, PRODUCT_ID);
		if (device == null) {
			throw new UsbException("Device not found.");
		}

		// Claim the interface
		UsbConfiguration configuration = device.getUsbConfiguration((byte) 1);
		UsbInterface iface = configuration.getUsbInterface((byte) 0);
		iface.claim(new UsbInterfacePolicy() {
			public boolean forceClaim(UsbInterface usbInterface) {
				return true;
			}
		});

		
	}
 
开发者ID:loreii,项目名称:jLedStripe,代码行数:19,代码来源:LedStripe.java


示例2: initialize

import javax.usb.UsbInterface; //导入依赖的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


示例3: getDeviceDetails

import javax.usb.UsbInterface; //导入依赖的package包/类
public static String getDeviceDetails( UsbDevice device ) 
	throws UsbException, UnsupportedEncodingException, UsbDisconnectedException
{
	StringBuilder sb = new StringBuilder();

	sb.append( device.getUsbDeviceDescriptor().toString() + "\n\n" );
	
	for( Object configObject: device.getUsbConfigurations() )
	{
		UsbConfiguration config = (UsbConfiguration)configObject;
		
		sb.append( config.getUsbConfigurationDescriptor().toString() + "\n\n" );
		
		for( Object interfaceObject: config.getUsbInterfaces() )
		{
			UsbInterface iface = (UsbInterface)interfaceObject;
			
			sb.append( iface.getUsbInterfaceDescriptor().toString() + "\n\n" );
			
			for( Object endpointObject: iface.getUsbEndpoints() )
			{
				UsbEndpoint endpoint = (UsbEndpoint)endpointObject;
				
				sb.append( endpoint.getUsbEndpointDescriptor().toString() + "\n\n" );
			}
		}
	}

	return sb.toString();
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:31,代码来源:USBUtils.java


示例4: isActive

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public boolean isActive()
{
    final UsbInterface iface = this.endpoint.getUsbInterface();
    final UsbConfiguration config = iface.getUsbConfiguration();
    return iface.isActive() && config.isActive();
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:8,代码来源:Pipe.java


示例5: testGetUsbInterfaces

import javax.usb.UsbInterface; //导入依赖的package包/类
/**
 * Tests the {@link RootHubConfiguration#getUsbInterfaces()} method.
 */
@Test
public void testGetUsbInterfaces()
{
    final List<UsbInterface> ifaces = this.config.getUsbInterfaces();
    assertEquals(1, ifaces.size());
    assertNotNull(ifaces.get(0));
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:11,代码来源:RootHubConfigurationTest.java


示例6: testGetSettings

import javax.usb.UsbInterface; //导入依赖的package包/类
/**
 * Tests the {@link RootHubInterface#getSettings()} method.
 */
@Test
public void testGetSettings()
{
    final List<UsbInterface> settings = this.iface.getSettings();
    assertEquals(0, settings.size());
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:10,代码来源:RootHubInterfaceTest.java


示例7: isAdbInterface

import javax.usb.UsbInterface; //导入依赖的package包/类
/**
 * Checks if the specified USB interface is an ADB interface.
 * 
 * @param iface
 *            The interface to check.
 * @return True if interface is an ADB interface, false if not.
 */
private static boolean isAdbInterface(UsbInterface iface)
{
    UsbInterfaceDescriptor desc = iface.getUsbInterfaceDescriptor();
    return desc.bInterfaceClass() == ADB_CLASS &&
        desc.bInterfaceSubClass() == ADB_SUBCLASS &&
        desc.bInterfaceProtocol() == ADB_PROTOCOL;
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:15,代码来源:Adb.java


示例8: getUsbInterfaces

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public List<UsbInterface> getUsbInterfaces()
{
    return this.interfaces;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHubConfiguration.java


示例9: getUsbInterface

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public UsbInterface getUsbInterface(final byte number)
{
    if (number != 0) return null;
    return this.interfaces.get(0);
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:7,代码来源:RootHubConfiguration.java


示例10: getActiveSetting

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public UsbInterface getActiveSetting()
{
    return this;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHubInterface.java


示例11: getSetting

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public UsbInterface getSetting(final byte number)
{
    return this;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHubInterface.java


示例12: getSettings

import javax.usb.UsbInterface; //导入依赖的package包/类
@Override
public List<UsbInterface> getSettings()
{
    return this.settings;
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:6,代码来源:RootHubInterface.java


示例13: checkDevice

import javax.usb.UsbInterface; //导入依赖的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);
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:65,代码来源:Adb.java


示例14: dumpDevice

import javax.usb.UsbInterface; //导入依赖的package包/类
/**
 * Dumps the specified USB device to stdout.
 * 
 * @param device
 *            The USB device to dump.
 */
private static void dumpDevice(final UsbDevice device)
{
    // Dump information about the device itself
    System.out.println(device);
    final UsbPort port = device.getParentUsbPort();
    if (port != null)
    {
        System.out.println("Connected to port: " + port.getPortNumber());
        System.out.println("Parent: " + port.getUsbHub());
    }

    // Dump device descriptor
    System.out.println(device.getUsbDeviceDescriptor());

    // Process all configurations
    for (UsbConfiguration configuration: (List<UsbConfiguration>) device
        .getUsbConfigurations())
    {
        // Dump configuration descriptor
        System.out.println(configuration.getUsbConfigurationDescriptor());

        // Process all interfaces
        for (UsbInterface iface: (List<UsbInterface>) configuration
            .getUsbInterfaces())
        {
            // Dump the interface descriptor
            System.out.println(iface.getUsbInterfaceDescriptor());

            // Process all endpoints
            for (UsbEndpoint endpoint: (List<UsbEndpoint>) iface
                .getUsbEndpoints())
            {
                // Dump the endpoint descriptor
                System.out.println(endpoint.getUsbEndpointDescriptor());
            }
        }
    }

    System.out.println();

    // Dump child devices if device is a hub
    if (device.isUsbHub())
    {
        final UsbHub hub = (UsbHub) device;
        for (UsbDevice child: (List<UsbDevice>) hub.getAttachedUsbDevices())
        {
            dumpDevice(child);
        }
    }
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:57,代码来源:DumpDevices.java


示例15: AdbDevice

import javax.usb.UsbInterface; //导入依赖的package包/类
/**
 * Constructs a new ADB interface.
 * 
 * @param iface
 *            The USB interface. Must not be null.
 * @param inEndpoint
 *            The in endpoint address.
 * @param outEndpoint
 *            THe out endpoint address.
 */
public AdbDevice(UsbInterface iface, byte inEndpoint,
    byte outEndpoint)
{
    if (iface == null)
        throw new IllegalArgumentException("iface must be set");
    this.iface = iface;
    this.inEndpoint = inEndpoint;
    this.outEndpoint = outEndpoint;
}
 
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:20,代码来源:AdbDevice.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Activation类代码示例发布时间:2022-05-22
下一篇:
Java TaskRepository类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap