move bpx cmd defs
This commit is contained in:
parent
4bf3e2e5e2
commit
5745973d3d
@ -1,5 +1,3 @@
|
||||
from eive_tmtc.pus_tc.devs.bpx_batt import BpxOpCodes
|
||||
|
||||
from eive_tmtc.config.definitions import CustomServiceList
|
||||
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry, CoreServiceList
|
||||
from tmtccmd.config.tmtc import (
|
||||
@ -121,23 +119,6 @@ def add_str_cmds(defs: TmtcDefinitionWrapper):
|
||||
defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce)
|
||||
|
||||
|
||||
@tmtc_definitions_provider
|
||||
def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys=BpxOpCodes.HK, info="Request BPX HK")
|
||||
oce.add(keys=BpxOpCodes.RST_BOOT_CNT, info="Reset Boot Count")
|
||||
oce.add(keys=BpxOpCodes.REQUEST_CFG, info="Request Configuration Struct (Step 1)")
|
||||
oce.add(
|
||||
keys=BpxOpCodes.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)"
|
||||
)
|
||||
oce.add(keys=BpxOpCodes.REBOOT, info="Reboot Command")
|
||||
defs.add_service(
|
||||
name=CustomServiceList.BPX_BATTERY.value,
|
||||
info="BPX Battery Handler",
|
||||
op_code_entry=oce,
|
||||
)
|
||||
|
||||
|
||||
@tmtc_definitions_provider
|
||||
def add_time_cmds(defs: TmtcDefinitionWrapper):
|
||||
from eive_tmtc.pus_tc.system.time import OpCodes, Info
|
||||
|
@ -1,9 +1,18 @@
|
||||
from spacepackets.ecss import PusTelecommand
|
||||
|
||||
from eive_tmtc.config.definitions import CustomServiceList
|
||||
from eive_tmtc.config.object_ids import BPX_HANDLER_ID
|
||||
from tmtccmd.config.tmtc import (
|
||||
tmtc_definitions_provider,
|
||||
TmtcDefinitionWrapper,
|
||||
OpCodeEntry,
|
||||
)
|
||||
from tmtccmd.tc import service_provider
|
||||
from tmtccmd.tc.decorator import ServiceProviderParams
|
||||
from tmtccmd.tc.pus_8_funccmd import make_fsfw_action_cmd
|
||||
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid
|
||||
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes
|
||||
from tmtccmd.tc.pus_200_fsfw_modes import Subservices as ModeSubservices
|
||||
|
||||
|
||||
class BpxSetIds:
|
||||
@ -20,12 +29,33 @@ class BpxActionIds:
|
||||
|
||||
class BpxOpCodes:
|
||||
HK = ["0", "hk"]
|
||||
OFF = ["off"]
|
||||
ON = ["on"]
|
||||
RST_BOOT_CNT = ["1", "rst_boot_cnt"]
|
||||
REQUEST_CFG = ["2", "cfg"]
|
||||
REQUEST_CFG_HK = ["3", "cfg_hk"]
|
||||
REBOOT = ["4", "reboot"]
|
||||
|
||||
|
||||
@tmtc_definitions_provider
|
||||
def add_bpx_cmd_definitions(defs: TmtcDefinitionWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(keys=BpxOpCodes.ON, info="On command")
|
||||
oce.add(keys=BpxOpCodes.OFF, info="Off command")
|
||||
oce.add(keys=BpxOpCodes.HK, info="Request BPX HK")
|
||||
oce.add(keys=BpxOpCodes.RST_BOOT_CNT, info="Reset Boot Count")
|
||||
oce.add(keys=BpxOpCodes.REQUEST_CFG, info="Request Configuration Struct (Step 1)")
|
||||
oce.add(
|
||||
keys=BpxOpCodes.REQUEST_CFG_HK, info="Request Configuration Struct HK (Step 2)"
|
||||
)
|
||||
oce.add(keys=BpxOpCodes.REBOOT, info="Reboot Command")
|
||||
defs.add_service(
|
||||
name=CustomServiceList.BPX_BATTERY.value,
|
||||
info="BPX Battery Handler",
|
||||
op_code_entry=oce,
|
||||
)
|
||||
|
||||
|
||||
@service_provider(CustomServiceList.BPX_BATTERY.value)
|
||||
def pack_bpx_commands(p: ServiceProviderParams):
|
||||
op_code = p.op_code
|
||||
@ -34,6 +64,26 @@ def pack_bpx_commands(p: ServiceProviderParams):
|
||||
q.add_log_cmd("Requesting BPX battery HK set")
|
||||
sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET)
|
||||
q.add_pus_tc(generate_one_hk_command(sid=sid))
|
||||
if op_code in BpxOpCodes.OFF:
|
||||
q.add_log_cmd("Off mode")
|
||||
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Modes.OFF, 0)
|
||||
q.add_pus_tc(
|
||||
PusTelecommand(
|
||||
service=200,
|
||||
subservice=ModeSubservices.TC_MODE_COMMAND,
|
||||
app_data=mode_cmd,
|
||||
)
|
||||
)
|
||||
if op_code in BpxOpCodes.ON:
|
||||
q.add_log_cmd("On mode")
|
||||
mode_cmd = pack_mode_data(BPX_HANDLER_ID, Modes.ON, 0)
|
||||
q.add_pus_tc(
|
||||
PusTelecommand(
|
||||
service=200,
|
||||
subservice=ModeSubservices.TC_MODE_COMMAND,
|
||||
app_data=mode_cmd,
|
||||
)
|
||||
)
|
||||
if op_code in BpxOpCodes.RST_BOOT_CNT:
|
||||
q.add_log_cmd("Resetting reboot counters")
|
||||
q.add_pus_tc(
|
||||
|
@ -69,6 +69,7 @@ class OpCodes:
|
||||
OFF = ["off"]
|
||||
NORMAL = ["normal"]
|
||||
VERIFY_BOOT = ["verify_boot"]
|
||||
MODE_REPLAY = ["mode_replay"]
|
||||
|
||||
|
||||
class Info:
|
||||
@ -76,6 +77,8 @@ class Info:
|
||||
OFF = "Off"
|
||||
NORMAL = "Normal"
|
||||
VERIFY_BOOT = "Verify boot by reading 0xdeadbeef from DEADBEEF address"
|
||||
MODE_REPLAY = "Switch to REPLAY mode"
|
||||
|
||||
|
||||
class MemAddresses(enum.IntEnum):
|
||||
DEADBEEF = 0x40000004
|
||||
@ -103,8 +106,8 @@ def add_ploc_mpsoc_cmds(defs: TmtcDefinitionWrapper):
|
||||
oce.add("11", "Ploc MPSoC: Replay write sequence")
|
||||
oce.add("12", "Ploc MPSoC: OBSW reset sequence count")
|
||||
oce.add(OpCodes.VERIFY_BOOT, "Ploc MPSoC: Read DEADBEEF address")
|
||||
oce.add("14", "Ploc MPSoC: Mode replay")
|
||||
oce.add("15", "Ploc MPSoC: Mode idle")
|
||||
oce.add(OpCodes.MODE_REPLAY, Info.MODE_REPLAY)
|
||||
oce.add("15", "Ploc MPSoC: Mode IDLE")
|
||||
oce.add("16", "Ploc MPSoC: Tc cam command send")
|
||||
oce.add("17", "Ploc MPSoC: Set UART TX tristate")
|
||||
oce.add("18", "Ploc MPSoC: Relesase UART TX")
|
||||
@ -296,7 +299,6 @@ def prepare_downlink_pwr_on_cmd(object_id: bytes) -> bytearray:
|
||||
|
||||
|
||||
def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray:
|
||||
null_terminator = 0
|
||||
use_decoding = int(input("Use decoding (set to 1): "))
|
||||
file = get_sequence_file()
|
||||
command = (
|
||||
@ -304,6 +306,7 @@ def prepare_replay_write_sequence_cmd(object_id: bytes) -> bytearray:
|
||||
+ struct.pack("!I", CommandIds.TC_REPLAY_WRITE_SEQUENCE)
|
||||
+ struct.pack("!B", use_decoding)
|
||||
+ bytearray(file, "utf-8")
|
||||
# + bytes([0])
|
||||
)
|
||||
return bytearray(command)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user