isendrecv

Execute DCMD_I2C_SENDRECV devctl()

Syntax:

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

Runs on:

QNX Neutrino

Options:

-a slave
The address of the slave device; this address is either seven bits (default), or 10 bits if the -x option is specified.
-x
If specified, use a ten-bit slave address. If not specified, use a seven-bit slave address (default).
-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.
-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.
data
Data bytes to send, written as space-separated hexadecimal values; for example: 0x12 0x34 0x56, not 0x123456.

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.