|Online Development Notebook > Index > Programming Overview > DLL Commands > WriteDevice|
WriteDevice - Write "raw" to a device through the DLL
This is a USBm.dll function that writes raw bytes to device.
true⁄false USBm_WriteDevice( device, dataarray )
The USBm_WriteDevice function syntax has these parts:
|device||Valid device from 0 to the maximum number of devices found (minus 1) . Any other number results in a FALSE return.|
|dataarray||Series of eight bytes to write to device.|
Note: USBm_WriteDevice returns TRUE if the device is successfully written.
VB Declaration (USBmAPI.bas)
|Public Declare Function USBm_WriteDevice _|
Lib "USBm.dll" _
(ByVal device As Byte, _
ByRef dataarray As Byte) _
|Dim OutBuffer(8) As Byte|
OutBuffer(0) = 0
OutBuffer(1) = 21
OutBuffer(2) = 3
OutBuffer(3) = 65
OutBuffer(4) = 8
OutBuffer(5) = 17
OutBuffer(6) = 60
OutBuffer(7) = 0
USBm_WriteDevice 2, OutBuffer(0)
This code fragment shows writing a series of bytes to device two. The bytes would follow the "raw" command format.
|int USBm_WriteDevice( unsigned char device, unsigned char *writebuffer );|
Returns a string that contains the results of the response to the command specified in the se_Data string. The data string passed is a set of 8 bytes. The first byte specifies the command code and the next 7 bytes are any byte data required by the command. The returned string contains the first byte as the command number (again) and then the next 7 bytes are any data returned by the command. Not all the bytes may have significance in either the passed string or the returned string.
The passed string will be truncated to 8 bytes if it is longer. It can be shorter if not all the byte positions are required.
Use ArraStr() function to extract the byte values from the string. If you wish to print the data as hexadecimal values then use the Hex() function.
When creating the string of byte values use the Char(desired byte numeric value) to convert the byte numerical value to a character so that it can be added to the string.
Hardware: U401 USB Interface U421 USB Interface U451 USB Interface
Programming: USBm DLL Programming Download Files
Application Notes: U4x1 Application Notes Misc Applications and Information FAQ
While every effort has been made to make sure that the information posted on this site is correct, the author can not be held liable for any damages whatsoever for losses as a result of the application of this information. Use this information at your own risk.
USBmicro can design your custom and semi-custom USB product. Email about USB design can be directed to " Robert " at usbmicro.com.
Copyright © USBmicro, L.L.C., 2002-2010