Reading data from the SPI
int spi_read(int $spi_id, string &$rbuf, int $rlen)
data length (byte) on success, 0 on fail
<?php
include "/lib/sd_340.php";
$rbuf = "";
$rlen = 0;
spi_setup(0); // configuring SPI
while(1)
{
$rlen = spi_read(0, $rbuf, 2); // Reading 2 bytes data from the SPI
if($rlen == 2)
echo "$rbuf\r\n";
sleep(1);
}
?>