69 lines
2.0 KiB
Python
69 lines
2.0 KiB
Python
import struct
|
|
|
|
from eive_tmtc.pus_tc.devs.bpx_batt import BpxSetId
|
|
from eive_tmtc.pus_tm.defs import PrintWrapper
|
|
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
|
|
|
|
|
HEADER_LIST = [
|
|
"Charge Current",
|
|
"Discharge Current",
|
|
"Heater Current",
|
|
"Battery Voltage",
|
|
"Batt Temp 1",
|
|
"Batt Temp 2",
|
|
"Batt Temp 3",
|
|
"Batt Temp 4",
|
|
"Reboot Counter",
|
|
"Boot Cause",
|
|
]
|
|
|
|
|
|
def handle_bpx_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
|
|
pw = PrintWrapper(printer)
|
|
if set_id == BpxSetId.GET_HK_SET:
|
|
fmt_str = "!HHHHhhhhIB"
|
|
inc_len = struct.calcsize(fmt_str)
|
|
(
|
|
charge_current,
|
|
discharge_current,
|
|
heater_current,
|
|
batt_voltage,
|
|
batt_temp_1,
|
|
batt_temp_2,
|
|
batt_temp_3,
|
|
batt_temp_4,
|
|
reboot_cntr,
|
|
boot_cause,
|
|
) = struct.unpack(fmt_str, hk_data[0:inc_len])
|
|
content_list = [
|
|
charge_current,
|
|
discharge_current,
|
|
heater_current,
|
|
batt_voltage,
|
|
batt_temp_1,
|
|
batt_temp_2,
|
|
batt_temp_3,
|
|
batt_temp_4,
|
|
reboot_cntr,
|
|
boot_cause,
|
|
]
|
|
validity_buffer = hk_data[inc_len:]
|
|
pw.dlog(str(HEADER_LIST))
|
|
pw.dlog(str(content_list))
|
|
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
|
|
elif set_id == BpxSetId.GET_CFG_SET:
|
|
battheat_mode = hk_data[0]
|
|
battheat_low = struct.unpack("!b", hk_data[1:2])[0]
|
|
battheat_high = struct.unpack("!b", hk_data[2:3])[0]
|
|
header_list = [
|
|
"Battery Heater Mode",
|
|
"Battery Heater Low Limit",
|
|
"Battery Heater High Limit",
|
|
]
|
|
content_list = [battheat_mode, battheat_low, battheat_high]
|
|
validity_buffer = hk_data[3:]
|
|
pw.dlog(str(header_list))
|
|
pw.dlog(str(content_list))
|
|
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
|