• PHP Video Tutorials

PHP - Direct I/O tcsetattr() Function



dio_tcsetattr() function can set terminal attributes and baud rate for a serial port.

Syntax

bool dio_tcsetattr( resource fd, array options )

dio_tcsetattr() function can set the terminal attributes and baud rate of an open fd.

Example

<?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;
      }
   } 
?>
php_function_reference.htm
Advertisements