Merge pull request 'rtd command to rewrite config' (#125) from meier/rtd into main

Reviewed-on: #125
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
This commit is contained in:
Robin Müller 2023-01-19 16:49:22 +01:00
commit f3c0b7567a

View File

@ -1,4 +1,5 @@
from typing import Optional
import struct
from eive_tmtc.config.definitions import CustomServiceList
from eive_tmtc.pus_tc.devs.pdec_handler import CommandId
@ -32,18 +33,22 @@ RTD_IDS = [
]
class CommandId:
WRITE_CONFIG = 6
class OpCode:
ON = ["0", "on"]
OFF = ["1", "off"]
NORMAL = ["2", "normal"]
CONFIG_CMD = ["3", "Write config"]
WRITE_CONFIG = ["3", "Write config"]
class Info:
ON = "Switch handler on"
OFF = "Switch handler off"
NORMAL = "Switch handler normal"
WIRTE_CONFIG = "Write config"
WRITE_CONFIG = "Write config"
@tmtc_definitions_provider
@ -52,6 +57,7 @@ def specify_rtd_cmds(defs: TmtcDefinitionWrapper):
oce.add(keys=OpCode.ON, info=Info.ON)
oce.add(keys=OpCode.NORMAL, info=Info.NORMAL)
oce.add(keys=OpCode.OFF, info=Info.OFF)
oce.add(keys=OpCode.WRITE_CONFIG, info=Info.WRITE_CONFIG)
defs.add_service(
name=CustomServiceList.RTD.value, info="RTD commands", op_code_entry=oce
)
@ -92,8 +98,8 @@ def pack_rtd_commands(
service=200, subservice=Subservice.TC_MODE_COMMAND, app_data=app_data
)
)
if op_code in OpCode.CONFIG_CMD:
command = object_id.as_bytes + CommandId.PRINT_CLCW
if op_code in OpCode.WRITE_CONFIG:
command = object_id.as_bytes + struct.pack('!I', CommandId.WRITE_CONFIG)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))