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


Java LibUsb.errorName方法代码示例

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


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

示例1: sendVendorRequest

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request with data (including special bits). This is a
 * blocking method.
 *
 * @param requestType
 *            the vendor requestType byte (used for special cases, usually
 *            0)
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataBuffer
 *            the data which is to be transmitted to the device (null means
 *            no data)
 */
synchronized public void sendVendorRequest(final byte request, final short value, final short index,
	ByteBuffer dataBuffer) throws HardwareInterfaceException {
	if (!isOpen()) {
		open();
	}

	if (dataBuffer == null) {
		dataBuffer = BufferUtils.allocateByteBuffer(0);
	}

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_OUT | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(deviceHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to send vendor OUT request " + String.format("0x%x", request)
			+ ": " + LibUsb.errorName(status));
	}

	if (status != dataBuffer.capacity()) {
		throw new HardwareInterfaceException("Wrong number of bytes transferred, wanted: " + dataBuffer.capacity()
			+ ", got: " + status);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:41,代码来源:CypressFX2.java

示例2: acquireDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * acquire a device for exclusive use, other processes can't open the device
 * anymore used for example for continuous sequencing in matlab
 */
public void acquireDevice() throws HardwareInterfaceException {
    SiLabsC8051F320_LibUsb.log.log(Level.INFO, "{0} acquiring device for exclusive access", this);

    final int status = LibUsb.claimInterface(retinahandle, 0);
    if (status != LibUsb.SUCCESS) {
        if (status == LibUsb.ERROR_BUSY) {
            try {
                sleep(3000);
            } catch (InterruptedException ex) {

            }
        }
        throw new HardwareInterfaceException("Unable to acquire device for exclusive use: "
                + LibUsb.errorName(status));
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:21,代码来源:SiLabsC8051F320_LibUsb.java

示例3: sendVendorRequest

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request with data (including special bits). This is a
 * blocking method.
 *
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataBuffer
 *            the data which is to be transmitted to the device (null means
 *            no data)
 *
 * @throws Exception
 *             on any exception
 */
public synchronized void sendVendorRequest(final byte request, final short value, final short index,
	final ByteBuffer buf) throws IOException {
	if (devHandle == null) {
		throw new IllegalStateException("Device is not open, cannot send vendor request.");
	}

	ByteBuffer dataBuffer = buf;
	if (dataBuffer == null) {
		dataBuffer = BufferUtils.allocateByteBuffer(0);
	}

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_OUT | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(devHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new IOException("Unable to send vendor OUT request " + String.format("0x%x", request) + ": "
			+ LibUsb.errorName(status));
	}

	if (status != dataBuffer.capacity()) {
		throw new IOException(
			"Wrong number of bytes transferred, wanted: " + dataBuffer.capacity() + ", got: " + status);
	}
}
 
开发者ID:inilabs,项目名称:flashy,代码行数:42,代码来源:UsbDevice.java

示例4: init

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Initializes the controller by opening the USB device and claiming the
 * HID interface.
 *
 * Invoke this method after constructing this class to setup the
 * controller.
 *
 * @throws SourceException if cannot open and claim the USB device
 */
public void init() throws SourceException
{
    mDeviceHandle = new DeviceHandle();

    int result = LibUsb.open(mDevice, mDeviceHandle);

    if(result != LibUsb.SUCCESS)
    {
        mDeviceHandle = null;

        throw new SourceException("libusb couldn't open funcube usb device [" + LibUsb.errorName(result) + "]");
    }

    claimInterface();
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:25,代码来源:FCDTunerController.java

示例5: acquireDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * acquire a device for exclusive use, other processes can't open the device
 * anymore
 * used for example for continuous sequencing in matlab
 */
public void acquireDevice() throws HardwareInterfaceException {
	CypressFX2.log.log(Level.INFO, "{0} acquiring device for exclusive access", this);

	final int status = LibUsb.claimInterface(deviceHandle, 0);
	if (status != LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to acquire device for exclusive use: "
			+ LibUsb.errorName(status));
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:15,代码来源:CypressFX2.java

示例6: releaseDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/** release the device from exclusive use */
public void releaseDevice() throws HardwareInterfaceException {
	CypressFX2.log.log(Level.INFO, "{0} releasing device", this);

	final int status = LibUsb.releaseInterface(deviceHandle, 0);
	if (status != LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to release device from exclusive use: "
			+ LibUsb.errorName(status));
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:11,代码来源:CypressFX2.java

示例7: sendVendorRequestIN

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request to receive (IN direction) data. This is a blocking
 * method.
 *
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataLength
 *            amount of data to receive, determines size of returned buffer
 *            (must be greater than 0)
 * @return a buffer containing the data requested from the device
 */
synchronized public ByteBuffer sendVendorRequestIN(final byte request, final short value, final short index,
	final int dataLength) throws HardwareInterfaceException {
	if (dataLength == 0) {
		throw new HardwareInterfaceException("Unable to send vendor IN request with dataLength of zero!");
	}

	if (!isOpen()) {
		open();
	}

	final ByteBuffer dataBuffer = BufferUtils.allocateByteBuffer(dataLength);

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_IN | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(deviceHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to send vendor IN request " + String.format("0x%x", request)
			+ ": " + LibUsb.errorName(status));
	}

	if (status != dataLength) {
		throw new HardwareInterfaceException("Wrong number of bytes transferred, wanted: " + dataLength + ", got: "
			+ status);
	}

	// Update ByteBuffer internal limit to show how much was successfully
	// read.
	// usb4java never touches the ByteBuffer's internals by design, so we do
	// it here.
	dataBuffer.limit(dataLength);

	return (dataBuffer);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:49,代码来源:CypressFX2.java

示例8: acquireDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * acquire a device for exclusive use, other processes can't open the device
 * anymore
 * used for example for continuous sequencing in matlab
 */
public void acquireDevice() throws HardwareInterfaceException {
	CypressFX3.log.log(Level.INFO, "{0} acquiring device for exclusive access", this);

	final int status = LibUsb.claimInterface(deviceHandle, 0);
	if (status != LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to acquire device for exclusive use: " + LibUsb.errorName(status));
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:14,代码来源:CypressFX3.java

示例9: releaseDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/** release the device from exclusive use */
public void releaseDevice() throws HardwareInterfaceException {
	CypressFX3.log.log(Level.INFO, "{0} releasing device", this);

	final int status = LibUsb.releaseInterface(deviceHandle, 0);
	if (status != LibUsb.SUCCESS) {
		throw new HardwareInterfaceException("Unable to release device from exclusive use: " + LibUsb.errorName(status));
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:10,代码来源:CypressFX3.java

示例10: sendVendorRequest

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request with data (including special bits). This is a
 * blocking method.
 *
 * @param requestType
 *            the vendor requestType byte (used for special cases, usually
 *            0)
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataBuffer
 *            the data which is to be transmitted to the device (null means
 *            no data)
 */
synchronized public void sendVendorRequest(final byte request, final short value, final short index, ByteBuffer dataBuffer)
	throws HardwareInterfaceException {
	if (!isOpen()) {
		open();
	}

	if (dataBuffer == null) {
		dataBuffer = BufferUtils.allocateByteBuffer(0);
	}

	// System.out.println(String.format("Sent VR %X, wValue %X, wIndex %X, wLength %d.\n", request, value, index,
	// dataBuffer.limit()));

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_OUT | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(deviceHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new HardwareInterfaceException(
			"Unable to send vendor OUT request " + String.format("0x%x", request) + ": " + LibUsb.errorName(status));
	}

	if (status != dataBuffer.capacity()) {
		throw new HardwareInterfaceException(
			"Wrong number of bytes transferred, wanted: " + dataBuffer.capacity() + ", got: " + status);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:44,代码来源:CypressFX3.java

示例11: sendVendorRequestIN

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request to receive (IN direction) data. This is a blocking
 * method.
 *
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataLength
 *            amount of data to receive, determines size of returned buffer
 *            (must be greater than 0)
 * @return a buffer containing the data requested from the device
 */
synchronized public ByteBuffer sendVendorRequestIN(final byte request, final short value, final short index, final int dataLength)
	throws HardwareInterfaceException {
	if (dataLength == 0) {
		throw new HardwareInterfaceException("Unable to send vendor IN request with dataLength of zero!");
	}

	if (!isOpen()) {
		open();
	}

	final ByteBuffer dataBuffer = BufferUtils.allocateByteBuffer(dataLength);

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_IN | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(deviceHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new HardwareInterfaceException(
			"Unable to send vendor IN request " + String.format("0x%x", request) + ": " + LibUsb.errorName(status));
	}

	if (status != dataLength) {
		throw new HardwareInterfaceException("Wrong number of bytes transferred, wanted: " + dataLength + ", got: " + status);
	}

	// Update ByteBuffer internal limit to show how much was successfully
	// read.
	// usb4java never touches the ByteBuffer's internals by design, so we do
	// it here.
	dataBuffer.limit(dataLength);

	return (dataBuffer);
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:48,代码来源:CypressFX3.java

示例12: releaseDevice

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * release the device from exclusive use
 */
public void releaseDevice() throws HardwareInterfaceException {
    SiLabsC8051F320_LibUsb.log.log(Level.INFO, "{0} releasing device", this);

    final int status = LibUsb.releaseInterface(retinahandle, 0);
    if (status != LibUsb.SUCCESS) {
        throw new HardwareInterfaceException("Unable to release device from exclusive use: "
                + LibUsb.errorName(status));
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:SiLabsC8051F320_LibUsb.java

示例13: sendVendorRequest

import org.usb4java.LibUsb; //导入方法依赖的package包/类
synchronized public void sendVendorRequest(final byte request, final Byte value,
        ByteBuffer dataBuffer, IntBuffer intBuffer) throws HardwareInterfaceException {
    if (!isOpen()) {
        open();
    }

    if (dataBuffer == null) {
        dataBuffer = BufferUtils.allocateByteBuffer(2);
        dataBuffer.put(request);
        dataBuffer.put(value);
    }
    if (intBuffer == null) {
        intBuffer = BufferUtils.allocateIntBuffer();
    }
    Byte endpoint = 0x02;

    final byte bmRequestType = (byte) (LibUsb.ENDPOINT_OUT | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);
    final int status = LibUsb.bulkTransfer(retinahandle, endpoint, dataBuffer, intBuffer, 0);
    //controlTransfer(retinahandle, bmRequestType, request, value, index, dataBuffer, 0);
    if (status < LibUsb.SUCCESS) {
        throw new HardwareInterfaceException("Unable to send vendor OUT request " + String.format("0x%x", request)
                + ": " + LibUsb.errorName(status));
    }

    //if (status != dataBuffer.capacity()) {
    //    throw new HardwareInterfaceException("Wrong number of bytes transferred, wanted: " + dataBuffer.capacity()
    //            + ", got: " + status);
    //}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:30,代码来源:SiLabsC8051F320_LibUsb.java

示例14: sendVendorRequestIN

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Sends a vendor request to receive (IN direction) data. This is a blocking
 * method.
 *
 * @param request
 *            the vendor request byte, identifies the request on the device
 * @param value
 *            the value of the request (bValue USB field)
 * @param index
 *            the "index" of the request (bIndex USB field)
 * @param dataLength
 *            amount of data to receive, determines size of returned buffer
 *            (must be greater than 0)
 *
 * @return a buffer containing the data requested from the device
 *
 * @throws Exception
 *             on any exception
 */
public synchronized ByteBuffer sendVendorRequestIN(final byte request, final short value, final short index,
	final int dataLength) throws IOException {
	if (devHandle == null) {
		throw new IllegalStateException("Device is not open, cannot send vendor request.");
	}

	if (dataLength == 0) {
		throw new IllegalArgumentException("Unable to send vendor IN request with dataLength of zero!");
	}

	final ByteBuffer dataBuffer = BufferUtils.allocateByteBuffer(dataLength);

	final byte bmRequestType = (byte) (LibUsb.ENDPOINT_IN | LibUsb.REQUEST_TYPE_VENDOR | LibUsb.RECIPIENT_DEVICE);

	final int status = LibUsb.controlTransfer(devHandle, bmRequestType, request, value, index, dataBuffer, 0);
	if (status < LibUsb.SUCCESS) {
		throw new IOException(
			"Unable to send vendor IN request " + String.format("0x%x", request) + ": " + LibUsb.errorName(status));
	}

	if (status != dataLength) {
		throw new IOException("Wrong number of bytes transferred, wanted: " + dataLength + ", got: " + status);
	}

	// Update ByteBuffer internal limit to show how much was successfully
	// read. usb4java never touches the ByteBuffer's internals by design,
	// so we do it here.
	dataBuffer.limit(dataLength);

	return (dataBuffer);
}
 
开发者ID:inilabs,项目名称:flashy,代码行数:51,代码来源:UsbDevice.java

示例15: claimInterface

import org.usb4java.LibUsb; //导入方法依赖的package包/类
/**
 * Claims the USB interface.  Attempts to detach the active kernel driver
 * if one is currently attached.
 */
public static void claimInterface(DeviceHandle handle) throws SourceException
{
    if(handle != null)
    {
        int result = LibUsb.kernelDriverActive(handle, USB_INTERFACE);

        if(result == 1)
        {
            result = LibUsb.detachKernelDriver(handle, USB_INTERFACE);

            if(result != LibUsb.SUCCESS)
            {
                mLog.error("failed attempt to detach kernel driver [" +
                    LibUsb.errorName(result) + "]");

                throw new SourceException("couldn't detach kernel driver "
                    + "from device");
            }
        }

        result = LibUsb.claimInterface(handle, USB_INTERFACE);

        if(result != LibUsb.SUCCESS)
        {
            throw new SourceException("couldn't claim usb interface [" +
                LibUsb.errorName(result) + "]");
        }
    }
    else
    {
        throw new SourceException("couldn't claim usb interface - no "
            + "device handle");
    }
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:39,代码来源:RTL2832TunerController.java


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