Skip to content
Snippets Groups Projects
Commit 76f02201 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-676: Split off packet parsing tests, add one for read_packet.

parent f2d826b5
No related branches found
No related tags found
1 merge request!266L2SS-676: Support parsing beamlet packets
...@@ -543,6 +543,9 @@ def main(args=None, **kwargs): ...@@ -543,6 +543,9 @@ def main(args=None, **kwargs):
# read the packet from input # read the packet from input
packet = read_packet(sys.stdin.buffer.read) packet = read_packet(sys.stdin.buffer.read)
if not packet:
break
# print header # print header
print(f"# Packet {nr} of class {packet.__class__.__name__} starting at offset {offset} with length {packet.size()}") print(f"# Packet {nr} of class {packet.__class__.__name__} starting at offset {offset} with length {packet.size()}")
pprint.pprint(packet.header()) pprint.pprint(packet.header())
......
...@@ -209,23 +209,3 @@ class TestXSTCollector(base.TestCase): ...@@ -209,23 +209,3 @@ class TestXSTCollector(base.TestCase):
self.assertEqual(0, collector.parameters["nof_valid_payloads"][fpga_index]) self.assertEqual(0, collector.parameters["nof_valid_payloads"][fpga_index])
self.assertEqual(1, collector.parameters["nof_payload_errors"][fpga_index]) self.assertEqual(1, collector.parameters["nof_payload_errors"][fpga_index])
class TestBeamletPacket(base.TestCase):
def test_valid_packet(self):
# a valid packet as obtained from SDP, with 4 samples for 488 beamlets
packet = b'b\x05\x00\x00\x00\x00\x03\x85\x11\n\x00\x00\x00\x00\x00\x80\x00\x00\x00\x04\x01\xe8\x14\x00\x00\x01$\x8dI\x9c\xac\x00' + (4*488) * b'\x00\x00\x00\x00'
# parse it
fields = BeamletPacket(packet)
# check some fields from the header
self.assertEqual(0, fields.payload_error)
self.assertEqual(8, fields.beamlet_width)
self.assertEqual(4, fields.nof_blocks_per_packet)
self.assertEqual(488, fields.nof_beamlets_per_block)
self.assertEqual(7840, fields.expected_size())
# check payload dimensions: 4 time slots of 488 beamlets, x/y, real/imag
self.assertEqual((4,488,2,2), fields.payload.shape)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment