extend STR fw update cmds

This commit is contained in:
Robin Müller 2023-04-13 12:08:00 +02:00
parent a5178e2bb0
commit 33fd280e51
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -103,6 +103,7 @@ class OpCodes:
TAKE_IMAGE = "take_image"
UPLOAD_IMAGE = "upload_image"
SET_IMG_PROCESSOR_MODE = "set_img_proc_mode"
FW_UPDATE = "fw_update"
class Info:
@ -111,6 +112,7 @@ class Info:
UPLOAD_IMAGE = "Upload Image"
TAKE_IMAGE = "Take Image"
SET_IMG_PROCESSOR_MODE = "Set Image Processor Mode"
FW_UPDATE = "Firmware Update"
class SetId(enum.IntEnum):
@ -141,6 +143,7 @@ class FileDefs:
firmware2_1 = "/home/pi/arcsec/firmware/sagitta-2-1.bin"
firmware22_1 = "/home/pi/arcsec/firmware/sagitta-22-1.bin"
firmware_origin = "/home/pi/arcsec/firmware/sagitta-origin.bin"
FW_SLOT_Q7S = "/mnt/sd0/startracker/updates/sagitta-update.bin"
json_dict = {
@ -158,7 +161,8 @@ json_dict = {
),
}
firmware_dict = {
FW_DICT = {
"0": ("Firmware Update Q7S", FileDefs.FW_SLOT_Q7S),
"1": ("Firmware Major = 2, Minor = 1", FileDefs.firmware2_1),
"2": ("Firmware Major = 22, Minor = 1", FileDefs.firmware22_1),
"3": ("Firmware Origin", FileDefs.firmware_origin),
@ -630,13 +634,13 @@ def pack_star_tracker_commands(
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "69":
q.add_log_cmd("Star tracker: Firmware update")
if op_code == OpCodes.FW_UPDATE:
q.add_log_cmd(Info.FW_UPDATE)
firmware = get_firmware()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE)
+ bytearray(firmware, "utf-8")
+ firmware.encode()
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
@ -681,9 +685,13 @@ def get_config_file() -> str:
def get_firmware() -> str:
_LOGGER.info("Specify firmware file")
input_helper = InputHelper(firmware_dict)
bin_select = int(input("Use hardcoded paths (0) or specify path manually (1) ?: "))
if bin_select == 0:
input_helper = InputHelper(FW_DICT)
key = input_helper.get_key()
firmware = firmware_dict[key][1]
firmware = FW_DICT[key][1]
else:
firmware = input("Specify absolute path of the firmware update file: ")
return firmware
@ -870,7 +878,7 @@ def add_str_cmds(defs: TmtcDefinitionWrapper):
oce.add("66", "Star Tracker: Set log level parameters")
oce.add("67", "Star Tracker: Set log subscription parameters")
oce.add("68", "Star Tracker: Set debug camera parameters")
oce.add("69", "Star Tracker: Firmware update")
oce.add(OpCodes.FW_UPDATE, Info.FW_UPDATE)
oce.add("70", "Star Tracker: Disable timestamp generation")
oce.add("71", "Star Tracker: Enable timestamp generation")
defs.add_service(CustomServiceList.STAR_TRACKER.value, "Star Tracker", oce)