Reading received data from the designated UART port
int uart_read(int $uart_id, int/string &$rbuf [, int $rlen = MAX_STRING_LEN])
$uart_id: UART ID to read $rbuf: variable to save the received data $rlen: maximum data length to read
Returns the number of bytes read
<?php
include "/lib/sd_340.php";
$rbuf = "";
$rlen = 0;
uart_setup(0, 9600); // Configuring UART0 to 9600bps
while(1)
{
uart_read(0, $rbuf); // Reading data from UART0 into $rbuf
echo "$rbuf\r\n";
}
?>