简体   繁体   English

在Raspberry Pi上通过Web控制交流程序

[英]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.

相关问题 Raspberry Pi上的Web界面 - Web Interface on the Raspberry Pi 通过Websocket将Raspberry PI中的数据获取到Web页中? - Get data from Raspberry PI over Websocket into Web Page? Raspberry Pi应用程序的信息网页 - Info Web Page For Raspberry Pi Application 您可以使用 JavaScript 控制您家外的设备吗? 例如,使用 web 页面上的“关闭”按钮关闭 Raspberry Pi 3 - Can you control a unit outside your home with JavaScript? For example, shut down a Raspberry Pi 3 with the button “Shut down” on a web page 我可以使用 chrome web 蓝牙低能量 android 将来自树莓派的图像的 stream 发送到 android 吗? - Can I send a stream of images from a raspberry pi to android using chrome web bluetooth low energy API? 尝试从 PC 浏览器访问 Raspberry Pi web 页面时出现错误 403 - Error 403 when trying to access Raspberry Pi web page from PC browser 在树莓派3上通过智能手机打开页面 - Open a page from a smartphone on a raspberry pi 3 如何将数据从客户端发送到树莓派? - How to send data from client to raspberry pi? 树莓派 3 上的 Node.js 服务器未在 web 浏览器中加载 - Node.js server on raspberry pi 3 not loading in web browser 如何通过Web套接字连接到Raspberry Pi上的Mosquitto代理? - How to connect to a Mosquitto broker on a Raspberry Pi through web sockets?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM