how to read serial stream of data [newbie]
roy at panix.com
Tue Feb 7 06:07:36 CET 2012
<e84f3af4-da6d-4ae9-8974-54354ec16307 at b18g2000vbz.googlegroups.com>,
Jean Dupont <jeandupont115 at gmail.com> wrote:
> I'd like to read in a stream of data which looks like this:
> the device sends out a byte-string of 11 bytes roughly every second:
> As you see every string is ended by 0D8A
> How can this be accomplished in Python?
The basic idea would be to open your datastream in binary mode
(http://docs.python.org/library/functions.html#open), then use read(11)
to read exactly 11 bytes into a string.
Depending on what the 11 bytes are, you might want to use the struct
module (http://docs.python.org/library/struct.html) to extract the data
in a more useful form.
More information about the Python-list