Write “raw” to a device through the DLL
Description:
This is a USBm.dll function that writes raw bytes to the device.
Command Syntax:
true⁄false USBm_WriteDevice( device, dataarray )
The USBm_WriteDevice function syntax has these parts:
Part | Description |
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 the device. |
Remarks:
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) _ As Integer |
VB Example
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.
C Prototype
int USBm_WriteDevice( unsigned char device, unsigned char *writebuffer ); |
C Example
RobotBASIC
usbm_DeviceCmd(ne_DeviceNumber,se_Data)
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.