[PHP] Serial Communication
Hello List, I have managed to communicate with the serial device with the following code: 'mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=n';//the config the device needs $fp = fopen(COM1:, rb+);//also tried only r+ here if(!$fp) die(); $query = chr(59).chr(32).0.chr(13).chr(10); fputs($fp, $query); $reply = fgets($fp, 32); print($reply); This works, the 0-command requests the ID of the device and the reply I get in $reply is exactly what it should be. The problem: it takes around 5 seconds until this reply is there, I tried different lengths to buffer in fgets, tried fgetc, fread, everything, always the same. It can't be the device blocking it, because if I send a couple of commands (to position the devices measurement head) it reacts to all of these commands in lightning speed, so I don't think it is the device slowing the thing down, BUT what could it be? Does anybody have any experience with this??? Basically, fread/fgets/fgetc just hangs the PHP core for several seconds, with 0-1% CPU load...something just stalls PHP for this peroid of time. If this is an internal problem of PHP: does anybody know a source where I can find some hints on how to communicate with the serial port over the COM implementation of php-win? Googling for com serial port php is a bit troublesom, since com in this case finds dozens of sites where com refers to com1 and not the COM system of Win32. Any help is greatly appreciated! best regards Ulrik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Serial Communication
Ulrik Witschass wrote: Hello List, I have managed to communicate with the serial device with the following code: 'mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=n';//the config the device needs $fp = fopen(COM1:, rb+);//also tried only r+ here if(!$fp) die(); $query = chr(59).chr(32).0.chr(13).chr(10); fputs($fp, $query); $reply = fgets($fp, 32); print($reply); This works, the 0-command requests the ID of the device and the reply I get in $reply is exactly what it should be. The problem: it takes around 5 seconds until this reply is there, I tried different lengths to buffer in fgets, tried fgetc, fread, everything, always the same. It can't be the device blocking it, because if I send a couple of commands (to position the devices measurement head) it reacts to all of these commands in lightning speed, so I don't think it is the device slowing the thing down, BUT what could it be? Does anybody have any experience with this??? Basically, fread/fgets/fgetc just hangs the PHP core for several seconds, with 0-1% CPU load...something just stalls PHP for this peroid of time. If this is an internal problem of PHP: does anybody know a source where I can find some hints on how to communicate with the serial port over the COM implementation of php-win? Googling for com serial port php is a bit troublesom, since com in this case finds dozens of sites where com refers to com1 and not the COM system of Win32. Any help is greatly appreciated! best regards Ulrik You could try the same thing using windows' HyperTerminal. Connecting trough it and sending the same commands, and check if it takes as long aswell. That way you can rule out at least half of the possible problems (are they windows/COM related or PHP related). Basically, last time I tried something similair, I noticed my system freezing for a few secs on sending the first command. But this was with a faulty cable, so I'm not sure if that means anything... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP] Serial Communication
Thanks for the help, when communicating to it via hyperterminal (or other software) it responds immidiately. I will try it on different machines within the next few days...hopefully it is just a hardware/software problem with my dev-system... best regards Ulrik //You could try the same thing using windows' HyperTerminal. Connecting trough it and sending the same commands, and check if it takes as long aswell. That way you can rule out at least half of the possible problems (are they windows/COM related or PHP related). Basically, last time I tried something similair, I noticed my system freezing for a few secs on sending the first command. But this was with a faulty cable, so I'm not sure if that means anything... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Serial Communication
Hello List, I am searching information about serial communication with PHP on Windows machines. I want to communicate with a colorimeter via a COM-Port, using a PHP-GTK application. Can anybody point me into the right direction (a webpage, a PHP class/function, a PHP-GTK list) where I can find infos about this? I searched the web for some hours now but didn't find anything worthy. Any help is greatly appreciated! thanks in advance! best regards Ulrik Witschass
Re: [PHP] Serial Communication
On Fri, 22 Oct 2004 18:11:43 +0200, Ulrik Witschass [EMAIL PROTECTED] wrote: Hello List, I am searching information about serial communication with PHP on Windows machines. There's a simple example on this page: http://www.php.net/function.fopen Search for 'SERIAL'. -- Greg Donald Zend Certified Engineer http://gdconsultants.com/ http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Serial Communication
Ulrik Witschass wrote: Hello List, I am searching information about serial communication with PHP on Windows machines. I want to communicate with a colorimeter via a COM-Port, using a PHP-GTK application. Can anybody point me into the right direction (a webpage, a PHP class/function, a PHP-GTK list) where I can find infos about this? I searched the web for some hours now but didn't find anything worthy. Any help is greatly appreciated! Check out http://pecl.php.net/WinBinder Maybe there is a COM (common object model) interface, I don't know. In that case you could use http://www.php.net/com. Look at msdn.microsoft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Serial Communication
You can also use the DIO extension (built-in as of PHP 5.0.0). using dio_open, dio_read, dio_write and dio_close you can do a lot of magical things ;) http://www.php.net/manual/en/ref.dio.php Greg Donald wrote: On Fri, 22 Oct 2004 18:11:43 +0200, Ulrik Witschass [EMAIL PROTECTED] wrote: Hello List, I am searching information about serial communication with PHP on Windows machines. There's a simple example on this page: http://www.php.net/function.fopen Search for 'SERIAL'. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
AW: [PHP] Serial Communication
Thanks for the many great replies, since at the moment the project is based on PHP4, I will try if the filesystem functions provide what I need. Opening the port and sending doesn't seem to be a problem, I'll try it out tonight. If for some reason it doesnt provide the functionality I need, I will take a closer look at migrating to PHP 5 (which shouldn't be a problem) and using the DIO functions. Thanx to everybody for the help they provided! best regards Ulrik -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php