STR reload json cfg cmd
All checks were successful
EIVE/-/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-11-21 15:23:41 +01:00
parent 07b13c153d
commit 38b3166b3f
2 changed files with 45 additions and 35 deletions

View File

@ -13,6 +13,7 @@ list yields a list of all related PRs for each release.
## Added
- Core controller auto switch enable and disable command.
- Star Tracker JSON reload command. Reboot still required.
# [v5.10.1] 2023-10-27

View File

@ -100,9 +100,10 @@ class StarTrackerActionId(enum.IntEnum):
ADD_SECONDARY_TM_TO_NORMAL_MODE = 95
RESET_SECONDARY_TM_SET = 96
READ_SECONDARY_TM_SET = 97
RELOAD_JSON_CFG_FILE = 100
class OpCodes:
class OpCode:
ON_BOOTLOADER = "on_bootloader"
ON_FIRMWARE = "on_firmware"
NORMAL = "nml"
@ -120,6 +121,7 @@ class OpCodes:
SET_IMG_PROCESSOR_MODE = "set_img_proc_mode"
FW_UPDATE = "fw_update"
SET_TIME_FROM_SYS_TIME = "set_time"
RELOAD_JSON_CFG_FILE = "reload_json_cfg"
class Info:
@ -135,6 +137,7 @@ class Info:
SET_IMG_PROCESSOR_MODE = "Set Image Processor Mode"
FW_UPDATE = "Firmware Update"
SET_TIME_FROM_SYS_TIME = "Set time from system time"
RELOAD_JSON_CFG_FILE = "Reload JSON configuration file. Reboot still required."
class SetId(enum.IntEnum):
@ -244,36 +247,36 @@ def pack_star_tracker_commands( # noqa C901
f"Generate command for star tracker with object id: {object_id.as_hex_string}"
)
obyt = object_id.as_bytes
if op_code == OpCodes.ON_BOOTLOADER:
if op_code == OpCode.ON_BOOTLOADER:
q.add_log_cmd("Star tracker: Mode On, Submode Bootloader")
data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.ON, Submode.BOOTLOADER)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == OpCodes.ON_FIRMWARE:
if op_code == OpCode.ON_FIRMWARE:
q.add_log_cmd("Star tracker: Mode On, Submode Firmware")
data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.ON, Submode.FIRMWARE)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == OpCodes.NORMAL:
if op_code == OpCode.NORMAL:
q.add_log_cmd("Star tracker: Mode Normal")
data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == OpCodes.OFF:
if op_code == OpCode.OFF:
q.add_log_cmd("Star tracker: Mode Off")
data = pack_mode_data(prompt_object_id_mode_cmd(), Mode.OFF, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == OpCodes.ONE_SHOOT_HK:
if op_code == OpCode.ONE_SHOOT_HK:
q.add_log_cmd(Info.ONE_SHOOT_HK)
request_dataset(q, DataSetRequest.ONESHOT)
if op_code == OpCodes.ENABLE_HK:
if op_code == OpCode.ENABLE_HK:
q.add_log_cmd(Info.ENABLE_HK)
request_dataset(q, DataSetRequest.ENABLE)
if op_code == OpCodes.DISABLE_HK:
if op_code == OpCode.DISABLE_HK:
q.add_log_cmd(Info.DISABLE_HK)
request_dataset(q, DataSetRequest.DISABLE)
if op_code == "4":
q.add_log_cmd("Star tracker: Mode Raw")
data = pack_mode_data(obyt, Mode.RAW, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == OpCodes.PING:
if op_code == OpCode.PING:
q.add_log_cmd("Star tracker: Ping")
data = obyt + struct.pack("!I", StarTrackerActionId.PING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
@ -316,7 +319,7 @@ def pack_star_tracker_commands( # noqa C901
q.add_log_cmd("Star tracker: Request time")
data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TIME)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.UPLOAD_IMAGE:
if op_code == OpCode.UPLOAD_IMAGE:
q.add_log_cmd("Star tracker: Upload image")
image = get_upload_image()
data = (
@ -325,7 +328,7 @@ def pack_star_tracker_commands( # noqa C901
+ bytearray(image, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.DOWNLOAD_IMAGE:
if op_code == OpCode.DOWNLOAD_IMAGE:
q.add_log_cmd(f"STR: {Info.DOWNLOAD_IMAGE}")
path = input("Specify storage location (default - /mnt/sd0/startracker): ")
if not path:
@ -417,7 +420,7 @@ def pack_star_tracker_commands( # noqa C901
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.TAKE_IMAGE:
if op_code == OpCode.TAKE_IMAGE:
q.add_log_cmd("Star tracker: Take image")
actionid = int(
input("Specify parameter ID (4: take image, 7: get histogram): ")
@ -475,7 +478,7 @@ def pack_star_tracker_commands( # noqa C901
q.add_log_cmd("Star tracker: Get checksum")
data = pack_checksum_command(obyt)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.SET_TIME_FROM_SYS_TIME:
if op_code == OpCode.SET_TIME_FROM_SYS_TIME:
q.add_log_cmd(Info.SET_TIME_FROM_SYS_TIME)
data = obyt + struct.pack("!I", StarTrackerActionId.SET_TIME_FROM_SYS_TIME)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
@ -538,7 +541,7 @@ def pack_star_tracker_commands( # noqa C901
q.add_log_cmd("Star tracker: Request limits")
data = obyt + struct.pack("!I", StarTrackerActionId.REQ_LIMITS)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.SET_IMG_PROCESSOR_MODE:
if op_code == OpCode.SET_IMG_PROCESSOR_MODE:
q.add_log_cmd(Info.SET_IMG_PROCESSOR_MODE)
json_file = get_config_file()
data = (
@ -639,7 +642,7 @@ def pack_star_tracker_commands( # noqa C901
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.FW_UPDATE:
if op_code == OpCode.FW_UPDATE:
q.add_log_cmd(Info.FW_UPDATE)
firmware = get_firmware()
data = (
@ -648,7 +651,7 @@ def pack_star_tracker_commands( # noqa C901
+ firmware.encode()
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE:
if op_code == OpCode.ADD_SECONDARY_TM_TO_NORMAL_MODE:
q.add_log_cmd(Info.ADD_SECONDARY_TM_TO_NORMAL_MODE)
for val in SetId:
print("{:<2}: {:<20}".format(val, val.name))
@ -660,7 +663,7 @@ def pack_star_tracker_commands( # noqa C901
struct.pack("!I", set_id),
)
)
if op_code == OpCodes.RESET_SECONDARY_TM_SET:
if op_code == OpCode.RESET_SECONDARY_TM_SET:
q.add_log_cmd(Info.RESET_SECONDARY_TM_SET)
q.add_pus_tc(
create_action_cmd(
@ -668,13 +671,18 @@ def pack_star_tracker_commands( # noqa C901
StarTrackerActionId.RESET_SECONDARY_TM_SET,
)
)
if op_code == OpCodes.READ_SECONDARY_TM_SET:
if op_code == OpCode.READ_SECONDARY_TM_SET:
q.add_log_cmd(Info.READ_SECONDARY_TM_SET)
q.add_pus_tc(
create_action_cmd(
STAR_TRACKER_ID, StarTrackerActionId.READ_SECONDARY_TM_SET
)
)
if op_code == OpCode.RELOAD_JSON_CFG_FILE:
q.add_log_cmd(Info.RELOAD_JSON_CFG_FILE)
q.add_pus_tc(
create_action_cmd(STAR_TRACKER_ID, StarTrackerActionId.RELOAD_JSON_CFG_FILE)
)
def request_dataset(q: DefaultPusQueueHelper, req_type: DataSetRequest):
@ -1150,23 +1158,24 @@ def handle_read_secondary_tm_set(pw: PrintWrapper, custom_data: bytes):
@tmtc_definitions_provider
def add_str_cmds(defs: TmtcDefinitionWrapper):
oce = OpCodeEntry()
oce.add(OpCodes.ON_BOOTLOADER, "Mode On, Submode Bootloader")
oce.add(OpCodes.ON_FIRMWARE, "Mode On, Submode Firmware")
oce.add(OpCodes.NORMAL, "Mode Normal")
oce.add(OpCodes.OFF, "Mode Off")
oce.add(OpCodes.PING, "Star Tracker: Ping")
oce.add(OpCodes.TAKE_IMAGE, "Take Image")
oce.add(OpCodes.UPLOAD_IMAGE, Info.UPLOAD_IMAGE)
oce.add(OpCodes.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE)
oce.add(OpCodes.ONE_SHOOT_HK, Info.ONE_SHOOT_HK)
oce.add(OpCodes.ENABLE_HK, Info.ENABLE_HK)
oce.add(OpCodes.DISABLE_HK, Info.DISABLE_HK)
oce.add(OpCodes.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE)
oce.add(OpCode.ON_BOOTLOADER, "Mode On, Submode Bootloader")
oce.add(OpCode.ON_FIRMWARE, "Mode On, Submode Firmware")
oce.add(OpCode.NORMAL, "Mode Normal")
oce.add(OpCode.OFF, "Mode Off")
oce.add(OpCode.PING, "Star Tracker: Ping")
oce.add(OpCode.TAKE_IMAGE, "Take Image")
oce.add(OpCode.UPLOAD_IMAGE, Info.UPLOAD_IMAGE)
oce.add(OpCode.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE)
oce.add(OpCode.ONE_SHOOT_HK, Info.ONE_SHOOT_HK)
oce.add(OpCode.ENABLE_HK, Info.ENABLE_HK)
oce.add(OpCode.DISABLE_HK, Info.DISABLE_HK)
oce.add(OpCode.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE)
oce.add(
OpCodes.ADD_SECONDARY_TM_TO_NORMAL_MODE, Info.ADD_SECONDARY_TM_TO_NORMAL_MODE
OpCode.ADD_SECONDARY_TM_TO_NORMAL_MODE, Info.ADD_SECONDARY_TM_TO_NORMAL_MODE
)
oce.add(OpCodes.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET)
oce.add(OpCodes.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET)
oce.add(OpCodes.FW_UPDATE, Info.FW_UPDATE)
oce.add(OpCodes.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME)
oce.add(OpCode.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET)
oce.add(OpCode.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET)
oce.add(OpCode.FW_UPDATE, Info.FW_UPDATE)
oce.add(OpCode.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME)
oce.add(OpCode.RELOAD_JSON_CFG_FILE, Info.RELOAD_JSON_CFG_FILE)
defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce)