Edit report at https://bugs.php.net/bug.php?id=32469&edit=1

 ID:                 32469
 Comment by:         xodrf at hotmail dot com
 Reported by:        mccaskey at stanford dot edu
 Summary:            With COM ports (Windows), fread sees nothing until
                     8K
 Status:             Closed
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   Windows XP
 PHP Version:        5CVS-2005-03-29
 Block user comment: N
 Private report:     N

 New Comment:

In windows one way to make work fopen("COM4","r+") and then sucesives fread() 
is previusly do this: start->control panel->modem and phone then select de 
modem and click propertys and make a test or Diagnostic of the device.

After that work properly fopen() and fread() under serial port while not 
disconnect de port.

I work in project with PHP to SEND SMS with my cell phone SAMGSUNG E2222

Sorry my English


Previous Comments:
------------------------------------------------------------------------
[2005-05-23 14:59:15] sni...@php.net

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.



------------------------------------------------------------------------
[2005-04-02 20:29:45] mccaskey at stanford dot edu

(2) was an artifact of my test setup. Ignore that. But (1) stands: I can't see 
any input until 8K bytes have been read.

Using a COM-port monitoring program, I can see and count the bytes coming in, 
and a terminal emulator gets them starting with the first byte, but php (fread, 
fgets, or fgetc) doesn't.

------------------------------------------------------------------------
[2005-03-28 03:56:10] mccaskey at stanford dot edu

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 this bug report at https://bugs.php.net/bug.php?id=32469&edit=1

Reply via email to