读取接收UART端口的数据
int uart_read(int $uart_id, string &$rbuf [, int $rlen = MAX_STRING_LEN])
$uart_id: 接收数据的UART账号 $rbuf: 读取数据来保存的变量 $rlen: 读取的数据长度、省略将读取最多可读取的大小
读取的数据长度(字节数)
<?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";
}
?>