def _parse_packets_v1_0(row, message_dset, *args, **kwargs): if row['type'] == 4: return TimestampPacket(row['timestamp']) if row['type'] == 5: index = row['counter'] message_row = message_dset[index] message = message_row['message'].decode() timestamp = row['timestamp'] return MessagePacket(message, timestamp) if row['type'] < 4: p = Packet_v1() p.chip_key = row['chip_key'] p.packet_type = row['type'] p.chipid = row['chipid'] p.parity_bit_value = row['parity'] if p.packet_type == Packet_v1.DATA_PACKET: p.channel = row['channel'] p.timestamp = row['timestamp'] p.dataword = row['adc_counts'] p.fifo_half_flag = row['fifo_half'] p.fifo_full_flag = row['fifo_full'] elif p.packet_type == Packet_v1.TEST_PACKET: p.counter = row['counter'] elif (p.packet_type == Packet_v1.CONFIG_WRITE_PACKET or p.packet_type == Packet_v1.CONFIG_READ_PACKET): p.register_address = row['register'] p.register_data = row['value'] p.direction = row['direction'] return p return None
def config_read_packet(): p = Packet_v1() p.packet_type = Packet_v1.CONFIG_READ_PACKET p.chipid = 123 p.register_address = 10 p.register_data = 23 p.assign_parity() p.chip_key = Key('1-2-123') p.direction = 1 return p
def data_packet(): p = Packet_v1() p.packet_type = Packet_v1.DATA_PACKET p.chipid = 123 p.channel = 7 p.timestamp = 123456 p.dataword = 120 p.fifo_half_flag = 1 p.assign_parity() p.chip_key = Key('1-2-123') p.direction = 1 return p
def test_to_file_v0_0_config_read_packet(tmpfile, config_read_packet): to_file(tmpfile, [config_read_packet], version='0.0') f = h5py.File(tmpfile, 'r') assert len(f['raw_packet']) == 1 row = f['raw_packet'][0] props = dtype_property_index_lookup['0.0']['raw_packet'] new_packet = Packet_v1() new_packet.chip_key = row[props['chip_key']] new_packet.packet_type = row[props['type']] new_packet.chipid = row[props['chipid']] new_packet.parity_bit_value = row[props['parity']] new_packet.register_address = row[props['register']] new_packet.register_data = row[props['value']] assert new_packet == config_read_packet
def test_to_file_v0_0_data_packet(tmpfile, data_packet): to_file(tmpfile, [data_packet], version='0.0') f = h5py.File(tmpfile, 'r') assert len(f['raw_packet']) == 1 row = f['raw_packet'][0] props = dtype_property_index_lookup['0.0']['raw_packet'] new_packet = Packet_v1() new_packet.chip_key = row[props['chip_key']] new_packet.packet_type = row[props['type']] new_packet.chipid = row[props['chipid']] new_packet.parity_bit_value = row[props['parity']] new_packet.channel = row[props['channel']] new_packet.timestamp = row[props['timestamp']] new_packet.dataword = row[props['adc_counts']] new_packet.fifo_half_flag = row[props['fifo_half']] new_packet.fifo_full_flag = row[props['fifo_full']] assert new_packet == data_packet