array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'function.dio-tcsetattr.php', 1 => 'dio_tcsetattr', ), 'up' => array ( 0 => 'ref.dio.php', 1 => 'Direct IO Functions', ), 'prev' => array ( 0 => 'function.dio-stat.php', 1 => 'dio_stat', ), 'next' => array ( 0 => 'function.dio-truncate.php', 1 => 'dio_truncate', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/dio/functions/dio-tcsetattr.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.3.0, PHP 5 < 5.1.0)
dio_tcsetattr — Sets terminal attributes and baud rate for a serial port
dio_tcsetattr() sets the terminal attributes and baud
rate of the open fd
.
fd
The file descriptor returned by dio_open().
options
The currently available options are:
'baud' - baud rate of the port - can be 38400,19200,9600,4800,2400,1800, 1200,600,300,200,150,134,110,75 or 50, default value is 9600.
'bits' - data bits - can be 8,7,6 or 5. Default value is 8.
'stop' - stop bits - can be 1 or 2. Default value is 1.
'parity' - can be 0,1 or 2. Default value is 0.
No value is returned.
Example #1 Setting the baud rate on a serial port
<?php
$fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);
dio_fcntl($fd, F_SETFL, O_SYNC);
dio_tcsetattr($fd, array(
'baud' => 9600,
'bits' => 8,
'stop' => 1,
'parity' => 0
));
while (1) {
$data = dio_read($fd, 256);
if ($data) {
echo $data;
}
}
?>
Note: This function is not implemented on Windows platforms.