[time-nuts] beaglebones, time, web services

Didier Juges shalimr9 at gmail.com
Sun Jul 5 19:13:28 UTC 2015


I have been working on and off on that kind of project for a while.
One type of issue you have when trying to control hardware from a web page is that any hardware access from a web server poses many issues, such as permissions and the fact that web servers are basically stateless and many are multitasking. 
What happens if your web page (or the python script behind it) tries to send data on a serial port (for instance) and another request for the same thing comes along?

The current approach I am using is to have a separate process that maintains the device status in files that be easily accessed by the web server, so that simple status requests can be serviced immediately without needing to query the device each time, and use a fifo to pipe commands between the web page script and the process. The process is the only one that talks to the hardware, so there is no contention.

On the client side, you can use Ajax to keep the web page updated with fresh data without reloading everything each time. It is JavaScript, but there is not too much of it. That part is relatively easy, unless you want to make it really pretty. In that case, it takes a different set of skills (art major with CSS experience...)

Here is a demo:

http://www.ko4bb.com/AjaxDemo/x-web.html

The back end of that runs on php, but it could be python just the same.

Obviously failing the "pretty" test :)

Didier KO4BB


On July 4, 2015 8:13:06 AM CDT, Jim Lux <jimlux at earthlink.net> wrote:
>I've got a project I'm working on to make a sophisticated sundial with 
>moving mirrors.  I've got a batch of Arduinos that move the mirrors to 
>the appropriate places, given the current sun angle, etc.
>
>I've got a beaglebone that runs some python code to calculate sun angle
>
>based on time
>
>The beaglebone will have a GPS feeding it to get time.
>
>BUT now, I'd like to add a web interface, so that it can be manipulated
>
>by a mobile device using a browser.
>
>One way I can think of is to run some sort of limited web server. there
>
>are a couple that come with the beaglebone, including the python 
>"simplehttpserver".
>
>But I'm sort of stuck on the interface between the webserver and the 
>other code running.
>
>I've done this kind of thing where the one task goes out and updates 
>files in the tree that's being served by the web server, and that works
>
>fine for "status display" kinds of things that don't update very 
>quickly. It's also nicely partitioned.
>
>but I want to be able to change the behavior of the system (e.g. by 
>having the server respond to a PUT or something)
>
>Is the best scheme to go in and modify the webserver code to look for 
>specific URLs requested, and then fire off some custom code to do what
>I 
>want?
>
>I'm not particularly interested in javascript, and would prefer python.
>
>
>Or are there libraries that make this more cookbook? (the little 
>"getting started with beaglebone" book talks about flask)
>
>There's quite a few websites out there where someone has done some sort
>
>of "home automation", but they tend to be a bit light on the analysis
>of 
>pros and cons of implementation architectures: "I built X using Y and Z
>
>and it sort of works".
>
>
>Actually, along a similar line.. my "solar position" code isn't very 
>pretty (it's sort of replicating some code I wrote in Basic a long time
>
>ago, with some changes from stuff I cribbed from ccmatlab).  If someone
>
>knows of a python package that just "does this", I'd love to hear about
>
>it.  Either Az El, or X,Y,Z in ECI or ECF would do.
>
>
>
>_______________________________________________
>time-nuts mailing list -- time-nuts at febo.com
>To unsubscribe, go to
>https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
>and follow the instructions there.

-- 
Sent from my Motorola Droid Razr HD 4G LTE wireless tracker while I do other things.


More information about the Time-nuts_lists.febo.com mailing list