TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: ALL
from: A. DUMAS
date: 2019-09-02 09:23:00
subject: Re: how to have dio on ra

Op 01-09-19 om 15:23 schreef ZOT:
> Le 01/09/2019 14:53, ZOT a écrit :
>> I have a brand new install of raspian, fresh install of apache2 + php
>> +rrdools
>> But the php script that ran well on a old version of rapian ( I had
>> compiled both apache and php at that time) faile with '
>> -- undefined function dio_open() '
>> So probably php is not compiled with dio!
>> Is there a way to add these functionality to php without recompile?
>> Many tanks to all
>>
>> Les politiciens sont imprévoyants, les électeurs sans mémoire.
>
> to give some precision, dio allow direct access to tty, ..
> exmple:
> $DEVICE="/dev/ttyS1";
> $LOCK="/var/lock/lockdev/LCK..ttyS1";
>
> -----
> $fd = dio_open($DEVICE, O_RDWR |O_NOCTTY | O_NONBLOCK );
> if (! $fd ) {
>     LogErrors($myErrors,"Error opening $DEVICE");ABORT("error opening
> $DEVICE ");}
>
> $param = array( 'baud' => 9600, 'bits' => 8, 'stop'  =>1, 'parity' => 0);
> if ( ! dio_tcsetattr($fd, $param) ) {
>            dio_close($fd);
>            ABORT("Error while dio_tcsetattr \n");
> }
>
> $rc = dio_write($fd, "\r");
> [...]

Alternatively, just use fopen(), fclose(), fread(), fwrite(). Set port
parameters with exec("stty -F [device] [parameters]"), see: man stty.
Flushing the buffers at the right moment might be tricky, or it might
work well automatically; I don't know.

Look at this old thing for inspiration:
https://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html
#view_files/files/17926

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.