bit parsing from file
rewonka at gmail.com
rewonka at gmail.com
Wed Jun 4 18:55:12 EDT 2008
On May 30, 9:16 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
> On Thu, 29 May 2008 09:37:54 -0700 (PDT), "rewo... at gmail.com"
> <rewo... at gmail.com> 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
> wlfr... at ix.netcom.com wulfr... at bestiaria.com
> HTTP://wlfraed.home.netcom.com/
> (Bestiaria Support Staff: web-a... at bestiaria.com)
> 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
More information about the Python-list
mailing list