split up p60 hk set

This commit is contained in:
Robin Müller 2022-04-07 12:51:47 +02:00
parent 25bab108df
commit ab5cca85bf
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
2 changed files with 137 additions and 126 deletions

View File

@ -31,10 +31,11 @@ class GomspaceOpCodes:
class SetIds:
PDU_1 = 0x01
PDU_2 = 0x02
P60_DOCK = 0x03
ACU = 0x04
PDU_1 = 1
PDU_2 = 2
P60_CORE = 3
P60_AUX = 4
ACU = 5
class TableIds:

View File

@ -13,6 +13,7 @@ from tmtccmd.tm.service_3_fsfw_housekeeping import (
from tmtccmd.logging import get_console_logger
from pus_tc.devs.bpx_batt import BpxSetIds
from pus_tc.devs.syrlinks_hk_handler import SetIds
from pus_tc.devs.p60dock import SetIds
from pus_tc.devs.imtq import ImtqSetIds
from tmtccmd.pus.obj_id import ObjectId, ObjectIdDictT
from config.object_ids import (
@ -23,7 +24,7 @@ from config.object_ids import (
BPX_HANDLER_ID,
CORE_CONTROLLER_ID,
P60_DOCK_HANDLER,
PL_PCDU_ID
PL_PCDU_ID,
)
LOGGER = get_console_logger()
@ -429,7 +430,9 @@ P60_INDEX_LIST = [
WDT_LIST = ["GND", "I2C", "CAN", "CSP0", "CSP1"]
def handle_p60_hk_data(printer: FsfwTmTcPrinter, hk_data: bytes):
def handle_p60_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
if set_id == SetIds.P60_CORE:
log_to_both(printer, "P60 Core HK")
current_idx = 0
current_list = []
for idx in range(13):
@ -456,60 +459,52 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, hk_data: bytes):
f"{P60_INDEX_LIST[idx].ljust(24)} | {out_enb} | "
f"{voltage_list[idx]:05} | {current_list[idx]:04}"
)
print(content_line)
printer.file_logger.info(content_line)
fmt_str = "!hhIIIhBBB"
log_to_both(printer, content_line)
fmt_str = "!IBhHhh"
inc_len = struct.calcsize(fmt_str)
(
temp0,
temp1,
boot_cause,
boot_count,
uptime,
reset_cause,
batt_mode,
heater_on,
conv_5v_on,
batt_current,
batt_voltage,
temp_0,
temp_1,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
util_info = (
f"Batt Mode {batt_mode} | Boot Count {boot_count} | Heater On {heater_on}"
batt_info = (
f"Batt Mode {batt_mode} | Boot Count {boot_count} | "
f"Batt: Current {batt_current} | Volt {batt_voltage}"
)
util_info2 = (
f"Reset Cause {reset_cause} | Boot Cause {boot_cause} | Uptime {uptime} | "
f"Conv 5V on {conv_5v_on}"
)
print(util_info)
print(util_info2)
printer.file_logger.info(util_info)
printer.file_logger.info(util_info2)
temps = f"In C: Temp 0 {temp_0 / 10.0} | Temp 1 {temp_1 / 10.0} | "
log_to_both(printer, temps)
log_to_both(printer, batt_info)
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=9)
if set_id == SetIds.P60_AUX:
log_to_both(printer, "P60 AUX HK")
current_idx = 0
latchup_list = []
for idx in range(0, 13):
latchup_list.append(
struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0]
)
content_line = f"{P60_INDEX_LIST[idx].ljust(24)} | {latchup_list[idx]}"
log_to_both(printer, content_line)
current_idx += 2
fmt_str = "!HhhHhh"
fmt_str = "!IIHBBHHhhB"
inc_len = struct.calcsize(fmt_str)
(
boot_cause,
uptime,
reset_cause,
heater_on,
conv_5v_on,
dock_vbat,
dock_vcc_current,
batt_current,
batt_voltage,
dock_vcc_c,
batt_temp_0,
batt_temp_1,
dearm_status,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
device_types = []
device_statuses = []
for idx in range(8):
device_types.append(hk_data[current_idx])
current_idx += 1
for idx in range(8):
device_statuses.append(hk_data[current_idx])
current_idx += 1
dearm_status = hk_data[current_idx]
current_idx += 1
wdt_reboots_list = []
for idx in range(5):
wdt_reboots_list.append(
@ -525,16 +520,32 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, hk_data: bytes):
for idx in range(2):
time_pings_left_list.append(hk_data[current_idx])
current_idx += 1
batt_charge_current = struct.unpack("!h", hk_data[current_idx : current_idx + 2])[0]
current_idx += 2
batt_discharge_current = struct.unpack(
"!h", hk_data[current_idx : current_idx + 2]
)[0]
current_idx += 2
ant6_depl_status = struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0]
fmt_str = "!hhbb"
inc_len = struct.calcsize(fmt_str)
(
batt_charge_current,
batt_discharge_current,
ant6_depl,
ar6_depl,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
device_types = []
device_statuses = []
for idx in range(8):
device_types.append(hk_data[current_idx])
current_idx += 1
ar6_depl_status = struct.unpack("!b", hk_data[current_idx : current_idx + 1])[0]
for idx in range(8):
device_statuses.append(hk_data[current_idx])
current_idx += 1
util_info = (
f"Reset Cause {reset_cause} | Boot Cause {boot_cause} | Uptime {uptime}"
)
util_info_2 = (
f"Conv 5V on {conv_5v_on} | Heater On {heater_on} | "
f"Dock VBAT {dock_vbat} | DOCK VCC Current {dock_vcc_c}"
)
log_to_both(printer, util_info)
log_to_both(printer, util_info_2)
wdt_info = "WDT Type | Reboots | Time or Pings left (CSP only)"
log_to_both(printer, wdt_info)
for idx in range(len(wdt_reboots_list)):
@ -543,19 +554,18 @@ def handle_p60_hk_data(printer: FsfwTmTcPrinter, hk_data: bytes):
f"{WDT_LIST[idx].ljust(5)} | "
f"{wdt_reboots_list[idx]:010} | {time_pings_left_list[idx]:010}",
)
temps = (
f"In C: Temp 0 {temp0 / 10.0} | Temp 1 {temp1 / 10.0} | "
f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0}"
misc_info = (
f"Dearm {dearm_status} | ANT6 Depl {ant6_depl} | AR6 Deply {ar6_depl}"
)
log_to_both(printer, misc_info)
batt_info = (
f"Batt: Current {batt_current} | Volt {batt_voltage} | "
f"Batt Temp 0 {batt_temp_0 / 10.0} | Batt Temp 1 {batt_temp_1 / 10.0}"
f"Charge Current {batt_charge_current} | Discharge Current {batt_discharge_current}"
)
log_to_both(printer, temps)
log_to_both(printer, batt_info)
misc_info = f"Dearm {dearm_status} | ANT6 Depl {ant6_depl_status} | AR6 Deply {ar6_depl_status}"
log_to_both(printer, misc_info)
printer.print_validity_buffer(validity_buffer=hk_data[current_idx:], num_vars=36)
printer.print_validity_buffer(
validity_buffer=hk_data[current_idx:], num_vars=27
)
def log_to_both(printer: FsfwTmTcPrinter, string: str):