From d69d16c3affb4f6801b2189e6874c8a1236ca7b7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Jan 2024 15:38:01 +0100 Subject: [PATCH 1/5] add latchup status report handling --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 54 ++++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index cffd273..62973a1 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -6,6 +6,7 @@ @author J. Meier @date 10.07.2021 """ +from datetime import datetime import enum import logging import struct @@ -42,14 +43,14 @@ MANUAL_INPUT = "1" HARDCODED_FILE = "/home/rmueller/EIVE/mpsoc_boot.bin" UPDATE_FILE_DICT = { - HARDCODED: ["hardcoded", ""], - MANUAL_INPUT: ["manual input", ""], - "2": ["/mnt/sd0/ploc/mpsoc/image.bin", "/mnt/sd0/ploc/mpsoc/image.bin"], + HARDCODED: ("hardcoded", ""), + MANUAL_INPUT: ("manual input", ""), + "2": ("/mnt/sd0/ploc/mpsoc/image.bin", "/mnt/sd0/ploc/mpsoc/image.bin"), } EVENT_BUFFER_PATH_DICT = { - MANUAL_INPUT: ["manual input", ""], - "2": ["/mnt/sd0/ploc/supervisor", "/mnt/sd0/ploc/supervisor"], + MANUAL_INPUT: ("manual input", ""), + "2": ("/mnt/sd0/ploc/supervisor", "/mnt/sd0/ploc/supervisor"), } @@ -149,7 +150,6 @@ class OpCode: class Info(str, enum.Enum): - value: str OFF = "Switch Off" ON = "Switch On" NML = "Switch Normal" @@ -766,6 +766,8 @@ def handle_supv_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper): handle_adc_report(hk_data) elif set_id == SetId.COUNTERS_REPORT: handle_counters_report(hk_data) + elif set_id == SetId.LATCHUP_REPORT: + handle_latchup_status_report(hk_data) else: pw.dlog(f"PLOC SUPV: HK handling not implemented for set ID {set_id}") pw.dlog(f"Raw Data: 0x[{hk_data.hex(sep=',')}]") @@ -907,3 +909,43 @@ def handle_counters_report(hk_data: bytes): print(f"MM task lost: {mm_task_lost}") print(f"HK task lost: {hk_task_lost}") print(f"DL task lost: {dl_task_lost}") + + +def handle_latchup_status_report(hk_data: bytes): + # 1 byte ID, 7 times 2 bytes of counts, and 8 bytes of time. + if len(hk_data) < 23: + raise ValueError("Latchup status report smaller than expected") + current_idx = 0 + id = hk_data[current_idx] + current_idx += 1 + counts_of_alerts = [] + for _ in range(7): + counts_of_alerts.append( + struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + ) + current_idx += 2 + print(f"ID: {id}") + print(f"Counts of alerts: {counts_of_alerts}") + time_ms = struct.unpack("!H", hk_data[current_idx : current_idx + 2])[0] + current_idx += 2 + time_seconds = hk_data[current_idx] + current_idx += 1 + time_minutes = hk_data[current_idx] + current_idx += 1 + time_hour = hk_data[current_idx] + current_idx += 1 + time_day = hk_data[current_idx] + current_idx += 1 + time_month = hk_data[current_idx] + current_idx += 1 + time_year = hk_data[current_idx] + dt = datetime( + year=time_year, + month=time_month, + day=time_day, + hour=time_hour, + minute=time_minutes, + second=time_seconds, + microsecond=time_ms * 1000, + ) + print(f"Time Now: {dt}") From 5e3b60b3af1b6ba688d7ddba4e740f6dfbed5fe1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Jan 2024 15:56:03 +0100 Subject: [PATCH 2/5] cleaned up PLOC SUPV a bit --- CHANGELOG.md | 6 + eive_tmtc/tmtc/payload/ploc_supervisor.py | 134 ++++++++-------------- 2 files changed, 53 insertions(+), 87 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 416b2ce..0d723b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ list yields a list of all related PRs for each release. # [unreleased] +# [v6.0.0] 2024-01-31 + +## Changed + +- Added new PLOC SUPV commands to test sets, cleaned up PLOC SUPV commanding. + # [v5.13.0] 2024-01-30 ## Added diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 62973a1..3227006 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -134,19 +134,24 @@ class OpCode: ON = "on" NORMAL = "nml" HK_TO_OBC = "hk_to_obc" - REQUEST_HK_SET_FROM_DEV = "req_hk_from_dev" - REQUEST_HK_SET = "req_hk" + REQUEST_GENERIC_HK_SET = "req_generic_hk" START_MPSOC = "start_mpsoc" SHUTDOWN_MPSOC = "stop_mpsoc" SEL_NVM = "sel_nvm" SET_TIME_REF = "set_time_ref" FACTORY_FLASH = "factory_flash" - REQ_BOOT_STATUS_REPORT = "boot_report" START_UPDATE = "start_update" PERFORM_UPDATE = "update" FACTORY_RESET = "factory_reset" MEM_CHECK = "mem_check" RESET_MPSOC = "reset_mpsoc" + SET_GPIO = "set_gpio" + READ_GPIO = "read_gpio" + READ_STATUS_REPORT = "read_hk_set" + READ_BOOT_STATUS_REPORT = "boot_report" + READ_LATCHUP_STATUS_REPORT = "read_latchup_status_report" + READ_ADC_STATUS_REPORT = "read_adc_status_report" + READ_COUNTERS_REPORT = "read_counters_report" class Info(str, enum.Enum): @@ -154,17 +159,22 @@ class Info(str, enum.Enum): ON = "Switch On" NML = "Switch Normal" HK_TO_OBC = "Request HK from PLOC SUPV" - REQUEST_HK_SET_FROM_DEV = "Request HK set from the device to the PLOC Handler" - REQUEST_HK_SET = "Request HK set from PLOC Handler" + REQUEST_GENERIC_HK_SET = "Request prompted HK set from PLOC Handler" SET_TIME_REF = "Set time reference" FACTORY_FLASH = "Factory Flash Mode" PERFORM_UPDATE = "Start or continue MPSoC SW update at starting bytes" START_UPDATE = "Start new MPSoC SW update" FACTORY_RESET = "Factory Reset of loggers" - REQ_BOOT_STATUS_REPORT = "Request boot status report and HK" MEM_CHECK = "Memory Check" SEL_NVM = "Select NVM" RESET_MPSOC = "Reset MPSoC" + SET_GPIO = "Set GPIO" + READ_GPIO = "Read GPIO" + READ_STATUS_REPORT = "Read HK status report" + READ_LATCHUP_STATUS_REPORT = "Read Latchup status report" + READ_BOOT_STATUS_REPORT = "Read boot status report" + READ_ADC_STATUS_REPORT = "Read ADC status report" + READ_COUNTERS_REPORT = "Read Data Logger counters report" @tmtc_definitions_provider @@ -174,8 +184,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add(OpCode.ON, Info.ON) oce.add(OpCode.NORMAL, Info.NML) oce.add(OpCode.HK_TO_OBC, Info.HK_TO_OBC) - oce.add(OpCode.REQUEST_HK_SET, Info.REQUEST_HK_SET) - oce.add(OpCode.REQUEST_HK_SET_FROM_DEV, Info.REQUEST_HK_SET_FROM_DEV) + oce.add(OpCode.REQUEST_GENERIC_HK_SET, Info.REQUEST_GENERIC_HK_SET) oce.add(OpCode.START_MPSOC, "PLOC Supervisor: Start MPSoC") oce.add(OpCode.SHUTDOWN_MPSOC, "PLOC Supervisor: Shutdown MPSoC") oce.add(OpCode.SEL_NVM, Info.SEL_NVM) @@ -184,11 +193,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add(OpCode.RESET_MPSOC, Info.RESET_MPSOC) oce.add("8", "PLOC Supervisor: Set max restart tries") oce.add("11", "PLOC Supervisor: Set boot timeout") - oce.add("12", "PLOC Supervisor: Disable Hk") - oce.add(OpCode.REQ_BOOT_STATUS_REPORT, Info.REQ_BOOT_STATUS_REPORT) - oce.add("17", "PLOC Supervisor: Enable latchup alert") - oce.add("18", "PLOC Supervisor: Disable latchup alert") - oce.add("20", "PLOC Supervisor: Set alert limit") + oce.add(OpCode.READ_BOOT_STATUS_REPORT, Info.READ_BOOT_STATUS_REPORT) oce.add("23", "PLOC Supervisor: Set ADC enabled channels") oce.add("24", "PLOC Supervisor: Set ADC window and stride") oce.add("25", "PLOC Supervisor: Set ADC threshold") @@ -196,26 +201,26 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add("27", "PLOC Supervisor: Copy ADC data to MRAM") oce.add("30", "PLOC Supervisor: Run auto EM tests") oce.add("31", "PLOC Supervisor: MRAM Wipe") - oce.add("35", "PLOC Supervisor: Set GPIO") - oce.add("36", "PLOC Supervisor: Read GPIO") + oce.add(OpCode.SET_GPIO, Info.SET_GPIO) + oce.add(OpCode.READ_GPIO, Info.READ_GPIO) oce.add("37", "PLOC Supervisor: Restart supervisor") oce.add(OpCode.PERFORM_UPDATE, Info.PERFORM_UPDATE) oce.add(OpCode.START_UPDATE, Info.START_UPDATE) oce.add("43", "PLOC Supervisor: Terminate supervisor process") - oce.add("44", "PLOC Supervisor: Start MPSoC quiet") oce.add("45", "PLOC Supervisor: Set shutdown timeout") oce.add(OpCode.FACTORY_FLASH, Info.FACTORY_FLASH) - oce.add("47", "PLOC Supervisor: Enable auto TM") - oce.add("48", "PLOC Supervisor: Disable auto TM") - oce.add("51", "PLOC Supervisor: Logging request event buffers") oce.add("52", "PLOC Supervisor: Logging clear counters") oce.add("53", "PLOC Supervisor: Logging set topic") - oce.add("54", "PLOC Supervisor: Logging request counters") - oce.add("55", "PLOC Supervisor: Request ADC Report") oce.add("56", "PLOC Supervisor: Reset PL") oce.add("57", "PLOC Supervisor: Enable NVMs") oce.add("58", "PLOC Supervisor: Continue update") oce.add(OpCode.MEM_CHECK, Info.MEM_CHECK) + + oce.add(OpCode.READ_STATUS_REPORT, Info.READ_STATUS_REPORT) + oce.add(OpCode.READ_ADC_STATUS_REPORT, Info.READ_ADC_STATUS_REPORT) + oce.add(OpCode.READ_LATCHUP_STATUS_REPORT, Info.READ_LATCHUP_STATUS_REPORT) + oce.add(OpCode.READ_BOOT_STATUS_REPORT, Info.READ_BOOT_STATUS_REPORT) + oce.add(OpCode.READ_COUNTERS_REPORT, Info.READ_COUNTERS_REPORT) defs.add_service(CustomServiceList.PLOC_SUPV.value, "PLOC Supervisor", oce) @@ -244,15 +249,16 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 q.add_log_cmd(f"{prefix}: {Info.HK_TO_OBC}") command = obyt + struct.pack("!I", SupvActionId.REQUEST_HK_REPORT) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == OpCode.REQUEST_HK_SET: - q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK_SET}") + if op_code == OpCode.REQUEST_GENERIC_HK_SET: + q.add_log_cmd(f"{prefix}: {Info.REQUEST_GENERIC_HK_SET}") sid = make_sid(object_id.as_bytes, prompt_set_id()) cmd = generate_one_hk_command(sid) q.add_pus_tc(cmd) - if op_code == OpCode.REQUEST_HK_SET_FROM_DEV: - q.add_log_cmd(f"{prefix}: {Info.REQUEST_HK_SET_FROM_DEV}") + if op_code == OpCode.READ_STATUS_REPORT: + q.add_log_cmd(f"{prefix}: {Info.READ_STATUS_REPORT}") set_id = prompt_set_id() action_cmd = None + # First read the set from the device. if set_id == SetId.HK_REPORT: action_cmd = create_action_cmd(PLOC_SUPV_ID, SupvActionId.REQUEST_HK_REPORT) if set_id == SetId.ADC_REPORT: @@ -263,6 +269,20 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 action_cmd = create_action_cmd( PLOC_SUPV_ID, SupvActionId.REQUEST_LOGGING_COUNTERS ) + if set_id == SetId.LATCHUP_REPORT: + action_cmd = create_action_cmd( + PLOC_SUPV_ID, SupvActionId.GET_LATCHUP_STATUS_REPORT + ) + if set_id == SetId.BOOT_STATUS_REPORT: + action_cmd = create_action_cmd( + PLOC_SUPV_ID, SupvActionId.GET_BOOT_STATUS_REPORT + ) + q.add_wait_seconds(2.0) + + # Now dump the HK set. + sid = make_sid(object_id.as_bytes, set_id) + req_hk = generate_one_hk_command(sid) + q.add_pus_tc(req_hk) assert action_cmd is not None q.add_pus_tc(action_cmd) elif op_code == OpCode.START_MPSOC: @@ -324,28 +344,6 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 + struct.pack("!I", boot_timeout) ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "12": - q.add_log_cmd("PLOC Supervisor: Disable HK") - command = object_id.as_bytes + struct.pack("!I", SupvActionId.DISABLE_HK) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code in OpCode.REQ_BOOT_STATUS_REPORT: - q.add_log_cmd(f"{prefix}: {Info.REQ_BOOT_STATUS_REPORT}") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionId.GET_BOOT_STATUS_REPORT - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - q.add_wait_seconds(2.0) - sid = make_sid(object_id.as_bytes, SetId.BOOT_STATUS_REPORT) - req_hk = generate_one_hk_command(sid) - q.add_pus_tc(req_hk) - if op_code == "17": - q.add_log_cmd("PLOC Supervisor: Enable latchup alert") - command = pack_lachtup_alert_cmd(object_id.as_bytes, True) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "18": - q.add_log_cmd("PLOC Supervisor: Disable latchup alert") - command = pack_lachtup_alert_cmd(object_id.as_bytes, False) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code == "20": q.add_log_cmd("PLOC Supervisor: Set alert limit") command = pack_set_alert_limit_cmd(object_id.as_bytes) @@ -362,31 +360,15 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 q.add_log_cmd("PLOC Supervisor: Set ADC threshold") command = pack_set_adc_threshold_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "26": - q.add_log_cmd("PLOC Supervisor: Request latchup status report") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionId.GET_LATCHUP_STATUS_REPORT - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "27": - q.add_log_cmd("PLOC Supervisor: Copy ADC data to MRAM") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionId.COPY_ADC_DATA_TO_MRAM - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "30": - q.add_log_cmd("PLOC Supervisor: Run auto EM tests") - command = pack_auto_em_tests_cmd(object_id.as_bytes) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code == "31": q.add_log_cmd("PLOC Supervisor: Wipe MRAM") command = pack_mram_wipe_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "35": + if op_code == OpCode.SET_GPIO: q.add_log_cmd("PLOC Supervisor: Set GPIO command") command = pack_set_gpio_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "36": + if op_code == OpCode.READ_GPIO: q.add_log_cmd("PLOC Supervisor: Read GPIO command") command = pack_read_gpio_cmd(object_id.as_bytes) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) @@ -422,40 +404,18 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 q.add_log_cmd(f"{prefix}: {Info.FACTORY_FLASH}") command = object_id.as_bytes + struct.pack("!I", SupvActionId.FACTORY_FLASH) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "47": - q.add_log_cmd("PLOC Supervisor: Enable auto TM") - command = object_id.as_bytes + struct.pack("!I", SupvActionId.ENABLE_AUTO_TM) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "48": - q.add_log_cmd("PLOC Supervisor: Disable auto TM") - command = object_id.as_bytes + struct.pack("!I", SupvActionId.DISABLE_AUTO_TM) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "51": - q.add_log_cmd("PLOC Supervisor: Logging request event buffers") - command = pack_logging_buffer_request(object_id.as_bytes) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code == "52": q.add_log_cmd("PLOC Supervisor: Logging clear counters") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.LOGGING_CLEAR_COUNTERS ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "53": - q.add_log_cmd("PLOC Supervisor: Logging set topic") - command = pack_logging_set_topic(object_id.as_bytes) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code == "54": q.add_log_cmd("PLOC Supervisor: Logging request counters") command = object_id.as_bytes + struct.pack( "!I", SupvActionId.REQUEST_LOGGING_COUNTERS ) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) - if op_code == "55": - q.add_log_cmd("PLOC Supervisor: Request ADC report") - command = object_id.as_bytes + struct.pack( - "!I", SupvActionId.REQUEST_ADC_REPORT - ) - q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command)) if op_code == "56": q.add_log_cmd("PLOC Supervisor: Reset PL") command = object_id.as_bytes + struct.pack("!I", SupvActionId.RESET_PL) From c6b2edf688694b5232596576dc5a1b105d4f7fa6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Jan 2024 15:58:43 +0100 Subject: [PATCH 3/5] removed old commands --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 3227006..c360566 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -147,11 +147,7 @@ class OpCode: RESET_MPSOC = "reset_mpsoc" SET_GPIO = "set_gpio" READ_GPIO = "read_gpio" - READ_STATUS_REPORT = "read_hk_set" - READ_BOOT_STATUS_REPORT = "boot_report" - READ_LATCHUP_STATUS_REPORT = "read_latchup_status_report" - READ_ADC_STATUS_REPORT = "read_adc_status_report" - READ_COUNTERS_REPORT = "read_counters_report" + READ_STATUS_REPORT = "read_status_report" class Info(str, enum.Enum): @@ -171,10 +167,6 @@ class Info(str, enum.Enum): SET_GPIO = "Set GPIO" READ_GPIO = "Read GPIO" READ_STATUS_REPORT = "Read HK status report" - READ_LATCHUP_STATUS_REPORT = "Read Latchup status report" - READ_BOOT_STATUS_REPORT = "Read boot status report" - READ_ADC_STATUS_REPORT = "Read ADC status report" - READ_COUNTERS_REPORT = "Read Data Logger counters report" @tmtc_definitions_provider @@ -193,7 +185,7 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add(OpCode.RESET_MPSOC, Info.RESET_MPSOC) oce.add("8", "PLOC Supervisor: Set max restart tries") oce.add("11", "PLOC Supervisor: Set boot timeout") - oce.add(OpCode.READ_BOOT_STATUS_REPORT, Info.READ_BOOT_STATUS_REPORT) + oce.add(OpCode.READ_STATUS_REPORT, Info.READ_STATUS_REPORT) oce.add("23", "PLOC Supervisor: Set ADC enabled channels") oce.add("24", "PLOC Supervisor: Set ADC window and stride") oce.add("25", "PLOC Supervisor: Set ADC threshold") @@ -216,11 +208,6 @@ def add_ploc_supv_cmds(defs: TmtcDefinitionWrapper): oce.add("58", "PLOC Supervisor: Continue update") oce.add(OpCode.MEM_CHECK, Info.MEM_CHECK) - oce.add(OpCode.READ_STATUS_REPORT, Info.READ_STATUS_REPORT) - oce.add(OpCode.READ_ADC_STATUS_REPORT, Info.READ_ADC_STATUS_REPORT) - oce.add(OpCode.READ_LATCHUP_STATUS_REPORT, Info.READ_LATCHUP_STATUS_REPORT) - oce.add(OpCode.READ_BOOT_STATUS_REPORT, Info.READ_BOOT_STATUS_REPORT) - oce.add(OpCode.READ_COUNTERS_REPORT, Info.READ_COUNTERS_REPORT) defs.add_service(CustomServiceList.PLOC_SUPV.value, "PLOC Supervisor", oce) From f93f713b0e601f80949361e9b59565dc0d6ab83c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Jan 2024 16:49:54 +0100 Subject: [PATCH 4/5] some minor bugfixes --- eive_tmtc/pus_tm/hk_handler.py | 2 ++ eive_tmtc/tmtc/payload/ploc_supervisor.py | 37 ++++++++++++++--------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/eive_tmtc/pus_tm/hk_handler.py b/eive_tmtc/pus_tm/hk_handler.py index 949d165..5c55b96 100644 --- a/eive_tmtc/pus_tm/hk_handler.py +++ b/eive_tmtc/pus_tm/hk_handler.py @@ -1,6 +1,7 @@ """HK Handling for EIVE OBSW""" import dataclasses import logging +import base64 # noqa from typing import List from eive_tmtc.tmtc.acs.acs_ctrl import handle_acs_ctrl_hk_data @@ -70,6 +71,7 @@ def handle_hk_packet( hk_data = tm_packet.tm_data[8:] if named_obj_id in hk_filter.object_ids: + # print(f"PUS TM Base64: {base64.b64encode(raw_tm)}") handle_regular_hk_print( printer=printer, object_id=named_obj_id, diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index c360566..10032fd 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -264,14 +264,16 @@ def pack_ploc_supv_commands(p: ServiceProviderParams): # noqa C901 action_cmd = create_action_cmd( PLOC_SUPV_ID, SupvActionId.GET_BOOT_STATUS_REPORT ) - q.add_wait_seconds(2.0) - + if action_cmd is None: + _LOGGER.warning(f"invalid set ID {set_id!r} for PLOC SUPV") + return # Now dump the HK set. sid = make_sid(object_id.as_bytes, set_id) req_hk = generate_one_hk_command(sid) + q.add_pus_tc(action_cmd) + q.add_wait_seconds(2.0) q.add_pus_tc(req_hk) assert action_cmd is not None - q.add_pus_tc(action_cmd) elif op_code == OpCode.START_MPSOC: q.add_log_cmd("PLOC Supervisor: Start MPSoC") command = obyt + struct.pack("!I", SupvActionId.START_MPSOC) @@ -885,14 +887,21 @@ def handle_latchup_status_report(hk_data: bytes): current_idx += 1 time_month = hk_data[current_idx] current_idx += 1 - time_year = hk_data[current_idx] - dt = datetime( - year=time_year, - month=time_month, - day=time_day, - hour=time_hour, - minute=time_minutes, - second=time_seconds, - microsecond=time_ms * 1000, - ) - print(f"Time Now: {dt}") + # Is stored as years since 1900. + time_year = 1900 + hk_data[current_idx] + try: + dt = datetime( + year=time_year, + month=time_month, + day=time_day, + hour=time_hour, + minute=time_minutes, + second=time_seconds, + microsecond=time_ms * 1000, + ) + print(f"Time Now: {dt}") + except ValueError: + print( + f"Time: {time_day}.{time_month}.{time_year}T" + f"{time_hour}:{time_minutes}:{time_seconds}.{time_ms}" + ) From 248df1d4df8ca9fb877b550586623385b3e7e6e5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 31 Jan 2024 16:57:59 +0100 Subject: [PATCH 5/5] added missing field parsing --- eive_tmtc/tmtc/payload/ploc_supervisor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eive_tmtc/tmtc/payload/ploc_supervisor.py b/eive_tmtc/tmtc/payload/ploc_supervisor.py index 10032fd..93e7095 100644 --- a/eive_tmtc/tmtc/payload/ploc_supervisor.py +++ b/eive_tmtc/tmtc/payload/ploc_supervisor.py @@ -861,8 +861,8 @@ def handle_counters_report(hk_data: bytes): def handle_latchup_status_report(hk_data: bytes): - # 1 byte ID, 7 times 2 bytes of counts, and 8 bytes of time. - if len(hk_data) < 23: + # 1 byte ID, 7 times 2 bytes of counts, and 8 bytes of time and 1 byte sync status. + if len(hk_data) < 24: raise ValueError("Latchup status report smaller than expected") current_idx = 0 id = hk_data[current_idx] @@ -889,6 +889,9 @@ def handle_latchup_status_report(hk_data: bytes): current_idx += 1 # Is stored as years since 1900. time_year = 1900 + hk_data[current_idx] + current_idx += 1 + is_synced = hk_data[current_idx] + print(f"Time Sync Status: {is_synced}") try: dt = datetime( year=time_year,