uart_readn()


读取指定长度的UART接收数据

Description

int uart_readn(int $uart_id, string &$rbuf, int $rlen)

Parameters

Return Value

成功时读取数据长度(字节数),失败时0

Example

<?php
include "/lib/sd_340.php";
$rbuf = "";
uart_setup(0, 9600);               // Configuring UART0 to 9600 bps
while(1)
{
  $rlen = uart_readn(0, $rbuf, 5);  // Reading 5 bytes of data from the UART0
  if($rlen)
  {
    echo "$rbuf\r\n";
    break;
  }
}
?>

See also