Read “raw” from a device through the DLL
Description:
This is a USBm.dll function that reads raw bytes from a device.
Command Syntax:
true⁄false USBm_ReadDevice( device, dataarray )
The USBm_ReadDevice 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 read from the device. |
Remarks:
Note: USBm_ReadDevice returns TRUE if the device is successfully read.
VB Declaration (USBmAPI.bas)
Public Declare Function USBm_ReadDevice _ Lib “USBm.dll” _ (ByVal device As Byte, _ ByRef dataarray As Byte) _ As Integer |
VB Example
Dim InBuffer(8) As Byte USBm_ReadDevice 2, InBuffer(0) |
This code fragment shows reading a series of bytes from device two. The bytes would follow the “raw” command format.
C Prototype
int USBm_ReadDevice( unsigned char device, unsigned char *readbuffer ); |
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.