added missing str parameters #162

Merged
muellerr merged 2 commits from zink_str into main 2023-03-10 13:38:33 +01:00
Showing only changes of commit 05429d2048 - Show all commits

View File

@ -174,7 +174,7 @@ class Submode:
def pack_star_tracker_commands(
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
object_id: ObjectIdU32, q: DefaultPusQueueHelper, op_code: str
):
q.add_log_cmd(
f"Generate command for star tracker with object id: {object_id.as_hex_string}"
@ -230,9 +230,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set subscription parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.SUBSCRIPTION)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.SUBSCRIPTION)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "12":
@ -251,9 +251,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Upload image")
image = get_upload_image()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE)
+ bytearray(image, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.UPLOAD_IMAGE)
+ bytearray(image, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "16":
@ -262,99 +262,99 @@ def pack_star_tracker_commands(
if not path:
path = FileDefs.download_path
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE)
+ bytearray(path, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_IMAGE)
+ bytearray(path, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "17":
q.add_log_cmd("Star tracker: Set limits")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.LIMITS)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.LIMITS)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "18":
q.add_log_cmd("Star tracker: Set tracking parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.TRACKING)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.TRACKING)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "19":
q.add_log_cmd("Star tracker: Mounting")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.MOUNTING)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.MOUNTING)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "20":
q.add_log_cmd("Star tracker: Camera")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "22":
q.add_log_cmd("Star tracker: Centroiding")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CENTROIDING)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CENTROIDING)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "23":
q.add_log_cmd("Star tracker: LISA")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.LISA)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.LISA)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "24":
q.add_log_cmd("Star tracker: Matching")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.MATCHING)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.MATCHING)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "25":
q.add_log_cmd("Star tracker: Validation")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.VALIDATION)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.VALIDATION)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "26":
q.add_log_cmd("Star tracker: Algo")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.ALGO)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.ALGO)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "27":
q.add_log_cmd("Star tracker: Take image")
actionid = int(input("Specify parameter ID (take image - 4): "))
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.TAKE_IMAGE)
+ struct.pack("!B", actionid)
obyt
+ struct.pack("!I", StarTrackerActionId.TAKE_IMAGE)
+ struct.pack("!B", actionid)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "28":
@ -365,9 +365,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set name of download image")
filename = input("Specify download image name: ")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE)
+ bytearray(filename, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CHANGE_DOWNLOAD_IMAGE)
+ bytearray(filename, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "31":
@ -382,9 +382,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set json filename")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.SET_JSON_FILE_NAME)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "35":
@ -395,9 +395,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set flash read filename")
filename = input("Specify filename: ")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME)
+ bytearray(filename, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.SET_FLASH_READ_FILENAME)
+ bytearray(filename, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "37":
@ -408,36 +408,36 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set time")
unix_time = 1640783543
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.SET_TIME)
+ struct.pack("!Q", unix_time)
obyt
+ struct.pack("!I", StarTrackerActionId.SET_TIME)
+ struct.pack("!Q", unix_time)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "39":
q.add_log_cmd("Star tracker: Download Centroid")
id = 0
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID)
+ struct.pack("!B", id)
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_CENTROID)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "41":
q.add_log_cmd("Star tracker: Download matched star")
id = 0
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR)
+ struct.pack("!B", id)
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_MATCHED_STAR)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "42":
q.add_log_cmd("Star tracker: Download DB Image")
id = 0
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE)
+ struct.pack("!B", id)
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_DBIMAGE)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "43":
@ -445,10 +445,10 @@ def pack_star_tracker_commands(
id = 0
type = 1 # 0 - normal, 1 - fast
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL)
+ struct.pack("!B", id)
+ struct.pack("!B", type)
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_BLOBPIXEL)
+ struct.pack("!B", id)
+ struct.pack("!B", type)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "44":
@ -456,36 +456,36 @@ def pack_star_tracker_commands(
position = int(input("Start position: "))
length = int(input("Size to download: "))
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE)
+ struct.pack("!I", position)
+ struct.pack("!I", length)
+ bytearray(FileDefs.downloadFpgaImagePath, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.DOWNLOAD_FPGA_IMAGE)
+ struct.pack("!I", position)
+ struct.pack("!I", length)
+ bytearray(FileDefs.downloadFpgaImagePath, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "45":
q.add_log_cmd("Star tracker: Change donwload FPGA image file name")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE)
+ bytearray(FileDefs.downloadFpgaImageName, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CHANGE_FPGA_DOWNLOAD_FILE)
+ bytearray(FileDefs.downloadFpgaImageName, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "46":
q.add_log_cmd("Star tracker: Upload FPGA image")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE)
+ bytearray(FileDefs.uploadFpgaImageName, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.UPLOAD_FPGA_IMAGE)
+ bytearray(FileDefs.uploadFpgaImageName, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "47":
q.add_log_cmd("Star tracker: FPGA action")
id = 3
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.FPGA_ACTION)
+ struct.pack("!B", id)
obyt
+ struct.pack("!I", StarTrackerActionId.FPGA_ACTION)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "48":
@ -504,25 +504,25 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set image processor parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.IMAGE_PROCESSOR)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "52":
q.add_log_cmd("Star tracker: EGSE load ground config camera parameters")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(FileDefs.egse_ground_config, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(FileDefs.egse_ground_config, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "53":
q.add_log_cmd("Star tracker: EGSE load flight config camera parameters")
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(FileDefs.egse_flight_config, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.CAMERA)
+ bytearray(FileDefs.egse_flight_config, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "54":
@ -577,9 +577,9 @@ def pack_star_tracker_commands(
q.add_log_cmd("Star tracker: Set log level parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.LOGLEVEL)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.LOGLEVEL)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "67":
@ -587,27 +587,27 @@ def pack_star_tracker_commands(
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.LOG_SUBSCRIPTION)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "68":
q.add_log_cmd("Star tracker: Set debug camera parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA)
+ bytearray(json_file, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.DEBUG_CAMERA)
+ 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")
firmware = get_firmware()
data = (
obyt
+ struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE)
+ bytearray(firmware, "utf-8")
obyt
+ struct.pack("!I", StarTrackerActionId.FIRMWARE_UPDATE)
+ bytearray(firmware, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "70":
@ -631,11 +631,11 @@ def pack_read_command(object_id: bytes) -> bytearray:
if not path:
path = FileDefs.download_path
data = (
object_id
+ struct.pack("!I", StarTrackerActionId.FLASH_READ)
+ struct.pack("!B", start_region)
+ struct.pack("!I", size)
+ bytearray(path, "utf-8")
object_id
+ struct.pack("!I", StarTrackerActionId.FLASH_READ)
+ struct.pack("!B", start_region)
+ struct.pack("!I", size)
+ bytearray(path, "utf-8")
)
return bytearray(data)
@ -645,11 +645,11 @@ def pack_checksum_command(object_id: bytes) -> bytearray:
address = 0
size = PartitionSize.STAR_TRACKER_FIRMWARE
data = (
object_id
+ struct.pack("!I", StarTrackerActionId.CHECKSUM)
+ struct.pack("!B", start_region)
+ struct.pack("!I", address)
+ struct.pack("!I", size)
object_id
+ struct.pack("!I", StarTrackerActionId.CHECKSUM)
+ struct.pack("!B", start_region)
+ struct.pack("!I", address)
+ struct.pack("!I", size)
)
return bytearray(data)
@ -693,7 +693,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
current_idx = 0
fmt_len = struct.calcsize(ticks_time_fmt)
(ticks, unix_time) = struct.unpack(
ticks_time_fmt, hk_data[current_idx: current_idx + fmt_len]
ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len]
)
unix_as_dt = datetime.datetime.fromtimestamp(unix_time, tz=datetime.timezone.utc)
pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}")
@ -702,7 +702,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
calib_quaternions_fmt = "!ffff"
fmt_len = struct.calcsize(calib_quaternions_fmt)
(calib_q_w, calib_q_x, calib_q_y, calib_q_z) = struct.unpack(
calib_quaternions_fmt, hk_data[current_idx: current_idx + fmt_len]
calib_quaternions_fmt, hk_data[current_idx : current_idx + fmt_len]
)
pw.dlog("Calibrated Quaternions")
pw.dlog(f"Quaternion w: {calib_q_w}")
@ -713,7 +713,7 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
track_fmt = "!fffff"
fmt_len = struct.calcsize(track_fmt)
(track_confidence, track_q_w, track_q_x, track_q_y, track_q_z) = struct.unpack(
track_fmt, hk_data[current_idx: current_idx + fmt_len]
track_fmt, hk_data[current_idx : current_idx + fmt_len]
)
pw.dlog(f"Track Confidence: {track_confidence}")
pw.dlog(f"Track QW: {track_q_w}")
@ -733,20 +733,27 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
# Result of LISA: Lost in space algorithm
lisa_fmt = "!fffffB"
fmt_len = struct.calcsize(track_fmt)
(lisa_q_w, lisa_q_x, lisa_q_y, lisa_q_z, lisa_percentage_close_stars, lisa_number_close_stars) = struct.unpack(
lisa_fmt, hk_data[current_idx: current_idx + fmt_len]
)
(
lisa_q_w,
lisa_q_x,
lisa_q_y,
lisa_q_z,
lisa_percentage_close_stars,
lisa_number_close_stars,
) = struct.unpack(lisa_fmt, hk_data[current_idx : current_idx + fmt_len])
pw.dlog(f"LISA QW: {lisa_q_w}")
pw.dlog(f"LISA QX: {lisa_q_x}")
pw.dlog(f"LISA QY: {lisa_q_y}")
pw.dlog(f"LISA QZ: {lisa_q_z}")
pw.dlog(f"Percentage of close stars in LISA solution: {lisa_percentage_close_stars}")
pw.dlog(
f"Percentage of close stars in LISA solution: {lisa_percentage_close_stars}"
)
pw.dlog(f"Number of close stars in LISA solution: {lisa_number_close_stars}")
current_idx += fmt_len
is_trusworthy = hk_data[current_idx]
pw.dlog(f"Trustworthy solution: {is_trusworthy}")
current_idx += 1
stable_count = struct.unpack("!I", hk_data[current_idx: current_idx + 4])
stable_count = struct.unpack("!I", hk_data[current_idx : current_idx + 4])
pw.dlog(f"Stable count: {stable_count}")
current_idx += 4
solution_strategy = hk_data[current_idx]