added PLOC SUPV TM handling
All checks were successful
EIVE/-/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-11-28 12:43:30 +01:00
parent 1508acb7ae
commit 51227100af

View File

@ -10,18 +10,19 @@ import enum
import logging import logging
import struct import struct
from eive_tmtc.config.object_ids import PLOC_SUPV_ID, get_object_ids
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tm.defs import PrintWrapper
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.config import TmtcDefinitionWrapper from tmtccmd.config import TmtcDefinitionWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider, OpCodeEntry from tmtccmd.config.tmtc import OpCodeEntry, tmtc_definitions_provider
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
from tmtccmd.pus.s8_fsfw_action import create_action_cmd
from tmtccmd.pus.s200_fsfw_mode import Mode, pack_mode_data
from tmtccmd.pus.tc.s3_fsfw_hk import generate_one_hk_command, make_sid
from tmtccmd.tmtc import service_provider from tmtccmd.tmtc import service_provider
from tmtccmd.tmtc.decorator import ServiceProviderParams from tmtccmd.tmtc.decorator import ServiceProviderParams
from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode
from tmtccmd.pus.s8_fsfw_action import create_action_cmd from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter from eive_tmtc.config.object_ids import PLOC_SUPV_ID, get_object_ids
from eive_tmtc.pus_tm.defs import PrintWrapper
from eive_tmtc.utility.input_helper import InputHelper from eive_tmtc.utility.input_helper import InputHelper
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -130,9 +131,13 @@ class SupvActionId(enum.IntEnum):
MEM_CHECK = 61 MEM_CHECK = 61
class SetIds(enum.IntEnum): class SetId(enum.IntEnum):
HK_REPORT = 102 HK_REPORT = 102
BOOT_STATUS_REPORT = 103 BOOT_STATUS_REPORT = 103
LATCHUP_REPORT = 104
COUNTERS_REPORT = 105
ADC_REPORT = 106
UPDATE_STATUS_REPORT = 107
class OpCodes: class OpCodes:
@ -249,7 +254,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code in OpCodes.REQUEST_HK: if op_code in OpCodes.REQUEST_HK:
q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK}") q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK}")
sid = make_sid(object_id.as_bytes, SetIds.HK_REPORT) sid = make_sid(object_id.as_bytes, SetId.HK_REPORT)
cmd = generate_one_hk_command(sid) cmd = generate_one_hk_command(sid)
q.add_pus_tc(cmd) q.add_pus_tc(cmd)
elif op_code in OpCodes.START_MPSOC: elif op_code in OpCodes.START_MPSOC:
@ -322,7 +327,7 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901
) )
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
q.add_wait_seconds(2.0) q.add_wait_seconds(2.0)
sid = make_sid(object_id.as_bytes, SetIds.BOOT_STATUS_REPORT) sid = make_sid(object_id.as_bytes, SetId.BOOT_STATUS_REPORT)
req_hk = generate_one_hk_command(sid) req_hk = generate_one_hk_command(sid)
q.add_pus_tc(req_hk) q.add_pus_tc(req_hk)
if op_code == "17": if op_code == "17":
@ -731,62 +736,150 @@ class SocState(enum.IntEnum):
def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper): def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
current_idx = 0 if set_id == SetId.HK_REPORT:
if set_id == SetIds.HK_REPORT: handle_hk_report(hk_data, pw)
fmt_str = "!IIIQIIIIIBBBB" elif set_id == SetId.BOOT_STATUS_REPORT:
inc_len = struct.calcsize(fmt_str) handle_boot_report(hk_data, pw)
( elif set_id == SetId.ADC_REPORT:
temp_ps, handle_adc_report(hk_data)
temp_pl, elif set_id == SetId.COUNTERS_REPORT:
temp_sup, handle_counters_report(hk_data)
uptime,
cpu_load,
avail_heap,
num_tcs,
num_tms,
soc_state,
nvm_0_1_state,
nvm_3_state,
mission_io_state,
fmc_state,
) = struct.unpack(fmt_str, hk_data[:inc_len])
pw.dlog(f"Temp PS {temp_ps} C | Temp PL {temp_pl} C | Temp SUP {temp_sup} C")
pw.dlog(f"Uptime {uptime} | CPU Load {cpu_load} | Avail Heap {avail_heap}")
pw.dlog(f"Number TCs {num_tcs} | Number TMs {num_tms}")
pw.dlog(f"SOC state {SocState(soc_state)}")
pw.dlog(f"NVM 01 State {nvm_0_1_state}")
pw.dlog(f"NVM 3 State {nvm_3_state}")
pw.dlog(f"Mission IO state {mission_io_state}")
pw.dlog(f"FMC state {fmc_state}")
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[inc_len:], 13))
elif set_id == SetIds.BOOT_STATUS_REPORT:
fmt_str = "!BBIIBBBBBB"
inc_len = struct.calcsize(fmt_str)
(
soc_state,
power_cycles,
boot_after_ms,
boot_timeout_ms,
active_nvm,
bp_0_state,
bp_1_state,
bp_2_state,
boot_state,
boot_cycles,
) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
current_idx += inc_len
pw.dlog(
"SoC state (0:off, 1:booting, 2:update, 3:operating, 4:shutdown, 5:reset):"
f" {soc_state}"
)
pw.dlog(f"Power Cycles {power_cycles}")
pw.dlog(f"Boot after {boot_after_ms} ms | Boot timeout {boot_timeout_ms} ms")
pw.dlog(f"Active NVM: {active_nvm}")
pw.dlog(
f"BP0 State {bp_0_state} | BP1 State {bp_1_state} | BP2 State {bp_2_state}"
)
pw.dlog(f"Boot State {boot_state} | Boot Cycles {boot_cycles}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 10)
else: else:
pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}") pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}")
pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]") pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]")
def handle_hk_report(hk_data: bytes, pw: PrintWrapper):
fmt_str = "!IIIQIIIIIBBBB"
inc_len = struct.calcsize(fmt_str)
(
temp_ps,
temp_pl,
temp_sup,
uptime,
cpu_load,
avail_heap,
num_tcs,
num_tms,
soc_state,
nvm_0_1_state,
nvm_3_state,
mission_io_state,
fmc_state,
) = struct.unpack(fmt_str, hk_data[:inc_len])
pw.dlog(f"Temp PS {temp_ps} C | Temp PL {temp_pl} C | Temp SUP {temp_sup} C")
pw.dlog(f"Uptime {uptime} | CPU Load {cpu_load} | Avail Heap {avail_heap}")
pw.dlog(f"Number TCs {num_tcs} | Number TMs {num_tms}")
pw.dlog(f"SOC state {SocState(soc_state)}")
pw.dlog(f"NVM 01 State {nvm_0_1_state}")
pw.dlog(f"NVM 3 State {nvm_3_state}")
pw.dlog(f"Mission IO state {mission_io_state}")
pw.dlog(f"FMC state {fmc_state}")
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[inc_len:], 13))
def handle_boot_report(hk_data: bytes, pw: PrintWrapper):
current_idx = 0
fmt_str = "!BBIIBBBBBB"
inc_len = struct.calcsize(fmt_str)
(
soc_state,
power_cycles,
boot_after_ms,
boot_timeout_ms,
active_nvm,
bp_0_state,
bp_1_state,
bp_2_state,
boot_state,
boot_cycles,
) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
current_idx += inc_len
pw.dlog(
"SoC state (0:off, 1:booting, 2:update, 3:operating, 4:shutdown, 5:reset):"
f" {soc_state}"
)
pw.dlog(f"Power Cycles {power_cycles}")
pw.dlog(f"Boot after {boot_after_ms} ms | Boot timeout {boot_timeout_ms} ms")
pw.dlog(f"Active NVM: {active_nvm}")
pw.dlog(f"BP0 State {bp_0_state} | BP1 State {bp_1_state} | BP2 State {bp_2_state}")
pw.dlog(f"Boot State {boot_state} | Boot Cycles {boot_cycles}")
FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], 10)
def handle_adc_report(hk_data: bytes):
if len(hk_data) < 64:
_LOGGER.warning("ADC report smaller than 64 bytes")
current_idx = 0
adc_raw = []
adc_eng = []
for _ in range(16):
adc_raw.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0])
current_idx += 2
for _ in range(16):
adc_eng.append(struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0])
current_idx += 2
print(f"ADC RAW: {adc_raw}")
print(f"ADC ENG: {adc_eng}")
def handle_counters_report(hk_data: bytes):
current_idx = 0
signature = struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
current_idx += 4
latchup_counters = []
for _ in range(7):
latchup_counters.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
fmt_str = "!IIIIIIIIIIIIIIIIIIII"
inc_len = struct.calcsize(fmt_str)
(
adc_deviation_triggers_cnt,
tc_received_cnt,
tm_available_cnt,
supervisor_boots,
mpsoc_boots,
mpsoc_boot_failed_attempts,
mpsoc_powerup,
mpsoc_updates,
mpsoc_heartbeat_resets,
cpu_wdt_resets,
ps_heartbeats_lost,
pl_heartbeats_lost,
eb_task_lost,
bm_task_lost,
lm_task_lost,
am_task_lost,
tctmm_task_lost,
mm_task_lost,
hk_task_lost,
dl_task_lost,
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
current_idx += inc_len
_redwire_tasks_lost = []
for _ in range(3):
_redwire_tasks_lost.append(
struct.unpack("!I", hk_data[current_idx : current_idx + 4])[0]
)
print(f"Signature: {signature}")
print(f"Latchup Counters: {latchup_counters}")
print(f"ADC Deviation Triggers Count: {adc_deviation_triggers_cnt}")
print(f"TCs received: {tc_received_cnt} | TMs Available: {tm_available_cnt}")
print(f"Supervisor Boots: {supervisor_boots} | MPSoC boots: {mpsoc_boots}")
print(f"MPSoC boot failed attempts: {mpsoc_boot_failed_attempts}")
print(f"MPSoC powerup: {mpsoc_powerup}")
print(f"MPSoC updates: {mpsoc_updates}")
print(f"MPSoC heartbeat resets: {mpsoc_heartbeat_resets}")
print(f"CPU WDT resets: {cpu_wdt_resets}")
print(f"PS heartbeats lost: {ps_heartbeats_lost}")
print(f"PL heartbeats lost: {pl_heartbeats_lost}")
print(f"EB task lost: {eb_task_lost}")
print(f"BM task lost: {bm_task_lost}")
print(f"LM task lost: {lm_task_lost}")
print(f"AM task lost: {am_task_lost}")
print(f"TCTMM task lost: {tctmm_task_lost}")
print(f"MM task lost: {mm_task_lost}")
print(f"HK task lost: {hk_task_lost}")
print(f"DL task lost: {dl_task_lost}")