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


Java LibUsb.getBusNumber方法代码示例

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


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

示例1: getUSBAddress

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * USB address (bus/port)
 */
public String getUSBAddress()
{
    if(mDevice != null)
    {
        StringBuilder sb = new StringBuilder();

        sb.append("Bus:");
        int bus = LibUsb.getBusNumber(mDevice);
        sb.append(bus);

        sb.append(" Port:");
        int port = LibUsb.getPortNumber(mDevice);
        sb.append(port);

        return sb.toString();
    }

    return "UNKNOWN";
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:23,代码来源:FCDTunerController.java

示例2: createId

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Creates a device ID from the specified device.
 * 
 * @param device
 *            The libusb device. Must not be null.
 * @return The device id.
 * @throws UsbPlatformException
 *             When device descriptor could not be read from the specified
 *             device.
 */
private DeviceId createId(final Device device) throws UsbPlatformException
{
    if (device == null)
        throw new IllegalArgumentException("device must be set");
    final int busNumber = LibUsb.getBusNumber(device);
    final int addressNumber = LibUsb.getDeviceAddress(device);
    final int portNumber = LibUsb.getPortNumber(device);
    final DeviceDescriptor deviceDescriptor = new DeviceDescriptor();
    final int result = LibUsb.getDeviceDescriptor(device, deviceDescriptor);
    if (result < 0)
    {
        throw ExceptionUtils.createPlatformException(
            "Unable to get device descriptor for device " + addressNumber
                + " at bus " + busNumber, result);
    }
    return new DeviceId(busNumber, addressNumber, portNumber,
        new SimpleUsbDeviceDescriptor(deviceDescriptor));
}
 
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:29,代码来源:DeviceManager.java

示例3: UsbDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
public UsbDevice(final Device device) {
	dev = LibUsb.refDevice(device);

	devDesc = new DeviceDescriptor();
	LibUsb.getDeviceDescriptor(dev, devDesc);

	devVID = devDesc.idVendor();
	devPID = devDesc.idProduct();
	devDID = devDesc.bcdDevice();

	busAddr = LibUsb.getBusNumber(dev);
	devAddr = LibUsb.getDeviceAddress(dev);
}
 
开发者ID:inilabs,项目名称:flashy,代码行数:14,代码来源:UsbDevice.java

示例4: main

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Main method.
 * 
 * @param args
 *            Command-line arguments (Ignored)
 */
public static void main(String[] args)
{
    // Create the libusb context
    Context context = new Context();

    // Initialize the libusb context
    int result = LibUsb.init(context);
    if (result < 0)
    {
        throw new LibUsbException("Unable to initialize libusb", result);
    }

    // Read the USB device list
    DeviceList list = new DeviceList();
    result = LibUsb.getDeviceList(context, list);
    if (result < 0)
    {
        throw new LibUsbException("Unable to get device list", result);
    }

    try
    {
        // Iterate over all devices and list them
        for (Device device: list)
        {
            int address = LibUsb.getDeviceAddress(device);
            int busNumber = LibUsb.getBusNumber(device);
            DeviceDescriptor descriptor = new DeviceDescriptor();
            result = LibUsb.getDeviceDescriptor(device, descriptor);
            if (result < 0)
            {
                throw new LibUsbException(
                    "Unable to read device descriptor", result);
            }
            System.out.format(
                "Bus %03d, Device %03d: Vendor %04x, Product %04x%n",
                busNumber, address, descriptor.idVendor(),
                descriptor.idProduct());
        }
    }
    finally
    {
        // Ensure the allocated device list is freed
        LibUsb.freeDeviceList(list, true);
    }

    // Deinitialize the libusb context
    LibUsb.exit(context);
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:56,代码来源:ListDevices.java

示例5: dumpDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Dumps the specified device to stdout.
 * 
 * @param device
 *            The device to dump.
 */
public static void dumpDevice(final Device device)
{
    // Dump device address and bus number
    final int address = LibUsb.getDeviceAddress(device);
    final int busNumber = LibUsb.getBusNumber(device);
    System.out.println(String
        .format("Device %03d/%03d", busNumber, address));

    // Dump port number if available
    final int portNumber = LibUsb.getPortNumber(device);
    if (portNumber != 0)
        System.out.println("Connected to port: " + portNumber);

    // Dump parent device if available
    final Device parent = LibUsb.getParent(device);
    if (parent != null)
    {
        final int parentAddress = LibUsb.getDeviceAddress(parent);
        final int parentBusNumber = LibUsb.getBusNumber(parent);
        System.out.println(String.format("Parent: %03d/%03d",
            parentBusNumber, parentAddress));
    }

    // Dump the device speed
    System.out.println("Speed: "
        + DescriptorUtils.getSpeedName(LibUsb.getDeviceSpeed(device)));

    // Read the device descriptor
    final DeviceDescriptor descriptor = new DeviceDescriptor();
    int result = LibUsb.getDeviceDescriptor(device, descriptor);
    if (result < 0)
    {
        throw new LibUsbException("Unable to read device descriptor",
            result);
    }

    // Try to open the device. This may fail because user has no
    // permission to communicate with the device. This is not
    // important for the dumps, we are just not able to resolve string
    // descriptor numbers to strings in the descriptor dumps.
    DeviceHandle handle = new DeviceHandle();
    result = LibUsb.open(device, handle);
    if (result < 0)
    {
        System.out.println(String.format("Unable to open device: %s. "
            + "Continuing without device handle.",
            LibUsb.strError(result)));
        handle = null;
    }

    // Dump the device descriptor
    System.out.print(descriptor.dump(handle));

    // Dump all configuration descriptors
    dumpConfigurationDescriptors(device, descriptor.bNumConfigurations());

    // Close the device if it was opened
    if (handle != null)
    {
        LibUsb.close(handle);
    }
}
 
开发者ID:usb4java,项目名称:usb4java-examples,代码行数:69,代码来源:DumpDevices.java


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