eive-tmtc/eive_tmtc/tmtc/common.py
2022-11-29 16:53:29 +01:00

33 lines
908 B
Python

from typing import Union
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices
from tmtccmd.util import ObjectIdU32
def pack_mode_cmd_with_info(
object_id: Union[ObjectIdU32, bytes],
mode: Union[int, Modes],
submode: int,
q: DefaultPusQueueHelper,
info: str,
):
if isinstance(object_id, ObjectIdU32):
object_id_bytes = object_id.as_bytes
elif isinstance(object_id, bytes):
object_id_bytes = object_id
else:
raise ValueError("Invalid Object ID type")
q.add_log_cmd(info)
mode_data = pack_mode_data(
object_id=object_id_bytes,
mode=mode,
submode=submode,
)
q.add_pus_tc(
PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=mode_data
)
)