|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35531 php wont get input from a serialport after writing to it
Submitted: 2005-12-03 18:26 UTC Modified: 2005-12-11 01:00 UTC
Avg. Score:4.0 ± 1.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (100.0%)
From: roman-lehnert at gmx dot de Assigned:
Status: No Feedback Package: Filesystem function related
PHP Version: 4.4.1 OS: Linux 2.6.12
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-12-03 18:26 UTC] roman-lehnert at gmx dot de
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:

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:
$fp = fopen('/dev/ttyUSB0','r+');
#fp = fopen('/dev/ttyUSB0','w+');
$buffer = fread($fp,1);

$fp = dio_open('/dev/ttyUSB0', O_RDWR | O_NOCTTY | O_NONBLOCK | O_APPEND);
$buffer = dio_read($fp,1);

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:
read(3, "\0\340", 4096)                 = 2

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:
read(3, 0x17e4a4, 1024)                 = -1 EAGAIN (Resource temporarily unavailable)

When the devicefile is opened in blockingmode, it just hangs at


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-03 23:50 UTC]
Please try using this CVS snapshot:
For Windows:

 [2005-12-11 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Apr 04 06:01:23 2020 UTC