UsbReceive Procedure

Version 7

 

Reads bytes from the specified USB device.

Syntax

[ lBytes = ] UsbReceive (hDevice, sEOS, lTimeout, [enMode], pDst, [lBytes], [enPipeType], [lEndpointAddress] )

The UsbReceive procedure syntax has the following parts:

 

Name

Type

Description

lBytes

Long

Number of bytes received. A value of -1 indicates an error has occurred.

hDevice

Val AHandle

Handle to the USB device

sEos

Val BString

EOS (End of Sequence) string

lTimeout

Val Long

Timeout in milliseconds

enMode

[Val] enumAIoMode

Input send mode. Only the default value is 0 (aioDefault) is supported

pDst

Var Any

Receive data buffer

lBytes

[Val] Long

Maximum number of bytes to receive. If the default value is used (-1) the byte length of the pDst is used as the maximum of bytes to receive.

enPipeType

[Val] enumAUsbPipeTypes

Specify destination pipe using pipe type. Default = aUsbPipeTypeBulkIn

lEndpointAddress

[Val] Long

Instead using previous parameter enPipeType, specify destination pipe using endpoint address. Default = -1 (Use enPipeType)

Remarks

The value of hDevice may be obtained using the GetDriverAddress function.

The sEOS can be 0-2 bytes long. It specifies the data bytes that signals the end of data.

This function returns the number of bytes received, including the sEOS string. A return value of -1 indicates failure.

Example

The following example reads a maximum of 20 bytes from the DMM to sData. The terminator used is Carriage Return/Line Feed. Timeout is set to 1500 mSec:

hDevice=GetDriverAddress("DMM")

UsbReceive(hDevice, "\r\n", 1500,,sData, 20)

 

See Also

enumAIoMode, enumAUsbPipeTypes, UsbSend, UsbOpen, GetDriverAddress