Online Development Notebook > Index > Programming Overview > Device Commands > ReadA

ReadA - Read byte value from port A


Description:

This is a function that reads a byte value from port A. The returned value is the state of the port lines that an external device has set, if the line is an input. The lines that might be configured as outputs return the output state.

Command Syntax: (USBm.dll)

USBm_ReadA( device, dataarray )

The USBm_ReadA function syntax has these parts:

Part Description
device A zero-based index to address the appropriate USB device.
dataarray A byte array where the returned data will be stored. Minimum size of the array must be 1 byte

Remarks:

Port A does not have to have all 8 bits set to input for this to work. You can have a mix of inputs and outputs on the port and this command will read the entire port.


VB Declaration

Public Declare Function USBm_ReadA _
    Lib "USBm.dll" _
        (ByVal device As Byte, _
        ByRef dataarray As Byte) _
    As Integer

VB Example

Dim dataarray(1) As Byte
    USBm_ReadA 0, data(0)

This code fragment reads port A of device 0, placing the result into "dataarray(0)".


C Prototype

int USBm_ReadA( unsigned char device, unsigned char *data );

C Example

 


RobotBASIC

usbm_ReadA(ne_DeviceNumber)

Returns the byte value representing the states of the pins on Port A⁄B. The value returned is not a valid value if the device is not a validly active device.


Raw Command  Format:

Byte Number Description
0 05h: ReadACmd
1 <not used>
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

Raw Command  Format Details:

Byte 0 contains the command. Byte 1 through byte 7 are unused.

Raw Command Response Format:

Byte Number Description
0 05h: ReadACmd
1 Data read from port A
2 <not used>
3 <not used>
4 <not used>
5 <not used>
6 <not used>
7 <not used>

Raw Command Response Format Details:

Byte 0 contains the command. Byte 1 contains the current value of port A. Byte 2 through byte 7 are unused.

Raw Command Example Usage:

If the port lines were hi⁄lo⁄hi⁄lo⁄hi⁄lo⁄hi⁄lo (msb high), the command 05-00-00-00-00-00-00-00 would return 05-AA-00-00-00-00-00-00 (assuming that the port is set as all inputs).


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 58 of 126)

This page is created with TreePad