isendrecv

Updated: April 19, 2023

Execute DCMD_I2C_SENDRECV devctl()

Syntax:

isendrecv [-a slave] [-b speed] [-l length] [-n name] [-r] [-x] [data ... ]

Runs on:

QNX Neutrino

Options:

-a slave
The address of the slave device; this address is either seven bits (default), or ten bits if the -x option is specified.
-b speed
The bus speed, in Hertz. Default is to use the most recently set bus speed (i.e., use the same bus speed as the most recent transaction); if this is the first transaction, use the I2C driver's default bus speed.
-l length
The number of bytes to receive.
-n name
The path and name of the I2C device. Default is /dev/i2c0.
-r
Don't issue a stop condition on the bus when the transaction is complete. Default (-r not specified) is to issue a stop condition when the transaction is complete.
-x
If specified, use a ten-bit slave address. If not specified, use a seven-bit slave address (default).
data
Data bytes to send, written as space-separated values; for example: 0x12 0x34 0x56, not 0x123456. Data can be sent in any base understood by the shell (octal, decimal, or hexadecimal). For example:
isendrecv -a 0x6f 0x20 15 16 17

data: 20h fh 10h 11h
Data recvd:

isendrecv -a 0x6f -l 3 0x20

data: 20h
Data recvd: fh 10h 11h

Note: While the tool reports all values as hexadecimal followed with an "h" (like "fh"), that format cannot be used to send data because the shell doesn't understand it.

Description:

The isendrecv utility executes a DCMD_I2C_SENDRECV command (see DCMD_I2C_SENDRECV in Customizing a BSP).

Examples:

The following examples illustrate how to use isendrecv. Note that behavior is device-specific: it's up to the device to interpret the data it receives. For some devices, the first byte might be an address, but this is not guaranteed. You may need to modify the examples for your device. Check your device manual to know what it expects, and how it will behave.

Write, then read

Write one byte with the value 0x2 to an I2C device on bus 3, at address 0x48, using the same bus speed as the most recent transaction. After the data has been sent, read back one byte from the slave device:

isendrecv -a 0x48 -n /dev/i2c3 -l 1 0x2

For some I2C slave devices, this command format could be used to select the slave register at offset 0x2, then read back one byte of register data.

Write only

Write two bytes with the values 0x1 for the first byte, then 0x2 for the second byte to an I2C device on bus 3, at address 0x48 and with a bus speed of 400 KHz:

isendrecv -a 0x48 -n /dev/i2c3 -b 400000 0x1 0x2

For some I2C slave devices, this command format could be used to select the slave register at offset 0x1, then write value 0x2 to this register.

Read only

Read one byte from an I2C device on bus 3, at address 0x48.

isendrecv -a 0x48 -n /dev/i2c3 -l 1

Exit status:

0
Successful completion.
<0
An error occurred.