Merge pull request 'STR Improv' (#283) from str-version into main
All checks were successful
EIVE/-/pipeline/head This commit looks good

Reviewed-on: #283
Reviewed-by: Robin Müller <muellerr@irs.uni-stuttgart.de>
This commit is contained in:
Robin Müller 2024-03-14 10:55:59 +01:00
commit f87095bf68
2 changed files with 48 additions and 58 deletions

View File

@ -10,6 +10,10 @@ list yields a list of all related PRs for each release.
# [unreleased] # [unreleased]
## Added
- Added version set for STR
# [v6.1.1] 2024-03-06 # [v6.1.1] 2024-03-06
## Added ## Added

View File

@ -140,9 +140,15 @@ class OpCode:
SELECT_TARGET_FIRMWARE_BACKUP = "fw_backup" SELECT_TARGET_FIRMWARE_BACKUP = "fw_backup"
SELECT_TARGET_FIRMWARE_MAIN_PERSISTENT = "fw_main_persistent" SELECT_TARGET_FIRMWARE_MAIN_PERSISTENT = "fw_main_persistent"
SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT = "fw_backup_persistent" SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT = "fw_backup_persistent"
REQUEST_VERSION = "request_version"
class Info: class Info:
ON_BOOTLOADER = "Switch to Mode On, Submode Bootloder"
ON_FIRMWARE = "Switch to Mode On, Submode Firmware"
NORMAL = "Switch to Mode Normal"
OFF = "Switch to Mode Off"
PING = "Send Ping"
ONE_SHOOT_HK = "One shoot HK Set" ONE_SHOOT_HK = "One shoot HK Set"
ENABLE_HK = "Enable Periodic HK" ENABLE_HK = "Enable Periodic HK"
DISABLE_HK = "Disable Periodic HK" DISABLE_HK = "Disable Periodic HK"
@ -163,6 +169,7 @@ class Info:
SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT = ( SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT = (
"Select backup firmware slot persistently" "Select backup firmware slot persistently"
) )
REQUEST_VERSION = "Request the active Firmware Version"
class SetId(enum.IntEnum): class SetId(enum.IntEnum):
@ -316,10 +323,6 @@ def pack_star_tracker_commands( # noqa C901
q.add_log_cmd("Star tracker: Temperature request") q.add_log_cmd("Star tracker: Temperature request")
data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TEMPERATURE) data = obyt + struct.pack("!I", StarTrackerActionId.REQ_TEMPERATURE)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data)) q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if cmd_str == "8":
q.add_log_cmd("Star tracker: Request version")
data = obyt + struct.pack("!I", StarTrackerActionId.REQ_VERSION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if cmd_str == "9": if cmd_str == "9":
q.add_log_cmd("Star tracker: Request interface") q.add_log_cmd("Star tracker: Request interface")
data = obyt + struct.pack("!I", StarTrackerActionId.REQ_INTERFACE) data = obyt + struct.pack("!I", StarTrackerActionId.REQ_INTERFACE)
@ -730,6 +733,13 @@ def pack_star_tracker_commands( # noqa C901
if cmd_str == OpCode.SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT: if cmd_str == OpCode.SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT:
q.add_log_cmd(Info.SELECT_TARGET_FIRMWARE_BACKUP) q.add_log_cmd(Info.SELECT_TARGET_FIRMWARE_BACKUP)
q.add_pus_tc(create_update_firmware_target_cmd(True, FirmwareTarget.BACKUP)) q.add_pus_tc(create_update_firmware_target_cmd(True, FirmwareTarget.BACKUP))
if cmd_str == OpCode.REQUEST_VERSION:
q.add_log_cmd(Info.REQUEST_VERSION)
q.add_pus_tc(
create_action_cmd(
object_id=STAR_TRACKER_ID, action_id=StarTrackerActionId.REQ_VERSION
)
)
def create_update_firmware_target_cmd( def create_update_firmware_target_cmd(
@ -880,6 +890,8 @@ def handle_str_hk_data(set_id: int, hk_data: bytes, pw: PrintWrapper):
handle_contrast_set(hk_data, pw) handle_contrast_set(hk_data, pw)
elif set_id == SetId.BLOB_STATS: elif set_id == SetId.BLOB_STATS:
handle_blob_stats_set(hk_data, pw) handle_blob_stats_set(hk_data, pw)
elif set_id == SetId.VERSION:
handle_version_set(hk_data, pw)
else: else:
_LOGGER.warning(f"HK parsing for Star Tracker set ID {set_id} unimplemented") _LOGGER.warning(f"HK parsing for Star Tracker set ID {set_id} unimplemented")
@ -902,6 +914,25 @@ def unpack_time_hk(hk_data: bytes, current_idx: int, pw: PrintWrapper) -> int:
return current_idx return current_idx
def handle_version_set(hk_data: bytes, pw: PrintWrapper):
pw.dlog("Received Version Set")
if len(hk_data) != 16:
_LOGGER.warning(
f"Version dataset HK with length {len(hk_data)} of unexpected size"
)
current_idx = unpack_time_hk(hk_data, 0, pw)
program = struct.unpack("!B", hk_data[current_idx : current_idx + 1])[0]
pw.dlog(f"Program: {program}")
current_idx += 1
major = struct.unpack("!B", hk_data[current_idx : current_idx + 1])[0]
pw.dlog(f"Major: {major}")
current_idx += 1
minor = struct.unpack("!B", hk_data[current_idx : current_idx + 1])[0]
pw.dlog(f"Minor: {minor}")
current_idx += 1
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=5))
def handle_temperature_set(hk_data: bytes, pw: PrintWrapper): def handle_temperature_set(hk_data: bytes, pw: PrintWrapper):
pw.dlog("Received temperature set") pw.dlog("Received temperature set")
if len(hk_data) < 24: if len(hk_data) < 24:
@ -1208,7 +1239,7 @@ def handle_blob_stats_set(hk_data: bytes, pw: PrintWrapper):
i, noise_list[i], threshold_list[i], lvalid_list[i], oflow_list[i] i, noise_list[i], threshold_list[i], lvalid_list[i], oflow_list[i]
) )
) )
pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=4)) pw.dlog(FsfwTmTcPrinter.get_validity_buffer(hk_data[current_idx:], num_vars=6))
def handle_star_tracker_action_replies( def handle_star_tracker_action_replies(
@ -1251,60 +1282,15 @@ def handle_read_secondary_tm_set(pw: PrintWrapper, custom_data: bytes):
def create_str_node() -> CmdTreeNode: def create_str_node() -> CmdTreeNode:
# Zip the two classes together into a dictionary
op_code_strs = [
getattr(OpCode, key) for key in dir(OpCode) if not key.startswith("__")
]
info_strs = [getattr(Info, key) for key in dir(OpCode) if not key.startswith("__")]
combined_dict = dict(zip(op_code_strs, info_strs))
node = CmdTreeNode( node = CmdTreeNode(
"str", "Star Tracker Device", hide_children_which_are_leaves=True "str", "Star Tracker Device", hide_children_which_are_leaves=True
) )
node.add_child(CmdTreeNode(OpCode.ON_BOOTLOADER, "Mode On, Submode Bootloader")) for op_code, info in combined_dict.items():
node.add_child(CmdTreeNode(OpCode.ON_FIRMWARE, "Mode On, Submode Firmware")) node.add_child(CmdTreeNode(op_code, info))
node.add_child(CmdTreeNode(OpCode.NORMAL, "Mode Normal"))
node.add_child(CmdTreeNode(OpCode.OFF, "Mode Off"))
node.add_child(CmdTreeNode(OpCode.PING, "Star Tracker: Ping"))
node.add_child(CmdTreeNode(OpCode.TAKE_IMAGE, "Take Image"))
node.add_child(CmdTreeNode(OpCode.UPLOAD_IMAGE, Info.UPLOAD_IMAGE))
node.add_child(CmdTreeNode(OpCode.DOWNLOAD_IMAGE, Info.DOWNLOAD_IMAGE))
node.add_child(CmdTreeNode(OpCode.ONE_SHOOT_HK, Info.ONE_SHOOT_HK))
node.add_child(CmdTreeNode(OpCode.ENABLE_HK, Info.ENABLE_HK))
node.add_child(CmdTreeNode(OpCode.DISABLE_HK, Info.DISABLE_HK))
node.add_child(
CmdTreeNode(OpCode.SET_IMG_PROCESSOR_MODE, Info.SET_IMG_PROCESSOR_MODE)
)
node.add_child(
CmdTreeNode(
OpCode.ADD_SECONDARY_TM_TO_NORMAL_MODE,
Info.ADD_SECONDARY_TM_TO_NORMAL_MODE,
)
)
node.add_child(
CmdTreeNode(OpCode.READ_SECONDARY_TM_SET, Info.READ_SECONDARY_TM_SET)
)
node.add_child(
CmdTreeNode(OpCode.RESET_SECONDARY_TM_SET, Info.RESET_SECONDARY_TM_SET)
)
node.add_child(CmdTreeNode(OpCode.FW_UPDATE_MAIN, Info.FW_UPDATE_MAIN))
node.add_child(CmdTreeNode(OpCode.FW_UPDATE_BACKUP, Info.FW_UPDATE_BACKUP))
node.add_child(
CmdTreeNode(
OpCode.SELECT_TARGET_FIRMWARE_MAIN, Info.SELECT_TARGET_FIRMWARE_MAIN
)
)
node.add_child(
CmdTreeNode(
OpCode.SELECT_TARGET_FIRMWARE_BACKUP, Info.SELECT_TARGET_FIRMWARE_BACKUP
)
)
node.add_child(
CmdTreeNode(
OpCode.SELECT_TARGET_FIRMWARE_MAIN_PERSISTENT,
Info.SELECT_TARGET_FIRMWARE_MAIN_PERSISTENT,
)
)
node.add_child(
CmdTreeNode(
OpCode.SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT,
Info.SELECT_TARGET_FIRMWARE_BACKUP_PERSISTENT,
)
)
node.add_child(
CmdTreeNode(OpCode.SET_TIME_FROM_SYS_TIME, Info.SET_TIME_FROM_SYS_TIME)
)
return node return node