Working with binary data, S-records (long)
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:
> Bug! You test self.checkcs later, not self.check.
Well spotted, thanks!
> > def readrecord(self, line):
> > elif type in ('S3', 'S7'):
> > adr = (long(data) << 24) + (data << 16) \
> > + (data << 8) + data
> Bug? data and not data?
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,
More information about the Python-list