eive-tmtc/eive_tmtc/tmtc/common.py

33 lines
903 B
Python
Raw Normal View History

2022-05-27 11:53:57 +02:00
from typing import Union
2022-03-22 19:29:55 +01:00
from spacepackets.ecss.tc import PusTelecommand
2023-11-10 19:23:06 +01:00
from tmtccmd.tmtc import DefaultPusQueueHelper
from tmtccmd.pus.s200_fsfw_mode import pack_mode_data, Mode, Subservice
2022-10-04 14:46:00 +02:00
from tmtccmd.util import ObjectIdU32
2022-03-22 19:29:55 +01:00
2022-10-04 14:46:00 +02:00
def pack_mode_cmd_with_info(
object_id: Union[ObjectIdU32, bytes],
2023-01-16 15:05:33 +01:00
mode: Union[int, Mode],
2022-05-27 11:53:57 +02:00
submode: int,
2022-08-08 16:32:18 +02:00
q: DefaultPusQueueHelper,
2022-05-27 11:53:57 +02:00
info: str,
2022-03-22 19:29:55 +01:00
):
2022-10-04 14:46:00 +02:00
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")
2022-07-04 17:59:09 +02:00
q.add_log_cmd(info)
2022-03-22 19:29:55 +01:00
mode_data = pack_mode_data(
2022-10-04 14:46:00 +02:00
object_id=object_id_bytes,
2022-03-22 19:29:55 +01:00
mode=mode,
submode=submode,
)
2022-07-04 17:59:09 +02:00
q.add_pus_tc(
PusTelecommand(
2023-01-17 11:10:52 +01:00
service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=mode_data
2022-07-04 17:59:09 +02:00
)
2022-03-22 19:29:55 +01:00
)