On May 30, 9:16 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 29 May 2008 09:37:54 -0700 (PDT), "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > > Thank's for the reply, > > Yes, I have to search for the pattern, the bit offset not always the > > same. > > for another thing, it's ok if i can fill up with zero at the LSB or > > discard that byte. (the last byte not important) > > Sounds suspiciously like an HDLC protocol... > > You'll likely need to create a library that can extract the properly > aligned bytes by holding one -- properly shifted -- and fed the next > byte. > > In very loose pseudo-code > > detect bit offset > initialize extractor with first valid byte and offset > for inbyte in input: > outbyte = extract_feed(inbyte) > > where extract_feed() shifts the remainder (or first byte) left by the > offset (into a 16bit value), adds the new byte, ANDs with an 8-bit mask > with proper offset, returns left most result byte while also clearing > the remainder portion > -- > Wulfraed Dennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support Staff: [EMAIL PROTECTED]) > HTTP://www.bestiaria.com/
Thank you for your help, i will try to do something like that. I did some test about extracting byte with binascii, i will post it tomorow. Rew -- http://mail.python.org/mailman/listinfo/python-list