Transfer() public method

Synchronous bulk/interrupt transfer function.
public Transfer ( IntPtr buffer, int offset, int length, int timeout, int &transferLength ) : ErrorCode
buffer System.IntPtr An to a caller-allocated buffer.
offset int Position in buffer that transferring begins.
length int Number of bytes, starting from thr offset parameter to transfer.
timeout int Maximum time to wait for the transfer to complete.
transferLength int Number of bytes actually transferred.
return ErrorCode
コード例 #1
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            if (!CanRead)
            {
                throw new InvalidOperationException(String.Format("Cannot read from WriteEndpoint {0}.", (WriteEndpointID)mUsbEndpoint.EpNum));
            }

            int       transferred;
            ErrorCode ec = mUsbEndpoint.Transfer(buffer, offset, count, ReadTimeout, out transferred);

            if (ec == ErrorCode.Success)
            {
                return(transferred);
            }

            if (ec == ErrorCode.IoTimedOut)
            {
                throw new TimeoutException(String.Format("{0}:Endpoint 0x{1:X2} IO timed out.", ec, mUsbEndpoint.EpNum));
            }
            if (ec == ErrorCode.IoCancelled)
            {
                throw new IOCancelledException(String.Format("{0}:Endpoint 0x{1:X2} IO was cancelled.", ec, mUsbEndpoint.EpNum));
            }

            throw new IOException(string.Format("{0}:Failed reading from endpoint:{1}", ec, mUsbEndpoint.EpNum));
        }
コード例 #2
0
 public ErrorCode SyncTransfer()
 {
     mResult = mUsbEndpoint.Transfer(mGCBuffer.AddrOfPinnedObject(), mOffset, mCount, mTimeout, out mTrasferredLength);
     mGCBuffer.Free();
     mIsComplete = true;
     if (mCallback != null)
     {
         mCallback(this as IAsyncResult);
     }
     mCompleteEvent.Set();
     return(mResult);
 }