LED blinking through web application

I am experimenting with some Linux-based embedded systems (Beaglebone, FriendlyARM mini6410, Embest Devkit 8000). I would like to write a web application using some kind of PHP web technology, Javascript, ... whatever it is, the purpose of which is to simply blink an LED. I have to do this to check if I can control some hardware resources through a web application. I know that for Beaglebone I can use node.js and bonescript, but I would like to develop a solution that I can easily use for other purposes (without any or limited modifications to the application), since I have to replicate this on different built-in goals. I know that I need to go through sysfs in order to be able to control hardware resources from a user space application. I could do it in PHP (through sysfs I can only control the slave by opening and reading / writing files), or I could write a C CI application that does the same ... But my question is what other options ? I would like to identify the various possibilities for developing a web application in order to choose the right one.

+4
source share
3 answers

Well, if I did, I would choose a socket connection. Perhaps this is the serial number for really empty hardware (which may not have an Ethernet / WIFI port). I could enable support for both if the device is interchangeable by abstracting the comms layer so that the server can use sockets or serial connection strategies. Most languages ​​support one way or another.

+1
source

write a little cgi. This can even be done with a shell where you can send commands to sysfs

You can do something like

#!/bin/sh #this will parse the sent parameters eval $(echo "$QUERY_STRING"|awk -F'&' '{for(i=1;i<=NF;i++){print $i}}') # this has to be set to whatever you want GPIO=22 echo $GPIO > /sys/class/gpio/export echo "out" /sys/class/gpio/gpio$GPIO/direction echo 1 /sys/class/gpio/gpio$GPIO/value cat << EOF Content-Type: text/html <!DOCTYPE html> <html> <body> <h1>pin on</h1> </body> </html> EOF 

Finally, you must be sure that you have write permissions to sysfs and that the web server is configured to use the shell as the cgi interpreter

+4
source

I wrote a small library called "php-gpio": https://github.com/ronanguilloux/php-gpio

I suppose this could help to achieve this goal.

+1
source

Source: https://habr.com/ru/post/1442975/


All Articles