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


Java LibUsb.TRANSFER_COMPLETED属性代码示例

本文整理汇总了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 );
   }
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:39,代码来源:RTL2832TunerController.java

示例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 );
  }
 
开发者ID:ac2cz,项目名称:FoxTelem,代码行数:36,代码来源:AirspyDevice.java

示例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;
		}
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:53,代码来源:CypressFX2.java


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