eive-tmtc/eive_tmtc/pus_tc/devs/gps.py

49 lines
1.4 KiB
Python
Raw Normal View History

2021-09-08 13:20:22 +02:00
import enum
2022-11-29 16:53:29 +01:00
from eive_tmtc.config.definitions import CustomServiceList
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
from tmtccmd.config.tmtc import tmtc_definitions_provider
2022-08-08 16:32:18 +02:00
from tmtccmd.tc import DefaultPusQueueHelper
2022-05-24 01:34:33 +02:00
from tmtccmd.tc.pus_3_fsfw_hk import make_sid, generate_one_hk_command
from tmtccmd.logging import get_console_logger
2021-09-08 13:20:22 +02:00
2022-05-24 01:34:33 +02:00
LOGGER = get_console_logger()
2021-09-08 13:20:22 +02:00
2022-05-24 01:34:33 +02:00
2023-01-16 14:13:06 +01:00
class OpCode:
2022-05-24 01:34:33 +02:00
REQ_OS_HK = ["0", "hk-os"]
RESET_GNSS = ["5", "reset"]
class Info:
REQ_OS_HK = "Request One-Shot HK"
RESET_GNSS = "Reset GNSS using reset pin"
2023-01-16 14:13:06 +01:00
class SetId:
2022-05-24 01:34:33 +02:00
HK = 0
@tmtc_definitions_provider
def add_gps_cmds(defs: TmtcDefinitionWrapper):
2022-07-05 02:12:54 +02:00
oce = OpCodeEntry()
2023-01-16 14:13:06 +01:00
oce.add(keys=OpCode.RESET_GNSS, info=Info.RESET_GNSS)
oce.add(keys=OpCode.REQ_OS_HK, info=Info.REQ_OS_HK)
2022-07-05 02:12:54 +02:00
defs.add_service(
2022-05-24 01:34:33 +02:00
name=CustomServiceList.GPS_CTRL.value,
2022-05-25 10:37:38 +02:00
info="GPS/GNSS Controller",
2022-07-05 02:12:54 +02:00
op_code_entry=oce,
2022-05-24 01:34:33 +02:00
)
2021-09-08 13:20:22 +02:00
2022-08-08 16:32:18 +02:00
def pack_gps_command(object_id: bytes, q: DefaultPusQueueHelper, op_code: str):
2023-01-16 14:13:06 +01:00
if op_code in OpCode.RESET_GNSS:
2022-05-24 01:49:57 +02:00
# TODO: This needs to be re-implemented
LOGGER.warning("Reset pin handling needs to be re-implemented")
2023-01-16 14:13:06 +01:00
if op_code in OpCode.REQ_OS_HK:
2022-07-04 17:59:09 +02:00
q.add_log_cmd(f"GMSS: {Info.REQ_OS_HK}")
q.add_pus_tc(
2023-01-16 14:13:06 +01:00
generate_one_hk_command(sid=make_sid(object_id=object_id, set_id=SetId.HK))
2022-05-25 10:37:38 +02:00
)