From:             roman-lehnert at gmx dot de
Operating system: Linux 2.6.12
PHP version:      4.4.1
PHP Bug Type:     Filesystem function related
Bug description:  php wont get input from a serialport after writing to it

Description:
------------
Php doesn't get any input from a serialport, after opening the devicefile
and writing to it. Maybe this is thought to be so - and maybe it is a
feature. For those cases: sorry for stealing ur time. 


Infact, there IS a response from the device. The difference between
"strace php -f example.php" and "strace cat /dev/ttyUSB0"
(nonblocking-mode in php):

php wont get the input. for php, the device is "temporarily unavailable":
"read(3, 0x17e4a4, 1024)                 = -1 EAGAIN (Resource temporarily
unavailable)"

cat gets the answer from the device:
"read(3, "\0\340", 4096)                 = 2"


There is no difference, if i use fopen, or dio_open: php wont get the
answer from my device.
There is also no difference, if i use fread, fgets or dio_read. 

The lib i used can be seen here: http://nopaste.php-q.net/176167


Tested on a x86 and an embedded-arm machine, both running an actual linux
>2.6.12-r1 kernel. The chmods for the devices were set correctly. 

Reproduce code:
---------------
<?php
$fp = fopen('/dev/ttyUSB0','r+');
#fp = fopen('/dev/ttyUSB0','w+');
fputs($fp,chr(0xff),1);
$buffer = fread($fp,1);
fclose($fp);
?>

<?php
$fp = dio_open('/dev/ttyUSB0', O_RDWR | O_NOCTTY | O_NONBLOCK |
O_APPEND);
dio_write($fp,chr(0xff));
$buffer = dio_read($fp,1);
dio_close($fp);
?>


Expected result:
----------------
I expected to get the answer in $buffer by fread, fgets or dio_read. But
the answer from the device (wich i can see in cat /dev/ttyUSB0) didnt came
up in php. 

Actual result:
--------------
The strace of "cat /dev/ttyUSB0", you can see here:
<snip>
read(3, "\0\340", 4096)                 = 2
</snip>

Should appear also at "strace php -f example.php". but it doesnt. When the
devicefile is opened in nonblocking mode, the relevant strace-output is:
<snip>
read(3, 0x17e4a4, 1024)                 = -1 EAGAIN (Resource temporarily
unavailable)
</snip>

When the devicefile is opened in blockingmode, it just hangs at
<snip>
read(3,
</snip>


-- 
Edit bug report at http://bugs.php.net/?id=35531&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35531&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35531&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35531&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35531&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35531&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35531&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35531&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35531&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35531&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35531&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35531&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35531&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35531&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35531&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35531&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35531&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35531&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35531&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35531&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35531&r=mysqlcfg

Reply via email to