Magnavox Daemon: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
== Overview == | |||
Basically a continuous stream of data comes in from the receiver at 9600 bps. | |||
It is in ASCII text. A line starts with a message code and ends with a newline. | |||
With my simple CGI program, to get a full set of readings, it has to connect and listen until enough data has gone by. This takes around 10 seconds. | |||
The idea of the daemon is to listen all the time and keep an updated set of readings in memory. When a client asks for the data it just dumps it all out at once. | |||
So there are two parts to code up. The data collector and the network server. | |||
== Data collector == | |||
This is just a version of the existing CGI that runs all the time. Instead of | |||
collecting data and exiting, each time it gets a new reading it just holds it in a table. When enough data has been collected, a 'data good' flag is set. From then on, whenever a network request comes in, it just sends out the most recent data set. A debug flag can be set that will spew data to the console as it is collected. | |||
== Network server == | |||
I am thinking of using [http://www.nightmare.com/medusa/ Medusa] for the network server portion; I briefly considered [http://twistedmatrix.com Twisted] but it seems like 100 times more than I need right now. | I am thinking of using [http://www.nightmare.com/medusa/ Medusa] for the network server portion; I briefly considered [http://twistedmatrix.com Twisted] but it seems like 100 times more than I need right now. | ||
Even asyncore might be enough. | Even asyncore might be enough. |
Revision as of 19:02, 28 April 2006
Overview
Basically a continuous stream of data comes in from the receiver at 9600 bps. It is in ASCII text. A line starts with a message code and ends with a newline.
With my simple CGI program, to get a full set of readings, it has to connect and listen until enough data has gone by. This takes around 10 seconds.
The idea of the daemon is to listen all the time and keep an updated set of readings in memory. When a client asks for the data it just dumps it all out at once.
So there are two parts to code up. The data collector and the network server.
Data collector
This is just a version of the existing CGI that runs all the time. Instead of collecting data and exiting, each time it gets a new reading it just holds it in a table. When enough data has been collected, a 'data good' flag is set. From then on, whenever a network request comes in, it just sends out the most recent data set. A debug flag can be set that will spew data to the console as it is collected.
Network server
I am thinking of using Medusa for the network server portion; I briefly considered Twisted but it seems like 100 times more than I need right now.
Even asyncore might be enough.