add time dump command

This commit is contained in:
Robin Müller 2023-02-01 19:13:59 +01:00
parent bf06dd70f4
commit fa23e05971
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
4 changed files with 74 additions and 44 deletions

View File

@ -10,6 +10,10 @@ list yields a list of all related PRs for each release.
# [unreleased] # [unreleased]
## Added
- Add time dump command
# [v2.8.0] 2023-01-01 # [v2.8.0] 2023-01-01
- Move all device modules inside `pus_tc` and `pus_tm` to `tmtc` module and respective - Move all device modules inside `pus_tc` and `pus_tm` to `tmtc` module and respective

View File

@ -104,22 +104,6 @@ def add_str_cmds(defs: TmtcDefinitionWrapper):
defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce) defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce)
@tmtc_definitions_provider
def add_time_cmds(defs: TmtcDefinitionWrapper):
from eive_tmtc.pus_tc.system.time import OpCode, Info
oce = OpCodeEntry()
oce.add(
keys=OpCode.SET_CURRENT_TIME,
info=Info.SET_CURRENT_TIME,
)
defs.add_service(
name=CustomServiceList.TIME.value,
info="Time Service",
op_code_entry=oce,
)
@tmtc_definitions_provider @tmtc_definitions_provider
def add_system_cmds(defs: TmtcDefinitionWrapper): def add_system_cmds(defs: TmtcDefinitionWrapper):
import eive_tmtc.pus_tc.system.controllers as controllers import eive_tmtc.pus_tc.system.controllers as controllers

View File

@ -1,28 +0,0 @@
import logging
from datetime import datetime
from eive_tmtc.config.definitions import CustomServiceList
from spacepackets.ecss import PusTelecommand
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
class OpCode:
SET_CURRENT_TIME = ["0", "set-curr-time"]
class Info:
SET_CURRENT_TIME = "Setting current time in ASCII format"
@service_provider(CustomServiceList.TIME.value)
def pack_set_current_time_ascii_command(p: ServiceProviderParams):
q = p.queue_helper
time_test_current_time = datetime.utcnow().isoformat() + "Z" + "\0"
current_time_ascii = time_test_current_time.encode("ascii")
logging.getLogger(__name__).info(
f"Current time in ASCII format: {current_time_ascii}"
)
q.add_log_cmd(Info.SET_CURRENT_TIME)
q.add_pus_tc(PusTelecommand(service=9, subservice=128, app_data=current_time_ascii))

70
eive_tmtc/tmtc/time.py Normal file
View File

@ -0,0 +1,70 @@
import enum
import logging
from datetime import datetime
from eive_tmtc.config.definitions import CustomServiceList
from spacepackets.ecss import PusTelecommand, PusService
from tmtccmd.config.tmtc import (
tmtc_definitions_provider,
TmtcDefinitionWrapper,
OpCodeEntry,
)
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
class Subservice(enum.IntEnum):
SET_TIME = 128
DUMP_TIME = 129
class OpCode:
SET_CURRENT_TIME = ["set_curr_time"]
DUMP_TIME = ["dump_time"]
class Info:
SET_CURRENT_TIME = "Setting current time in ASCII format"
DUMP_TIME = "Dump system time as event"
@service_provider(CustomServiceList.TIME.value)
def pack_set_current_time_ascii_command(p: ServiceProviderParams):
q = p.queue_helper
o = p.op_code
if o == OpCode.SET_CURRENT_TIME:
current_time = datetime.utcnow().isoformat() + "Z" + "\0"
current_time_ascii = current_time.encode("ascii")
logging.getLogger(__name__).info(
f"Current time in ASCII format: {current_time_ascii}"
)
q.add_log_cmd(Info.SET_CURRENT_TIME)
q.add_pus_tc(
PusTelecommand(
service=PusService.S9_TIME_MGMT,
subservice=Subservice.SET_TIME,
app_data=current_time_ascii,
)
)
elif o == OpCode.DUMP_TIME:
q.add_log_cmd(Info.DUMP_TIME)
q.add_pus_tc(
PusTelecommand(
service=PusService.S9_TIME_MGMT, subservice=Subservice.DUMP_TIME
)
)
@tmtc_definitions_provider
def add_time_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(
keys=OpCode.SET_CURRENT_TIME,
info=Info.SET_CURRENT_TIME,
)
defs.add_service(
name=CustomServiceList.TIME.value,
info="Time Service",
op_code_entry=oce,
)