本文整理汇总了Java中javax.usb.UsbControlIrp类的典型用法代码示例。如果您正苦于以下问题:Java UsbControlIrp类的具体用法?Java UsbControlIrp怎么用?Java UsbControlIrp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UsbControlIrp类属于javax.usb包,在下文中一共展示了UsbControlIrp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:fredg02,项目名称:se.bitcraze.crazyflie.lib,代码行数:25,代码来源:UsbLinkJava.java
示例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();
}
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:34,代码来源:AbstractIrpQueue.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax-examples,代码行数:21,代码来源:MissileLauncher.java
示例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);
}
开发者ID:IAmContent,项目名称:public,代码行数:9,代码来源:UsbPololuMiniMaestroServoCard.java
示例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);
}
开发者ID:IAmContent,项目名称:public,代码行数:9,代码来源:UsbPololuMicroMaestroServoCard.java
示例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);
}
开发者ID:IAmContent,项目名称:public,代码行数:8,代码来源:Owi535UsbMotorController.java
示例7: syncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public void syncSubmit(UsbControlIrp irp) {
try {
device.syncSubmit(irp);
} catch (Exception e) {
throw new UsbRuntimeException(e);
}
}
开发者ID:IAmContent,项目名称:public,代码行数:9,代码来源:EasedUsbDevice.java
示例8: asyncSubmit
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public void asyncSubmit(UsbControlIrp irp) {
try {
device.asyncSubmit(irp);
} catch (Exception e) {
throw new UsbRuntimeException(e);
}
}
开发者ID:IAmContent,项目名称:public,代码行数:9,代码来源:EasedUsbDevice.java
示例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();
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:11,代码来源:AbstractDevice.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:9,代码来源:AbstractDevice.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:8,代码来源:AbstractDevice.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:9,代码来源:RootHub.java
示例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);
}
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:40,代码来源:IrpQueue.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:17,代码来源:DeviceListenerListTest.java
示例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);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:17,代码来源:DeviceListenerListTest.java
示例16: testDetachedEvent
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Tests the detached event.
*/
@Test
public void testDetachedEvent()
{
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.usbDeviceDetached(event);
verify(a).usbDeviceDetached(event);
verify(b).usbDeviceDetached(event);
}
开发者ID:usb4java,项目名称:usb4java-javax,代码行数:17,代码来源:DeviceListenerListTest.java
示例17: inRequest
import javax.usb.UsbControlIrp; //导入依赖的package包/类
protected UsbControlIrp inRequest(byte request, int dataSize) {
final byte requestType = REQUESTTYPE_TYPE_VENDOR | REQUESTTYPE_DIRECTION_IN;
final UsbControlIrp result = device.createUsbControlIrp(requestType, request, (short)0, (short)0);
result.setData(new byte[dataSize]);
return result;
}
开发者ID:IAmContent,项目名称:public,代码行数:7,代码来源:AbstractUsbPololuMaestroServoCard.java
示例18: outRequest
import javax.usb.UsbControlIrp; //导入依赖的package包/类
protected UsbControlIrp outRequest(byte request, short index, short value) {
final byte requestType = REQUESTTYPE_TYPE_VENDOR | REQUESTTYPE_DIRECTION_OUT;
return device.createUsbControlIrp(requestType, request, value, index);
}
开发者ID:IAmContent,项目名称:public,代码行数:5,代码来源:AbstractUsbPololuMaestroServoCard.java
示例19: sendStateToDevice
import javax.usb.UsbControlIrp; //导入依赖的package包/类
/**
* Sends a control message to the device. The message that is sent is the
* message that is required to synchronize the device's state with the state
* of this instance.
*/
protected void sendStateToDevice() {
final UsbControlIrp controlRequest = controlRequest();
controlRequest.setData(currentState());
device.syncSubmit(controlRequest);
}
开发者ID:IAmContent,项目名称:public,代码行数:11,代码来源:Owi535UsbMotorController.java
示例20: createUsbControlIrp
import javax.usb.UsbControlIrp; //导入依赖的package包/类
@Override
public UsbControlIrp createUsbControlIrp(byte bmRequestType, byte bRequest, short wValue, short wIndex) {
return device.createUsbControlIrp(bmRequestType, bRequest, wValue, wIndex);
}
开发者ID:IAmContent,项目名称:public,代码行数:5,代码来源:EasedUsbDevice.java
注:本文中的javax.usb.UsbControlIrp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论