TTY、SWIG 和 PHP
这里需要一些帮助。我有一个 C++ 库,用于通过 tty 与嵌入式模块 (ArchLinux) 进行通信。该库是使用 swig 编译/转换为 php 的。
现在的问题是,用 php 编写并从命令行运行的示例程序按预期执行,但当将相同的代码用作网页功能的一部分时,它无法执行。
基于我有限的 Linux 知识,我的假设是 tty 需要控制台才能运行,这就是为什么它无法作为网页的一部分运行?
有人对我如何让它发挥作用有任何想法吗?我读过一些有关使用 posix_ttyname 的内容,但我似乎找不到任何演示其用途的代码示例。
我已附上有问题的 c++ 文件以及可供审查的测试 main.php。
谢谢大家
Need some help here. I have a c++ library for communicating with an embedded module (ArchLinux) via tty. This library was compiled/converted into php using swig.
The issue now is that a sample program written in php and run from the command line executes as expected but when this same code is used as part of a web page's functionality it fails to execute.
My assumption based on my limited linux knowledge is that tty requires a console in order to run which is why it fails to run as part of a webpage??
Does anyone have any ideas as to how I can get this to work? I have read something about using posix_ttyname but I cant seem to find any code samples that demonstrate its use.
I have attached the offending c++ files along with a test main.php which works for review.
Thanks everyone
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$argv
变量仅在脚本时可用从 CLI 调用。如果您不想更改脚本以便从网络调用它,您可以尝试从另一个脚本调用它,就像从命令行调用它一样。
$argv
variable is available only when script is called from CLI. If you don't want to change the script so it could be called from web, you can try calling it from another script asJust like you do from command line.