> -----Original Message-----
> From: John McCaskey [mailto:[EMAIL PROTECTED]
> Sent: Sunday, March 27, 2005 5:13 AM
> Others have reported problems reading COM ports using fopen and fgets or
> fread. They open the port and start reading but nothing ever arrives.
I had the "problem" and solved it, I believe I posted the answer here too? What
kinda device are You listening to? I was listening to a switch and got nothing
using the example from the fgetc manual until I restarted the switch, then all
the boot info became visual... It reads each byte from the port, so use that as
a "listen_wrapper", send try some [enter] commands, have a terminal ready to
check if something goes wrong, try output the buffer, when $char is a "\n" and
basically know exactly what the device shows and expects. Here�s a hint to get
You started:
if($fp = fopen('com1', 'wb')) // b for windows
// send [enter]
fwrite($fp, "\r\n");
// listen to device
while (false !== ($char = fgetc($fp))) {
echo "$char\n";
$buffer .= $char;
if($char == "\n" || $char = "\r") {
echo "\nBUFFER: $buffer\n\n";
sleep(3);
$buffer = "";
}
}
}
else {
echo 'can�t connect to com1, got a terminal open?';
}
Play some more with the sleep and [enter]
> I have the same problem and discovered the following. There is an 8K
> input buffer. Only after 8K bytes have arrived does fgets or fread see the
> first.
Won�t be a problem with fgetc() since You read char by char.
> How does one get around this feature (or bug)?
>
> This is with php 5.0.2.2 on Windows XP.
I�m using 4.3.10
--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/systemdeveloper
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php