|
| 1 | +from struct import Struct |
| 2 | +import binascii |
| 3 | +import struct |
| 4 | + |
| 5 | +# Data is a raw packet from framer |
| 6 | +data = b'D\x16\x98\x12\x00\x00\xe8\x03\x00\x00\x00\x00\xee\xee\xee\xeeUz\x8c\xbd\x00\xda\x1b?\xc6)\x19\xbe\xcd\xacF?\xc9\xb2\xc3\xb8\x0e\xe8\xc19.\x99\x108\x00\x00\x00\x00Uz\x8c\xbd\x00\xda\x1b?\xc6)\x19\xbe\xcd\xacF?\xc9\xb2\xc3\xb8\x0e\xe8\xc19.\x99\x108\x00\x00\x00\x00\x00\x00\x00\x00\xf0?\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0?' |
| 7 | + |
| 8 | +# The first two bytes of data represents the apid number |
| 9 | +apid_struct = Struct(f"<H") |
| 10 | +apid_num = int(apid_struct.unpack(data[0:2])[0]) |
| 11 | +# apid_num = 5700 |
| 12 | +print('apid num is', apid_num) |
| 13 | + |
| 14 | +# The next 6 bytes represent the SCLK timestamp |
| 15 | +date_parts_struct = Struct('<IH') |
| 16 | +nowtime = date_parts_struct.unpack(data[2:8]) |
| 17 | +ctime = float(nowtime[0]) + float(nowtime[1]/40000) |
| 18 | +print('sclk timestamp', ctime) |
| 19 | + |
| 20 | +# The remainder of the packet is the apid data specified by the tlmdb |
| 21 | +# Channel values are in the order specified by FswTlmDetail.csv |
| 22 | +apid_data_struct = Struct('<I4x7fI7f2B6d') |
| 23 | +channel_values = apid_data_struct.unpack(data[8:]) |
| 24 | +print('channel values', channel_values) |
| 25 | + |
| 26 | + |
| 27 | +# Command is CMD_TLM_SET_APID_FREQ - 100000 from cmd_master |
| 28 | +mnem = '100000' |
| 29 | +mnem = binascii.unhexlify(mnem) |
| 30 | +raw_command = struct.pack("<I", int.from_bytes(mnem, byteorder='big', signed=False)) |
| 31 | + |
| 32 | +# Now check the CmdDetail for the parameters. We have one 8 byte double and one 4 byte unsigned int for this one. |
| 33 | +raw_command += struct.pack("<dI", 1, 5700) |
| 34 | +print('raw_command', raw_command) |
| 35 | +# b'\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\xf0?D\x16\x00\x00' |
0 commit comments