| cmdIIC_RD | Index |
Command Code:
The Packet:
| 0 | 1 | 2 | 3 | 4 | 5 | |||||
| address | 4 | cmdIIC_RD | DEVCODE | SLADDR | NBYTES |
| DEVCODE - | [ (7) HOST | (6) RFLX | (5:0) IICID {0} ] |
| SLADDR - | Address of IIC slave device (odd) |
| NBYTES - | Number of bytes to read (1-6) |
Description:
This command initiates a "master read" operation to retrieve data from a slave device on the IIC bus. An IIC input ID that is out of range will generate an error message. (There is only one IIC bus in a BrainStem network.) An IIC addres that is out of range will generate an error message. A byte count that is out of range will generate an error message.
If the HOST bit is set, the BrainStem will send a cmdDEV_VAL reply packet to the host . The reply packet echoes the IIC device ID in the first data byte and contains the device data in the remaining byte(s). If the RFLX bit is set, the data will go directly to a reflex routine within the BrainStem. The HOST bit and the RFLX bit may be set at the same time.
The following table shows the Console command and a sample reply when requesting three bytes of input from an IIC device with an address of 193 connected to a BrainStem with an address of 2. (The Console program automatically inserts a size byte into the command packet and extracts the size byte from the reply packet.)
| IIC Channel | Device ID | Console Input | Sample Reply |
| 0 | 52 (0x34) | 2 37 128 193 3 | 02:04,34,AA,BB,CC |
When communicating with an IIC device, it may be necessary to lower the IIC baud rate setting with the cmdVAL_SET command in order to get reliable communication.
If a device is not present on the bus or not responding to master-mode read operations, the data bytes retrieved by this command will all be 255 (0xFF).