You are here: Re: Reading COM1 with php-win « PHP Programming Language « IT news, forums, messages
Re: Reading COM1 with php-win

Posted by Jerry Stuckle on 12/27/06 01:15

>>I need to read incoming bytes on a COM port but I do not want to have
>>the script hang if there is nothing to read.
>>
>>Is there any way to have PHP interrogate a COM port buffer to see if
>>there is any content before reading it?
>>
>>Any other method to achieve the result would also be welcome.
>>
>>Cheers,
>>
>>Fred.
>
>

(Top posting fixed)
hackajar@gmail.com wrote:
> Windows "COM" ports (like com1, com2, etc) do not have a buffer. They
> are a serial interface that connects directly to the CPU (or CPU bridge
> I suppose with newer motherboards). You will have to be running in a
> loop waiting for data on the COM port to get data off it.
>
> Think:
>
> while(0) {
> $getData = comportcheckfuntion('com1'); //You would have to write
> this function or get one off internet
> if($getData) //do your stuff here
> else sleep(1); //sleep for a second and then let loop check com port
> again.
> }
>
> Cheers,
> Hackajar
> bloggsfred00@hotmail.com wrote:
>


Incorrect.

First of all, the serial port hardware itself has a 16 byte (or larger)
buffer built in.

Secondly, the COM port, like all devices in Windows, goes through a
driver. Your program doesn't talk to the chip itself; it talks to the
driver (through Windows). This driver has two buffers - a transmit and
a receive buffer. And IIRC, both are 4K. But I haven't written any COM
port software since WINNT, so this may have been increased in later
versions.

But it has not been decreased.

P.S. Please don't top post.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация