uart_read()


Reading received data from the designated UART port

Description

int uart_read(int $uart_id, int/string &$rbuf [, int $rlen = MAX_STRING_LEN])

Parameters

$uart_id: UART ID to read $rbuf: variable to save the received data $rlen: maximum data length to read

Return Value

Returns the number of bytes read

Example

<?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";
}
?>

See also