def find_records(stream, opts): records = [] errors = [] bolus = bytearray() extra = bytearray() opcode = '' for B in iter(lambda: bytearray(stream.read(2)), bytearray("")): if B == bytearray([0x00, 0x00]): print("#### STOPPING DOUBLE NULLS @ %s," % stream.tell()), nulls = eat_nulls(stream) print "reading more to debug %#04x" % B[0] print lib.hexdump(B, indent=4) print lib.int_dump(B, indent=11) extra = bytearray(stream.read(32)) print "##### DEBUG HEX" print lib.hexdump(extra, indent=4) print "##### DEBUG DECIMAL" print lib.int_dump(extra, indent=11) # print "XXX:???:XXX", history.parse_date(bolus).isoformat( ) break record = parse_record(stream, B, larger=opts.larger) records.append(record) return records
def find_records(stream, opts): records = [ ] errors = [ ] bolus = bytearray( ) extra = bytearray( ) opcode = '' for B in iter(lambda: bytearray(stream.read(2)), bytearray("")): if B == bytearray( [ 0x00, 0x00 ] ): print ("#### STOPPING DOUBLE NULLS @ %s," % stream.tell( )), nulls = eat_nulls(stream) print "reading more to debug %#04x" % B[0] print lib.hexdump(B, indent=4) print lib.int_dump(B, indent=11) extra = bytearray(stream.read(32)) print "##### DEBUG HEX" print lib.hexdump(extra, indent=4) print "##### DEBUG DECIMAL" print lib.int_dump(extra, indent=11) # print "XXX:???:XXX", history.parse_date(bolus).isoformat( ) break record = parse_record( stream, B, larger=opts.larger ) records.append(record) return records
def find_records (self, page, larger=None): if larger is None: larger = int(self.pump.model.getData( )[1:]) > 22 stream = io.BytesIO(page) records = [ ] print "SINCE", self.since.isoformat( ) for B in iter(lambda: bytearray(stream.read(2)), bytearray("")): if B == bytearray( [ 0x00, 0x00 ] ): break record = parse_record( stream, B, larger=larger ) data = record.decode( ) print " * found record", record, record.datetime if record.datetime: if record.datetime < self.since: self.enough_history = True records.append(record) if record.datetime > self.since: self.records.append(record) return records