PNS Receiving/Sending HTTP data

Ixolotl

New Member
Hi,

Apologies for exposing my ignorance, but I'm interested in using the PNS in a home automation project and I wanted to check that what I want to do is possible (or sensible). I have a Popcorn A110 Linux based media server/player, and I want to use the cron feature to send out the equivalent of html "button presses" at set times, so the PNS can react accordingly.

Basically I want a 28x or 40x to run it's automation program, the PNS to allow variable changes and user input/feedback as and when required, and the Popcorn to run a webpage allowing cron jobs to be updated (relax - not your problem!).:p

My knowledge of http/html/cgi/php is minimal :rolleyes:, but from the research I've done so far it looks as though I can get the Popcorn Linux server to open a "mini browser" (wget seems the best bet) and send a cgi command as if a browser had opened the PNS webpage and clicked on a button or entered text. It would also be extremely useful if I could get the PNS to accept a string of ASCII characters, perhaps the temperature forecast and sunrise/sunset from an RSS feed. Does this sound reasonable to you, or is there a better way of directly interfacing with the the PNS, without going through a browser?:confused:

I hope this makes some kind of sense, any advice or examples would be very welcome!:D

Cheers,

Ix
 

hippy

Technical Support
Staff member
Welcome to the PICAXE Forum.

The PNS is primarily a web server with an ability to use data which has been provided by an attached PICAXE and a further ability to provide data to that attached PICAXE.

What you seem to be proposing looks feasible. The data you extract from an RSS feed using your media server can be sent to the PNS and attached PICAXE. You will need to have something running on the media server which can read the RSS feed, extract the data, format it for the PNS and then send it. Page 42 of NET001.PDF shows an example of sending a GET command and supplying textual data to the PNS from within a browser page and it should be possible to use WGET or similar to send such data.
 

Ixolotl

New Member
hippy,

Thanks, I was hoping that would be the case, but I wanted to check first. I've managed to retrieve and format the data using wget and awk, but as far as I can tell wget doesn't support GET commands, but curl does. Hopefully I can install curl on the Popcorn, and all will be well! :rolleyes:

The reason I wanted to try this is that the Popcorn media server is pretty much permanently on, so I will use it to serve media files and also to browse the PNS webpages. I guess I could write (or steal :p) shell scripts for more complex operations, and perhaps changing media files as appropriate. It seems silly not to use the Popcorn as an internet gateway, and the two combined should consume a less than even a netbook. Now I just need to wait for payday, so I can place an order for the PNS. Terrible name, though! :rolleyes:

Cheers,

Ix
 

Ixolotl

New Member
Okay, I think I'm getting there, although I managed to do something horrible to telnet on the Popcorn A110, so I will have to reinstall it, plus some utilities that allow wget and curl. The proposed code so far (hopefully :rolleyes:):-

wget -q -O- http://newsrss.bbc.co.uk/weather/forecast/8/Next3DaysRSS.xml| awk 'BEGIN{RS="<title>"}/Max/{gsub(/.*Max Temp|\&\#.*/,"");print}'

wget -q -O- http://newsrss.bbc.co.uk/weather/forecast/8/Next3DaysRSS.xml| awk 'BEGIN{RS="<title>"}/Min/{gsub(/.*Min Temp|\&\#.*/,"");print}'

This should do the job (at work, so can't check what works on Linux :mad:) producing three days Max and Min temperatures in degrees C. The best way might be to save this as various .txt files, and then:-

curl -G -F "commands.cgi?13=24" http://192.168.1.50/index.htm
curl -G -F "commands.cgi?14=@MaxTemp1.txt" http://192.168.1.50/index.htm

"MaxTemp1.txt" contains "0##" where ## is updated daily by the Popcorn. Obviously I haven't tested this yet, but it looks fairly easy. The difficult bit will be making it elegant!

It also occured to me that you could use the media server to replace the unobtainable voice synthesizer, or even wake you up with a song that matches the weather :)

If this ever gets off the ground I'll add it to the Projects folder!
 
Last edited:
Top