From:             mccaskey at stanford dot edu
Operating system: Windows XP
PHP version:      5.0.3
PHP Bug Type:     Filesystem function related
Bug description:  With serial ports, fread is using the fwrite buffer

Description:
------------
(1) Open a COM port as a serial input using fopen. Read using fread or
fgets. No data appears until 8K bytes have been read. There is an 8K
buffer on writes, but there shouldn't be one on reads. (Should there?) Are
reads somehow using the write buffer? Sure enough:

(2) Again, open a COM port as a serial input using fopen. This time, write
some characters using fwrite. Now fread 8K of serial data. At the head of
that stream appears the data you had written with fwrite. Oops.

[Several people have reported an inability to get fgets to read COM data,
saying they tried and fgets just never sees any input. I assume this was
their problem. But others have reported using fgets on COM successfully.
Something specific to OS/PHP versions?] 

Reproduce code:
---------------
(1) 
$serial_port = fopen("COM4", "r+");
echo(fread($serial_port, 8192));

(2)
$serial_port = fopen("COM4", "r+");
fwrite($serial_port, "MP");
echo(fread($serial_port, 8192));

Expected result:
----------------
(1) & (2)
serial data starting with the first byte that came in on the serial line


Actual result:
--------------
(1) Nothing until 8K of data has been read in.

(2) After enough serial data to fill the buffer, first the data written
("MP" in this example), then the data that came in on the serial line.

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

Reply via email to