def __call__(self, buf): print lib.hexdump(buf) pkt = Packet.fromBuffer(buf) """ stamp = time.time( ) dt = datetime.fromtimestamp(stamp).replace(tzinfo=self.args.timezone) msg = lib.hexdump(buf) rssi = buf[0:2] rfpacket = buf[2:] record = dict(date=stamp , dateString=dt.isoformat( ) , rfpacket=str(rfpacket).encode('hex') , head=str(rssi).encode('hex') , serial=str(rfpacket[1:4]).encode('hex') , op=str(rfpacket[0:1]).encode('hex') , payload=str(rfpacket[4:]).encode('hex') , decocare_hex=msg ) # print """ if pkt.valid: print pkt return pkt if self.args.stream: self.args.out.write(self.formatter(record)) self.args.out.flush() else: self.data.append(record)
def generate(self, strict=False, **kwds): self.start() link = self.link while not self.done(): count = link.received() if count < 1: # print "sleeping" log.info('sleeping {}'.format(.150)) self.sleep() else: if self.verbosity > 0: print datetime.now().isoformat(), "count:", count for buf in link.dump_rx_buffer(): pkt = Packet.fromBuffer(buf) if strict: if pkt.valid: yield pkt else: yield pkt
def generate(self, strict=False, **kwds): self.start() link = self.link while not self.done(): count = link.received() if count < 1: # print "sleeping" log.info("sleeping {}".format(0.150)) self.sleep() else: if self.verbosity > 0: print datetime.now().isoformat(), "count:", count for buf in link.dump_rx_buffer(): pkt = Packet.fromBuffer(buf) if strict: if pkt.valid: yield pkt else: yield pkt