def dumpRawPackets(self, pkt_start=0, pkt_end=None, row_width=80, bytes_per_group=2, pkt_len=None, use_pager=True): if pkt_end == None: pkt_end = self.npkts_ if pkt_len: pkt_end = self.npkts_ if pkt_len == None: pkt_len = self.pkt_len_ genf = self._gen_hex_dump(self.raw_data_, pkt_start, pkt_len, row_width, bytes_per_group) res = StringIO() for i, line in enumerate(genf, pkt_start): if i < pkt_end: print >> res, 'pkt:' + str(i) + ' ' + line else: break if use_pager: _helpers.Pager(res.getvalue()) else: print res.getvalue()
def dumpPackets(self, pkt_start=0, pkt_end=None, payload_start=0, payload_end=40, raw_payload=False, header_only=False, use_pager=True): genf = self._gen_packet(self.raw_data_, pkt_start) if pkt_end == None: pkt_end = self.npkts_ res = StringIO() for i, pkt in enumerate(genf, pkt_start): if i < pkt_end: print >> res, 'Packet: ', str(i) print >> res, pkt.header_and_payload(payload_start, payload_end, header_only=header_only, raw=raw_payload) else: break if use_pager: _helpers.Pager(res.getvalue()) else: print res.getvalue()
def trackChanges(self, pkt_start=0, pkt_end=None, repeat_header=20, use_pager=True): genf = self._gen_packet(self.raw_data_, pkt_start) if pkt_end == None: pkt_end = self.npkts_ res = StringIO() keys = [ 'pkt', 'fsn', 'dmode', 'cplx', 'bps', 'freq', 'rate', 'ttv', 'timeslip' ] hdrs = [ 'PKT', 'SEQ', 'FMT', 'CPLX', 'BPS', ' FREQ ', ' CLK ', 'TIME VALID', 'TIME SLIP' ] hdr_fmt = '{pkt:^5s} {fsn:^5s} {dmode:^5s} {cplx:^4s} {bps:^5s} {freq:^12s} {rate:^12s} {ttv:^10s} {timeslip:^9s}' line_fmt = '{pkt:^5d} {fsn:^5s} {dmode:^5s} {cplx:^4s} {bps:^5s} {freq:^12s} {rate:^12s} {ttv:^10s} {timeslip:^9s}' last_pkt = None last_tstamp = None last_nsamps = 0 for i, pkt in enumerate(genf, pkt_start): if (i % repeat_header) == 0: print >> res, hdr_fmt.format(**dict(zip(keys, hdrs))) cmp_res = dict.fromkeys(keys, self._TRACK_OK_) if i == pkt_start: self._first_pkt(cmp_res, pkt) else: self._cmp_pkt(cmp_res, last_pkt, pkt, last_tstamp, last_nsamps) cmp_res['pkt'] = i dline = line_fmt.format(**cmp_res) print >> res, dline if pkt.get_ttv(): last_tstamp = pkt.get_SDDSTime() last_nsamp = 0 # keep running count of samples last_nsamps += pkt.get_samples_for_bps() last_pkt = pkt if use_pager: _helpers.Pager(res.getvalue()) else: print res.getvalue()