UsbSend Procedure |
Version 7 |
Writes bytes to the specified USB device.
[ lBytes = ] UsbSend ( hDevice, sEOS, lTimeout, enMode, pSrc, lBytes, enPipeType, lEndpointAddress )
The UsbSend procedure syntax has the following parts:
Name |
Type |
Description |
lBytes |
Long |
Return value: the number of bytes sent |
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 |
Output send mode. Only the default value is 0 (aioDefault) is supported |
pSrc |
[Val] Any |
Send data buffer |
lBytes |
[Val] Long |
Maximum number of data bytes to send. If the default value (-1) is used the size of the send buffer pSrc is used. |
enPipeType |
[Val] enumAUsbPipeTypes |
Specify destination pipe using pipe type. Default = aUsbPipeTypeBulkOut |
lEndpointAddress |
[Val] Long |
Instead using previous parameter enPipeType, specify destination pipe using endpoint address. Default = -1 (Use enPipeType) |
The value of hDevice may be obtained using the GetDriverAddress function.
The sEOS can be 0-2 bytes long. This string is sent after the pSrc is sent.
If lBytes was not specified(-1), then it will be set to the length of the source data buffer, pSrc.
This function returns the number of bytes sent, including the sEOS string. A return value of -1 indicates failure.
The following example sends the string "F1G2\r\n" to the USBTMC DMM. The terminator used is Carriage Return/Line Feed, and timeout is set to 150 mSec:
hDevice=GetDriverAddress("DMM")
if UsbSend(hDevice, "\r\n", 150,,"F1G2")<>6
abort
endif
AHandle, enumAIoMode, enumAUsbPipeTypes, UsbOpen, UsbSetup, UsbReceive