I am developing a Python application, which reads bytes from a serial
port (using pySerial).
Those bytes combine into packets by means of a non-trivial set of rules.
Using a chain of generators, I implemented the rules in a
straightforward way. A generator reads bytes from the serial port,
processes escape sequences and yields the resulting characters to
another generator. The next generator delimits packets and yields each
packet as a unicode string. The final generator parses the unicode
strings and yields the parse results for each frame as a data structure
(a Dict, whose elements are the various packet fields).
However, the ultimate input of the generators needs to be from the
serial port.
The question: do I have to use a separate thread for reading bytes from
the serial port (by means of the first generator in chain) and then use
some complicated mechanism for transferring the yielded data structures
to another thread?
The reads in such a case would be blocking reads.
Or is there another idiom for feeding data for processing by a chain of
generators, which can relieve me from having to use a separate thread?
--- Omer
--
Every good master plan involves building a time machine. Moshe Zadka
My own blog is at http://www.zak.co.il/tddpirate/
My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
_______________________________________________
Python-il mailing list
[email protected]
http://hamakor.org.il/cgi-bin/mailman/listinfo/python-il