ID: 35531 Updated by: [EMAIL PROTECTED] Reported By: roman-lehnert at gmx dot de -Status: Open +Status: Feedback Bug Type: Filesystem function related Operating System: Linux 2.6.12 PHP Version: 4.4.1 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5.1-latest.tar.gz For Windows: http://snaps.php.net/win32/php5.1-win32-latest.zip Previous Comments: ------------------------------------------------------------------------ [2005-12-03 18:26:22] roman-lehnert at gmx dot de 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 this bug report at http://bugs.php.net/?id=35531&edit=1