is there a problem on this simple code

jrlen balane nbbalane at gmail.com
Tue Mar 15 04:26:00 EST 2005


rx_data = ser.read(19)
byte[] = unpack('19B', rx_data)
    
    for k in range(9):
        if byte[k] == 70
            if byte[k+2] == 6
                if byte[k+9] ==
-(byte[k]+byte[k+1]+byte[k+2]+byte[k+3]+byte[k+4]+byte[k+5]+byte[k+6]+byte[k+7]+byte[k+8])
& 0xff
                    print byte[k:k+9]
====================================
what i am doing here is creating an array from based on the unpacked data
then i am searching for the array member that is equal to "70" since
it is going to be my reference. once i find it, i'll based my received
data from that point. then if the succeding tests are confirmed, i can
get my data.

please help....(again) :(


On Tue, 15 Mar 2005 08:05:04 GMT, Dennis Lee Bieber
<wlfraed at ix.netcom.com> wrote:
> On 14 Mar 2005 17:04:13 -0800, "John Machin" <sjmachin at lexicon.net>
> declaimed the following in comp.lang.python:
> 
> >
> > jrlen balane wrote:
> > > @sir John
> > > could you please show me how to do this exactly? it's in the "tip of
> > > my toungue" but i just can get it, please...
> > >
> >
> > You've had far too much help already for a school project. Asking for
> > someone to write the code for you is "over the fence".
> 
>         The repetition /is/ getting tedious, isn't it...
> 
>         At the least, getting a formal definition of the protocol the
> microcontroller uses would be nice. If it is continuously sending "70"
> status reports, WITHOUT handshaking (RTS/CTS), then I'd strongly
> recommend making the reader code a separate thread -- hopefully one
> won't lose bytes during other processing. When a valid status report is
> found, put it onto a Queue, which the main code can read when ever it
> finds time.
> 
>         Heck, at this point in time... I'd remove everything involved
> with /sending/ commands. Start with coding something that only reads the
> status from the microcontroller (since it sounds like the controller is
> always sending). When the reader works correctly, then start trying to
> add the command writer.
> 
> --
>  > ============================================================== <
>  >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
>  >      wulfraed at dm.net     |       Bestiaria Support Staff       <
>  > ============================================================== <
>  >           Home Page: <http://www.dm.net/~wulfraed/>            <
>  >        Overflow Page: <http://wlfraed.home.netcom.com/>        <
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list