读取I2C接收数据
int i2c_read(int $i2c_id, string &$rbuf, int $rlen)
读取数据长度(byte)
<?php
include "/lib/sd_340.php";
$rbuf = "";
$rlen = 0;
i2c_setup(0, 0x0E); // configuring I2C
while(1)
{
$rlen = i2c_read(0, $rbuf, 2); // reading 2 bytes data from the I2C
if($rlen == 2)
echo "$rbuf\r\n"; // Outputting the received data
sleep(1);
}
?>