USBmicro

Your source for USB electrical device interface products.

  • Home
  • Services
    • Design
    • Contact USBmicro
  • Where to buy…
You are here: Home / Documentation / Device Commands / ReadB

ReadB

Read byte value from port B


Description:

This is a function that reads a byte value from port B. 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_ReadB( device, dataarray )

The USBm_ReadB 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 B 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_ReadB _
    Lib “USBm.dll” _
        (ByVal device As Byte, _
        ByRef dataarray As Byte) _
    As Integer

VB Example

Dim dataarray(1) As Byte
    USBm_ReadB 4, dataarray(0)

This code fragment reads port B of device 4, placing the result into “dataarray(0)”.


C Prototype

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

C Example

 


RobotBASIC

usbm_ReadB(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 06h: ReadBCmd
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 06h: ReadBCmd
1 Data read from port B
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 B. Byte 2 through byte 7 are unused.

Raw Command Example Usage:

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

Documentation

Open all | Close all