本文整理汇总了Java中org.usb4java.LibUsb.TRANSFER_COMPLETED属性的典型用法代码示例。如果您正苦于以下问题:Java LibUsb.TRANSFER_COMPLETED属性的具体用法?Java LibUsb.TRANSFER_COMPLETED怎么用?Java LibUsb.TRANSFER_COMPLETED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.usb4java.LibUsb
的用法示例。
在下文中一共展示了LibUsb.TRANSFER_COMPLETED属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processTransfer
@Override
public void processTransfer( Transfer transfer )
{
if (devicePulled) return;
mTransfersInProgress.remove( transfer );
switch( transfer.status() )
{
case LibUsb.TRANSFER_COMPLETED:
case LibUsb.TRANSFER_STALL:
if( transfer.actualLength() > 0 )
{
ByteBuffer buffer = transfer.buffer();
byte[] data = new byte[ transfer.actualLength() ];
buffer.get( data );
buffer.rewind();
if( isRunning() )
{
mFilledBuffers.add( data );
}
}
break;
case LibUsb.TRANSFER_CANCELLED:
break;
default:
/* unexpected error */
Log.errorDialog( "ERROR, perhaps device removed?", "USB data transfer error [" +
getTransferStatus( transfer.status() ) +
"] transferred actual: " + transfer.actualLength() + "\nYou will probablly need to restart FoxTelem to reactivate this device." );
devicePulled = true;
return;
}
mAvailableTransfers.add( transfer );
}
示例2: processTransfer
@Override
public void processTransfer( Transfer transfer )
{
mTransfersInProgress.remove( transfer );
switch( transfer.status() )
{
case LibUsb.TRANSFER_COMPLETED:
case LibUsb.TRANSFER_STALL:
if( transfer.actualLength() > 0 )
{
ByteBuffer buffer = transfer.buffer();
byte[] data = new byte[ transfer.actualLength() ];
buffer.get( data );
buffer.rewind();
if( isRunning() )
{
mFilledBuffers.add( data );
}
}
break;
case LibUsb.TRANSFER_CANCELLED:
break;
default:
/* unexpected error */
Log.errorDialog("ERROR", "transfer error [" +
getTransferStatus( transfer.status() ) +
"] transferred actual: " + transfer.actualLength() );
}
mAvailableTransfers.add( transfer );
}
示例3: processTransfer
@Override
public void processTransfer(final RestrictedTransfer transfer) {
if (transfer.status() != LibUsb.TRANSFER_COMPLETED) {
if (transfer.status() != LibUsb.TRANSFER_CANCELLED) {
CypressFX2.log.warning("Error waiting for completion of read on status pipe: "
+ LibUsb.errorName(transfer.status()));
}
return;
}
if (transfer.actualLength() > 0) {
final byte msg = transfer.buffer().get(0);
switch (msg) {
case 0x01: {
final AEReader reader = getAeReader();
if (reader != null) {
CypressFX2.log
.info("********** CypressFX2.AsyncStatusThread: timestamps externally reset");
reader.resetTimestamps();
}
else {
CypressFX2.log
.info("Received timestamp external reset message, but monitor is not running");
}
break;
}
case (byte) 0xFF:
// llongi - copy message to send it out
final ByteBuffer newBuf = ByteBuffer.allocate(transfer.buffer().limit());
newBuf.put(transfer.buffer());
// tobi - send message to listeners
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
support.firePropertyChange(CypressFX2.PROPERTY_CHANGE_ASYNC_STATUS_MSG, null,
newBuf);
}
});
break;
default:
// Nothing to do here.
break;
}
}
}