atanas markov - 2011-10-09 17:19:35
In your class you use mode command to setup the com port parameters. This is ok, but has a serious leak of windows functionality that blocks all input comunication. Windows needs a timeout for read operations. If it's not set, the system just hangs waiting for input. The main problem is that mode command itself can't setup timeouts. Some people have described how the phpSerial class starts working after running a Windows based terminal emulator before it. It's just because the other program has set the timeout.
There's only one possible solution that may work fine on Windows systems(and it's more necessary on Windows 7 where there's no mode command in dos). You have to use a PECL extension that can set timeouts. I wrote one on my own that creates a Comport class which can be used on both Windows and Linux/POSIX systems. https://github.com/dreamer79/PHP-Comport-class . Unfortunately, the phpSerial class written in pure PHP can work ONLY on POSIX. Microsoft have disabled the functionality needed for such a program and I don't think there will ever be a standard dos command to setup a com port right. You may try to make a win32 executable to setup read timeout and execute it. I don't know if it's worth doing this.