Online Development Notebook > Index > Programming Overview > DLL Commands > ReadDevice

ReadDevice - 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 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.


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

Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 47 of 126)

This page is created with TreePad