Working with binary data, S-records (long)

Hans-Joachim Widmaier hjwidmaier at web.de
Fri Mar 21 13:29:17 CET 2003


Steven Taschuk <staschuk at telusplanet.net> wrote in message news:<mailman.1048222319.32043.python-list at python.org>...

> It would be nice to see a small sample of the input as well.

Those are just ordinary S-records, usually 16 Bytes of data per line:

S2140C06B06F2E630053657254784D626F7820213D1F
S2140C06C0204E554C4C00436F6D52784D626F78201F
S2140C06D0213D204E554C4C00436F6D54784D626F47

> Bug!  You test self.checkcs later, not self.check.

Well spotted, thanks!
 
> >     def readrecord(self, line):
>  [...]
> >         elif type in ('S3', 'S7'):
> >             adr = (long(data[0]) << 24) + (data[2] << 16) \
> >                   + (data[3] << 8) + data[4]
> 
> Bug?  data[0] and not data[1]?

Bug! Thanks again. This class isn't well tested -- I did it more to
see if it made any sense.

> On my 233 MHz machine your code can process about 2500 records a
> second (with some made-up records which might not be realistic).
> Would that be acceptable performance?

That translates to about 6 or 7 seconds for a typical image. With
slower machines I'd say 10 seconds. Maybe a bit annoying, but then,
that program might be left running. So it would have to read it only
once on startup, making this point almost moot.

As that other guy (Greg Ewing? Sorry, Google somehow hides this
thread) suggested, I'll also give array a try. And would you believe
that I somehow managed to not stumble across the binascii module? I
should have learnt by now to *first* search through the included
batteries, erm, modules.

Many thanks to both of you,
Hans-Joachim




More information about the Python-list mailing list