Click or drag to resize

PipeStreamRead Method

Attempts to read a specified number of bytes from the USB device.

Namespace:  WinUsbNet
Assembly:  WinUsbNet (in WinUsbNet.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public override int Read(
	byte[] buffer,
	int offset,
	int count
)

Parameters

buffer
Type: SystemByte
An array of bytes to receive the data read from the USB device.
offset
Type: SystemInt32
The zero-based byte offset in buffer at which to begin storing the data read from the USB device.
count
Type: SystemInt32
The maximum number of bytes to read from the USB device.

Return Value

Type: Int32

The total number of bytes read into buffer. This can be less than the number of bytes requested (including zero) if a short packet is received and the ReadUseShortPacket property is set to true.

Exceptions
ExceptionCondition
IOExceptionThe UsbDevice is not open.
NotSupportedExceptionThe PipeStream does not support reading.
ArgumentNullExceptionbuffer is null.
ArgumentOutOfRangeExceptionoffset or count is negative.
ArgumentExceptionThe sum of offset and count is larger than the buffer length.
Win32ExceptionAn error was reported by the operating system. If NativeErrorCode is 0x00000079, the operation timed out.
Remarks

If the USB device returns more data than requested, the excess data will be stored in an internal buffer. Future calls to Read or ReadByte will read from the internal buffer until it is exhausted.

If the ReadUseShortPacket property is true, then a short packet received from the USB device will terminate the read transfer. The number of bytes received to that point will be returned.

If the ReadUseShortPacket property is false, then a short packet will not terminate the read transfer. The transfer will continue until the number of bytes requested has been received or the time limit specifed by ReadTimeout has been reached.

See Also