php 执行可执行文件(写入串行端口)并冻结
我有一个 php 脚本正在执行写入串行端口的可执行文件。 然而,每次运行时
system("c:\Untitled1.exe")it just opens up a cmd window and freezes.
有人知道如何解决这个问题吗? 或者是否有更简单的方法让PHP直接写入串口? (我已经尝试过这两个: http:// blogs.vinutomas.com/2007/04/09/php-and-serial-ports/ 并且它们对我不起作用)
PS 我使用的是 Windows XP
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 don't work for me)
P.S. I am on Windows XP
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您运行“Untitled1.exe”时会发生什么 - 它可以在 php 环境之外运行吗?
我建议坚持使用加载的扩展方法 - 这是实现此目的的更好方法。
如果两种方法都不起作用,那么问题可能出在其他地方 - 与权限或配置相关。
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.
我相信win32下的技巧是从php运行start.exe /B来执行然后忘记。 :)
试一试!
您可以通过cmd运行start.exe来获取它的帮助:start /?
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 /?
AFAIK
system()
调用会阻塞执行,直到程序完成。 也许使用popen()
、fread()
和pclose()
可以解决这个问题。请参阅http://php.net/manual/en/function.popen.php 了解更多信息。
AFAIK
system()
call blocks the execution until the program finishes. Maybe usingpopen()
,fread()
andpclose()
could solve this.See http://php.net/manual/en/function.popen.php for more info.