views:

598

answers:

3

I have a php script that is executing an executable that writes to a serial port. However, everytime it runs

system("c:\Untitled1.exe")
it just opens up a cmd window and freezes.

Anybody know how to fix this? Or if there is an easier way to get PHP to write to the serial port directly? (I've already tried these two: http://blogs.vinuthomas.com/2007/04/09/php-and-serial-ports/ and they dont work for me)

P.S. I am on Windows XP

A: 

AFAIK system() call blocks the execution until the program finishes. Maybe using popen(), fread() and pclose() could solve this.

See http://php.net/manual/en/function.popen.php for more info.

lacop
+1  A: 

What happens when you run "Untitled1.exe" - does it work outside of the php environment?

I would advise persevering with the loaded extension method - it's a much better way of implementing this.

If both methods aren't working then maybe the problem is somewhere else - related to permissions or configuration.

Richard Harrison
A: 

I believe the trick under win32 is to run start.exe /B from php to execute and forget. :) Give it a shot!

You can get the help for start.exe by running it through cmd : start /?

SchizoDuckie