Exemple #1
 def record(self, packet):
     # make sure packet doesn't exist first
     if packet in self.packets:
         raise ValueError("This packet has already been recorded in the history.")
     # Attempt to delete from history only if we are removing from queue
     if self.packets[0] is not None:
         del self[self.packets[0].request.header.id]
     # Add new packet to history
     self[packet.request.header.id] = (IPBusConstruct.build(packet.request), IPBusConstruct.build(packet.response))
Exemple #2
 def __init__(self, blob):
     self.request = None
     self.response = None
     self._raw = blob
     # if little-endian, we need to swap when reading and writing
     self.littleendian = bool((ord(self._raw[0])&0xf0)>>4 == 0xf)
     # do some flipping
     raw = self.raw
     if self.littleendian: raw = byteswap(raw)
     self.request = IPBusConstruct.parse(raw)
     self.response = IPBusConstruct.parse(raw)