Exemplo n.º 1
0
        def reader_process():
            read_packets = []
            while len(read_packets) < len(test_packets):
                read = (yield from read_packet_from_stream(dut.output))
                read_packets.append(read)
                print([len(p) for p in read_packets])

            self.assertEqual(read_packets, test_packets)
Exemplo n.º 2
0
 def testbench():
     for i in range(3):
         packet_raw = (yield from read_packet_from_stream(dsi_protocol.output, timeout=1000, allow_pause=False, pause_after_word=3))
         rest = [x for word in packet_raw for x in [word & 0xff, word >> 8]]
         print("\n", rest)
         while rest:
             if short_packet := next((opt for opt in DsiShortPacketDataType if opt.value == rest[0]), None):
                 packet, rest = rest[:4], rest[4:]
                 print(f"{short_packet.name} \t {packet}")
                 continue
             elif long_packet := next((opt for opt in DsiLongPacketDataType if opt.value == rest[0]), None):
                 len_header = rest[1] | (rest[2] << 8)
                 packet, rest = rest[:len_header + 4 + 2], rest[len_header + 4 + 2:]
                 print(f"{long_packet.name} (len={len_header}) \t {packet}")
                 continue
             else:
                 raise TypeError(f"unknown packet: {rest}")
Exemplo n.º 3
0
 def reader():
     for packet in packets:
         self.assertEqual(packet, (yield from read_packet_from_stream(
             b.control_output, timeout=400)))
         self.assertEqual(packet, (yield from read_packet_from_stream(
             a.control_output, timeout=400)))