Soliciing suggestions for application design

Carl Banks imbosol-1048379651 at aerojockey.com
Sat Mar 22 19:55:40 EST 2003


Byron Morgan wrote:
> Greetings all,
> 
> I need to build an app to do the following:
> 
> 1. monitor two serial ports: port A polls for data, B carries responses from
> a population of 1000 mobile radios
> 2. match polls to responses based on timing window (between .033 & .066
> seconds) after poll is transmitted
> 3. do something interesting to selected poll - response pairs
> 4. forward results via inet (as telnet stream or cgi post, not decided yet)
> 
> Should I try to do it all in a single program, using threading (haven't
> tried threading yet), or use a parent app to do the interesting stuff and
> two children to monitor the ports and supply the data? If the latter, how
> best to handle the interprocess comms? I haven't started experimenting with
> the live data yet, but it seems to me the single most important part will be
> to get the timing stuff right (can't be off doing something else while a new
> message is waiting to be read).
> 
> All suggestions on architecture and methodology greatly appreciated by this
> Python newbie.

We could answer you better if you could also tell us:

1. Why you've ruled out a single-threaded program (if you did).
2. How frequently you poll.
3. Roughly what kinds of interesting things you do with the results.  
   How time consuming are they?
4. What platforms do you want this to work on?


If this is just big mobile radio ping (in other words, if you never
poll except when the user requests it), then I'd just make it
single-threaded.  I'd say this is the best option for getting the
timing right.  You might want to open the serial ports in exclusive
mode (if your platform has that kind of thing) so two invocations
can't try to poll at once.

If the polling is done automatically, and rather often, I would
probably make it multithreaded, and use the Queue module to hand off
raw serial port data to the thread that does interesting things
with it.

How you would do interprocess communication is highly system dependent
and depends on how much data we're talking about.


-- 
CARL BANKS




More information about the Python-list mailing list