2022-05-19 13:20:22 +02:00
|
|
|
import struct
|
|
|
|
|
2023-01-16 14:13:06 +01:00
|
|
|
from eive_tmtc.pus_tc.devs.bpx_batt import BpxSetId
|
2022-11-29 16:53:29 +01:00
|
|
|
from eive_tmtc.pus_tm.defs import PrintWrapper
|
2022-07-08 16:25:46 +02:00
|
|
|
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
2022-05-19 13:20:22 +02:00
|
|
|
|
|
|
|
|
2022-12-02 16:13:18 +01:00
|
|
|
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",
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2022-05-19 13:20:22 +02:00
|
|
|
def handle_bpx_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
|
|
|
|
pw = PrintWrapper(printer)
|
2023-01-16 14:13:06 +01:00
|
|
|
if set_id == BpxSetId.GET_HK_SET:
|
2022-05-19 13:20:22 +02:00
|
|
|
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:]
|
2022-12-02 16:13:18 +01:00
|
|
|
pw.dlog(str(HEADER_LIST))
|
2022-05-19 13:20:22 +02:00
|
|
|
pw.dlog(str(content_list))
|
|
|
|
printer.print_validity_buffer(validity_buffer=validity_buffer, num_vars=10)
|
2023-01-16 14:13:06 +01:00
|
|
|
elif set_id == BpxSetId.GET_CFG_SET:
|
2022-05-19 13:20:22 +02:00
|
|
|
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)
|