[英]Control a c program from the web on a Raspberry Pi
I have a C program on a Raspberry Pi that waits (in a loop) for an external user input to start or stop the acquisition of data, and I would like to control it in some way from a webserver hosted on the raspberry. 我在Raspberry Pi上有一个C程序,它(循环)等待外部用户输入来开始或停止数据的获取,我想以某种方式从Raspberry上托管的Web服务器进行控制。
At the moment, to start or stop the acquisition, I am using jquery to write on a txt file that is read in a polling way from the C program. 此刻,要开始或停止采集,我正在使用jquery编写一个从C程序以轮询方式读取的txt文件。
Are there any other (less ugly) solution to control the program from the webserver? 是否有其他(较难看的)解决方案可以从Web服务器控制程序?
Yes you can use nodejs and then you'll be able to access FS module and other useful node modules to communicate with your C program , take a look : 是的,您可以使用nodejs,然后就可以访问FS模块和其他有用的节点模块来与C程序进行通信,请看一下:
Or you can simple use CGI or Fast CGI. 或者,您可以简单地使用CGI或Fast CGI。
I think this is a good resource to start with: http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm 我认为这是一个很好的开始: http : //www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm
Edit: with this technology you get a better code structure and you use the given resources more efficiently than with a polling loop. 编辑:与轮询循环相比,使用此技术可以获得更好的代码结构,并且可以更有效地使用给定资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.