Re: adding tcsetattr to dio extenstion
| From: | Sterling Hughes | Date: | Wed, 07 Aug 2002 12:50:22 +0000 |
| Subject: | Re: adding tcsetattr to dio extenstion | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-86592@lists.php.net to get a copy of this message | ||
> attached is a patch to add tcsetattr() to the dio extension
>
> any objections/suggestions for it..
> for some reason if I do O_ASYNC on SET_FL i get 'I/O possible' and
> dies... ?????
>
Feel free to commit it, my only internet is currently firewalled http and
ftp, so I can't really do much in that way (actually, can't even test your
patch, but the interface looks fine).
O_ASYNC should really be removed, its useless from your php script, and php
really can't do async I/O without using the (un-portable) unix aio_*
interface, until that is directly support signal based I/O is pretty much
impossible in php.
-Sterling
>
> usage:
>
> dl('dio.so');
>
>
> $fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK);
>
> /* signal callbacks
> ....
> */
>
> dio_fcntl($fd,F_SETOWN,posix_getpid());
> //dio_fcntl($fd,F_SETFL, O_ASYNC ); // <- produces a 'I/O possible' and
> dies... ?????
> dio_fcntl($fd,F_SETFL, O_SYNC );
>
> dio_tcsetattr($fd, array(
> 'baud' => 9600,
> 'bits' => 8,
> 'stop' =>1,
> 'parity' => 0
> ));
> echo "STARTING READ";
> while (1) {
>
> $data = dio_read($fd,256);
>
> if ($data) {
> echo $data;
> }
> }