Merge branch 'main' into acs-ctrl-update

This commit is contained in:
Marius Eggert 2023-02-28 11:04:44 +01:00
commit 039eed1e16
7 changed files with 75 additions and 2 deletions

View File

@ -21,6 +21,10 @@ list yields a list of all related PRs for each release.
- Correction for ACS CTRL raw data requests HK type
- Fixed diag related ACS hk cmds
## Added
- Basic MGM commanding (modes)
# [v2.16.1] 2023-02-24
- Updated CSVs for new persistent TM store

View File

@ -37,6 +37,7 @@ class CustomServiceList(str, enum.Enum):
ACU = "acu"
ACS = "acs"
GYRO = "gyro"
MGMS = "mgms"
COM_SS = "com"
BPX_BATTERY = "bpx"
HEATER = "heater"

View File

@ -4,6 +4,7 @@ import logging
from typing import cast
from eive_tmtc.tmtc.acs.gyros import handle_gyr_cmd
from eive_tmtc.tmtc.acs.mgms import handle_mgm_cmd
from eive_tmtc.tmtc.power.power import pack_power_commands
from eive_tmtc.tmtc.tcs.rtd import pack_rtd_commands
from eive_tmtc.tmtc.payload.scex import pack_scex_cmds
@ -135,6 +136,8 @@ def handle_default_procedure(
return pack_single_rw_test_into(
object_id=RW4_ID, rw_idx=4, q=queue_helper, op_code=op_code
)
if service == CustomServiceList.MGMS.value:
return handle_mgm_cmd(q=queue_helper, op_code=op_code)
if service == CustomServiceList.RAD_SENSOR.value:
object_id = cast(ObjectIdU32, obj_id_man.get(RAD_SENSOR_ID))
return pack_rad_sensor_test_into(

View File

@ -2,7 +2,10 @@ import enum
import logging
import struct
from spacepackets.ecss import PusTelecommand
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_201_fsfw_health import pack_set_health_cmd_data, FsfwHealth
from tmtccmd.pus.s201_fsfw_health import Subservice
import eive_tmtc.config.object_ids as obj_ids
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode
@ -30,6 +33,7 @@ class OpCode:
OFF = "off"
CORE_HK = "core_hk"
CFG_HK = "cfg_hk"
SET_FAULTY = "set_faulty"
class AdisGyroSetId(enum.IntEnum):
@ -85,6 +89,15 @@ def handle_gyr_cmd(q: DefaultPusQueueHelper, op_code: str):
q.add_pus_tc(
create_request_one_hk_command(make_sid(gyr_obj_id, AdisGyroSetId.CFG_HK))
)
elif op_code == OpCode.SET_FAULTY:
q.add_log_cmd(f"Gyro {gyr_info[0]} set faulty")
q.add_pus_tc(
PusTelecommand(
service=201,
subservice=Subservice.TC_SET_HEALTH,
app_data=pack_set_health_cmd_data(object_id=gyr_obj_id, health=FsfwHealth.FAULTY)
)
)
else:
logging.getLogger(__name__).warning(
f"invalid op code {op_code} for gyro command"
@ -177,4 +190,5 @@ def add_gyr_cmd_defs(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCode.CFG_HK, info="Request CFG HK")
oce.add(keys=OpCode.NML, info="Normal Mode")
oce.add(keys=OpCode.OFF, info="Off Mode")
oce.add(keys=OpCode.SET_FAULTY, info="Set Faulty")
defs.add_service(CustomServiceList.GYRO, info="Gyro", op_code_entry=oce)

View File

@ -61,6 +61,7 @@ class ImtqSetId:
NEGATIVE_Y_TEST = 13
POSITIVE_Z_TEST = 14
NEGATIVE_Z_TEST = 15
SELF_TEST_SET = 16
class ImtqActionId:
@ -307,7 +308,7 @@ ENG_HK_HEADERS = [
def handle_imtq_hk(printer: FsfwTmTcPrinter, hk_data: bytes, set_id: int):
if (set_id >= ImtqSetId.POSITIVE_X_TEST) and (set_id <= ImtqSetId.NEGATIVE_Z_TEST):
if set_id == ImtqSetId.SELF_TEST_SET:
return handle_self_test_data(printer, hk_data)
elif set_id == ImtqSetId.ENG_HK_NO_TORQUE:
_LOGGER.info("Found engineering HK without torque")

View File

@ -1,13 +1,25 @@
import enum
import struct
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config import OpCodeEntry
import eive_tmtc.config.object_ids as obj_ids
from eive_tmtc.config.object_ids import MGM_0_LIS3_HANDLER_ID, MGM_1_RM3100_HANDLER_ID, MGM_2_LIS3_HANDLER_ID, MGM_3_RM3100_HANDLER_ID
from eive_tmtc.pus_tm.defs import PrintWrapper
from tmtccmd.config.tmtc import tmtc_definitions_provider, TmtcDefinitionWrapper
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, Mode
from tmtccmd.util import ObjectIdU32
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
class OpCode:
NORMAL = "normal"
OFF = "off"
class MgmLis3SetId(enum.IntEnum):
CORE_HK = 0
@ -16,6 +28,36 @@ class MgmRm3100SetId(enum.IntEnum):
CORE_HK = 0
class MgmSel(enum.IntEnum):
MGM_0_LIS3 = 0
MGM_1_RM3100 = 1
MGM_2_LIS3 = 2
MGM_3_RM3100 = 3
MGM_SEL_DICT = {
MgmSel.MGM_0_LIS3: ("MGM_0_LIS3", MGM_0_LIS3_HANDLER_ID),
MgmSel.MGM_1_RM3100: ("MGM_1_RM3100", MGM_1_RM3100_HANDLER_ID),
MgmSel.MGM_2_LIS3: ("MGM_2_LIS3", MGM_2_LIS3_HANDLER_ID),
MgmSel.MGM_3_RM3100: ("MGM_3_RM3100", MGM_3_RM3100_HANDLER_ID),
}
def handle_mgm_cmd(q: DefaultPusQueueHelper, op_code: str):
print("Please select the MGM Device")
for (k, v) in MGM_SEL_DICT.items():
print(f"{k}: {v[0]}")
sel_idx = int(input("Select MGM device by index: "))
mgm_info = MGM_SEL_DICT[MgmSel(sel_idx)]
mgm_obj_id = mgm_info[1]
if op_code == OpCode.NORMAL:
q.add_log_cmd(f"Gyro {mgm_info[0]} NORMAL mode")
q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.NORMAL, 0))
if op_code == OpCode.OFF:
q.add_log_cmd(f"Gyro {mgm_info[0]} OFF mode")
q.add_pus_tc(create_mode_command(mgm_obj_id, Mode.OFF, 0))
def handle_mgm_hk_data(
object_id: ObjectIdU32, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
@ -61,3 +103,11 @@ def handle_mgm_rm3100_hk_data(
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)
@tmtc_definitions_provider
def add_mgm_cmd_defs(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(keys=OpCode.NORMAL, info="Normal Mode")
oce.add(keys=OpCode.OFF, info="Off Mode")
defs.add_service(CustomServiceList.MGMS, info="MGMs", op_code_entry=oce)

View File

@ -45,7 +45,7 @@ class SetId(enum.IntEnum):
SWITCHER_SET = 0
class PcduSetIds:
class PcduSetIds(enum.IntEnum):
SWITCHER_SET = 0