本文整理汇总了Java中javax.usb.UsbControlIrp类的典型用法代码示例。如果您正苦于以下问题:Java UsbControlIrp类的具体用法?Java UsbControlIrp怎么用?Java UsbControlIrp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsbControlIrp类属于javax.usb包,在下文中一共展示了UsbControlIrp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendUsbControlIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Send the UsbControlIrp to the UsbDevice on the DCP.
*
* @param usbDevice
* The UsbDevice.
* @param usbControlIrp
* The UsbControlIrp.
* @return If the submission was successful.
*/
public static boolean sendUsbControlIrp(UsbDevice usbDevice, UsbControlIrp usbControlIrp) {
try {
/*
* This will block until the submission is complete.
* Note that submissions (except interrupt and bulk in-direction)
* will not block indefinitely, they will complete or fail within a finite
* amount of time. See MouseDriver.HidMouseRunnable for more details.
*/
usbDevice.syncSubmit(usbControlIrp);
return true;
} catch (UsbException uE) {
mLogger.error("DCP submission failed : " + uE.getMessage());
return false;
}
}
示例2: processControlIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Processes the control IRP.
*
* @param irp
* The IRP to process.
* @throws UsbException
* When processing the IRP fails.
*/
protected final void processControlIrp(final UsbControlIrp irp)
throws UsbException
{
final ByteBuffer buffer =
ByteBuffer.allocateDirect(irp.getLength());
buffer.put(irp.getData(), irp.getOffset(), irp.getLength());
buffer.rewind();
final DeviceHandle handle = getDevice().open();
final int result = LibUsb.controlTransfer(handle, irp.bmRequestType(),
irp.bRequest(), irp.wValue(), irp.wIndex(), buffer,
getConfig().getTimeout());
if (result < 0)
{
throw ExceptionUtils.createPlatformException(
"Unable to submit control message", result);
}
buffer.rewind();
buffer.get(irp.getData(), irp.getOffset(), result);
irp.setActualLength(result);
if (irp.getActualLength() != irp.getLength()
&& !irp.getAcceptShortPacket())
{
throw new UsbShortPacketException();
}
}
示例3: sendMessage
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Sends a message to the missile launcher.
*
* @param device
* The USB device handle.
* @param message
* The message to send.
* @throws UsbException
* When sending the message failed.
*/
public static void sendMessage(UsbDevice device, byte[] message)
throws UsbException
{
UsbControlIrp irp = device.createUsbControlIrp(
(byte) (UsbConst.REQUESTTYPE_TYPE_CLASS |
UsbConst.REQUESTTYPE_RECIPIENT_INTERFACE), (byte) 0x09,
(short) 2, (short) 1);
irp.setData(message);
device.syncSubmit(irp);
}
示例4: getRawPosition
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public short getRawPosition(short channel) {
final int offset = 0;
final int dataSize = offset + sizeOfAllServoStatusBlocks();
final UsbControlIrp request = inRequest(REQUEST_GET_SERVO_SETTINGS, dataSize);
device.syncSubmit(request);
return extractPositionFromStatusBlocks(request.getData(), offset, channel);
}
示例5: getRawPosition
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public short getRawPosition(short channel) {
final int offset = 98;
final int dataSize = offset + sizeOfAllServoStatusBlocks();
final UsbControlIrp request = inRequest(REQUEST_GET_VARIABLES, dataSize);
device.syncSubmit(request);
return extractPositionFromStatusBlocks(request.getData(), offset, channel);
}
示例6: controlRequest
import javax.usb.UsbControlIrp; //导入依赖的package包/类
protected UsbControlIrp controlRequest() {
final byte requestType = UsbConst.REQUESTTYPE_TYPE_VENDOR;
final byte request = UsbConst.REQUEST_GET_DESCRIPTOR;
final short value = 0x100;
final short index = 0;
return device.createUsbControlIrp(requestType, request, value, index);
}
示例7: syncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public void syncSubmit(UsbControlIrp irp) {
try {
device.syncSubmit(irp);
} catch (Exception e) {
throw new UsbRuntimeException(e);
}
}
示例8: asyncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public void asyncSubmit(UsbControlIrp irp) {
try {
device.asyncSubmit(irp);
} catch (Exception e) {
throw new UsbRuntimeException(e);
}
}
示例9: syncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public final void syncSubmit(final UsbControlIrp irp) throws UsbException
{
if (irp == null)
throw new IllegalArgumentException("irp must not be null");
checkConnected();
this.queue.add(irp);
irp.waitUntilComplete();
if (irp.isUsbException()) throw irp.getUsbException();
}
示例10: asyncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public final void asyncSubmit(final UsbControlIrp irp)
{
if (irp == null)
throw new IllegalArgumentException("irp must not be null");
checkConnected();
this.queue.add(irp);
}
示例11: createUsbControlIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public final UsbControlIrp createUsbControlIrp(final byte bmRequestType,
final byte bRequest, final short wValue, final short wIndex)
{
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue,
wIndex);
}
示例12: createUsbControlIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public UsbControlIrp createUsbControlIrp(final byte bmRequestType,
final byte bRequest,
final short wValue, final short wIndex)
{
return new DefaultUsbControlIrp(bmRequestType, bRequest, wValue,
wIndex);
}
示例13: processIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
protected void processIrp(final UsbIrp irp) throws UsbException
{
final UsbEndpoint endpoint = this.pipe.getUsbEndpoint();
final byte direction = endpoint.getDirection();
final byte type = endpoint.getType();
if (type == UsbConst.ENDPOINT_TYPE_CONTROL)
{
processControlIrp((UsbControlIrp) irp);
return;
}
switch (direction)
{
case UsbConst.ENDPOINT_DIRECTION_OUT:
irp.setActualLength(write(irp.getData(), irp.getOffset(),
irp.getLength()));
if (irp.getActualLength() < irp.getLength()
&& !irp.getAcceptShortPacket())
{
throw new UsbShortPacketException();
}
break;
case UsbConst.ENDPOINT_DIRECTION_IN:
irp.setActualLength(read(irp.getData(), irp.getOffset(),
irp.getLength()));
if (irp.getActualLength() < irp.getLength()
&& !irp.getAcceptShortPacket())
{
throw new UsbShortPacketException();
}
break;
default:
throw new UsbException("Invalid direction: "
+ direction);
}
}
示例14: testDataEvent
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Tests the data event.
*/
@Test
public void testDataEvent()
{
final UsbDeviceDataEvent event = new UsbDeviceDataEvent(
mock(UsbDevice.class), mock(UsbControlIrp.class));
final UsbDeviceListener a = mock(UsbDeviceListener.class);
final UsbDeviceListener b = mock(UsbDeviceListener.class);
this.list.add(a);
this.list.add(b);
this.list.dataEventOccurred(event);
verify(a).dataEventOccurred(event);
verify(b).dataEventOccurred(event);
}
示例15: testErrorEvent
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Tests the error event.
*/
@Test
public void testErrorEvent()
{
final UsbDeviceErrorEvent event = new UsbDeviceErrorEvent(
mock(UsbDevice.class), mock(UsbControlIrp.class));
final UsbDeviceListener a = mock(UsbDeviceListener.class);
final UsbDeviceListener b = mock(UsbDeviceListener.class);
this.list.add(a);
this.list.add(b);
this.list.errorEventOccurred(event);
verify(a).errorEventOccurred(event);
verify(b).errorEventOccurred(event);
}