Demo app showing Web browser controlling Netduino via Raspberry Pi

preview_player
Показать описание
This is a slightly out of focus demo of a cut down version of my robot buggy software.
(This is take 2, take 1 had a cat walking over the table.)

I have stripped down the buggy code to bare bones so I can share it as a starting point for a project (although there are still a lot of bones).

On the Netduino is a multi-threaded app that reports button press and release events to the Raspberry Pi via UDP. It also accepts UDP commands to turn the LED on or off.

The Pi has been setup to run a Python script on start up. It accepts the UDP status mesages from the Netduino and stores the current state of the button.
It also accepts TCP connections that can request the current status and/or request the LED on/off messages to be sent to the Netduino. The Python reports the current status as a simple html formatted text string that includes the state and the filename of a graphic to display. (There are actually two items that are displayed, the button state, and the state of the last request LED to the Netduino.)

The web page is served from a web server on the Pi. The web pages use PHP to make the TCP connections to the Python. PHP is a language that runs on the server - not in the user's browser. I wanted to avoid running stuff on the user's browser so that there are less requirements. In fact the Web pages will run on my 7 year old Palm T|X.

With each TCP connection to the Python, the PHP sends a simple text string that indicates what is wanted. The Python then acts upon it and returns the status text back to the PHP via the TCP connetion, which is then closed.

The main web page sends a request for status and displays it. It has a timer (html) to make it update (reload) every second.
The buttons cause a new web page to be opened to handle the button press. This web page just has some PHP that sends a request to the Python, and then imediately returns to the main page.

There is hardly any HTML or PHP to write.
There are no libraries of Python to install, just normal socket code and threads to handle messages.
The same with the Netduino, it runs some threads that send and receive UDP messages over Ethernet. The threads mean the main program can carry on running whilst the Ethernet stuff goes on in the background.

It going to take me a while to package up all the code and instructions, they should appear on the Netduino Forums when I do:

Paul
Рекомендации по теме
visit shbcf.ru