i2c_write_read()


Transmitting data to the I2C and reading data from the I2C simultaneously

Description

int i2c_write_read(int $i2c_id, string $wbuf, string &$rbuf, int $rlen)

Parameters

Return Value

data length to read/write on success, 0 on fail

Example

<?php
include "/lib/sd_340.php";
$rbuf = "";
$wbuf = "\x05\x03";
$rlen = 0;
i2c_setup(0, 0x1e);                         // configuring I2C
$rlen = i2c_write_read(0, $wbuf, $rbuf, 2); // writing and reading to/from the I2C
if($rlen == 2)
  echo "$rbuf";                             // outputting the received data
?>

See also