eive-tmtc/pus_tc/devs/star_tracker.py

656 lines
25 KiB
Python

# -*- coding: utf-8 -*-
"""
@file star_tracker.py
@brief Star tracker commanding
@author J. Meier
@date 14.08.2021
"""
import struct
from spacepackets.ecss.tc import PusTelecommand
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes
from tmtccmd.logging import get_console_logger
from tmtccmd.tc import DefaultPusQueueHelper
from tmtccmd.util import ObjectIdU32
from utility.input_helper import InputHelper
LOGGER = get_console_logger()
class StarTrackerActionIds:
PING = 0
BOOT = 1
REQ_VERSION = 2
REQ_INTERFACE = 3
REQ_TIME = 4
UNLOCK = 6
SWITCH_TO_BOOTLOADER_PROGRAM = 7
REQ_POWER = 11
TAKE_IMAGE = 15
DOWNLOAD_IMAGE = 9
UPLOAD_IMAGE = 10
DOWNLOAD_CENTROID = 16
UPLOAD_CENTROID = 17
SUBSCRIPTION = 18
IMAGE_PROCESSOR = 19
REQ_SOLUTION = 24
REQ_TEMPERATURE = 25
REQ_HISTOGRAM = 28
REQ_CONTRAST = 29
LIMITS = 40
MOUNTING = 41
CAMERA = 42
BLOB = 43
CENTROIDING = 44
LISA = 45
MATCHING = 46
TRACKING = 47
VALIDATION = 48
ALGO = 49
CHECKSUM = 50
FLASH_READ = 51
FLASH_WRITE = 52
DOWNLOAD_MATCHED_STAR = 53
STOP_STR_HELPER = 55
RESET_ERROR = 56
CHANGE_DOWNLOAD_IMAGE = 57
SET_JSON_FILE_NAME = 58
SET_FLASH_READ_FILENAME = 59
SET_TIME = 60
DOWNLOAD_DBIMAGE = 61
DOWNLOAD_BLOBPIXEL = 62
DOWNLOAD_FPGA_IMAGE = 63
CHANGE_FPGA_DOWNLOAD_FILE = 64
UPLOAD_FPGA_IMAGE = 65
FPGA_ACTION = 66
REQ_CAMERA_PARAMS = 67
REQ_LIMITS = 68
REQ_LOG_LEVEL = 69
REQ_MOUNTING = 70
REQ_IMAGE_PROCESSOR = 71
REQ_CENTROIDING = 72
REQ_LISA = 73
REQ_MATCHING = 74
REQ_TRACKING = 75
REQ_VALIDATION = 76
REQ_ALGO = 77
REQ_SUBSCRIPTION = 78
REQ_LOG_SUBSCRIPTION = 79
REQ_DEBUG_CAMERA = 80
LOGLEVEL = 81
LOG_SUBSCRIPTION = 82
DEBUG_CAMERA = 83
FIRMWARE_UPDATE = 84
class SetIds:
TEMPERATURE = 25
class FileDefs:
download_path = "/mnt/sd0/startracker"
json_file = "/mnt/sd0/startracker/full.json"
egse_ground_config = "/home/pi/arcsec/json/ground-config.json"
egse_flight_config = "/home/pi/arcsec/json/flight-config.json"
egse_solution_upload_img_config = "/home/pi/arcsec/json/upload-image-solution.json"
egse_histogram_upload_img_config = (
"/home/pi/arcsec/json/upload-image-histogram.json"
)
q7s_ground_config = "/mnt/sd0/startracker/json/ground-config.json"
q7s_flight_config = "/mnt/sd0/startracker/flight-config.json"
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"
json_dict = {
"1": ["Q7S flight config", FileDefs.q7s_flight_config],
"2": ["Q7S ground config", FileDefs.q7s_ground_config],
"3": ["EGSE flight config", FileDefs.egse_flight_config],
"4": ["EGSE ground config", FileDefs.egse_ground_config],
"5": [
"EGSE get solution, upload image config",
FileDefs.egse_solution_upload_img_config,
],
"6": [
"EGSE get histogram, upload image config",
FileDefs.egse_solution_upload_img_config,
],
}
firmware_dict = {
"1": ["Firmware Major = 2, Minor = 1", FileDefs.firmware2_1],
"2": ["Firmware Major = 22, Minor = 1", FileDefs.firmware22_1],
"3": ["Firmware Origin", FileDefs.firmware_origin],
}
upload_image_dict = {
"1": ["q7s gemma", "/mnt/sd0/startracker/gemma.bin"],
"2": ["egse gemma", "/home/pi/arcsec/star-images/gemma.bin"],
"3": ["q7s polaris", "/mnt/sd0/startracker/polaris.bin"],
"4": ["egse polaris", "/home/pi/arcsec/star-images/polaris.bin"],
}
class StartRegion:
# Definition according to datasheet (which turned out to be partially faulty)
BOOTLOADER = 0
STAR_TRACKER_FIRMWARE = 1
class PartitionSize:
# Size of most recent firmware image
STAR_TRACKER_FIRMWARE = 464572
class Submode:
BOOTLOADER = 1
FIRMWARE = 2
def pack_star_tracker_commands(
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}"
)
obyt = object_id.as_bytes
if op_code == "0":
q.add_log_cmd("Star tracker: Mode On, Submode Bootloader")
data = pack_mode_data(obyt, Modes.ON, Submode.BOOTLOADER)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == "1":
q.add_log_cmd("Star tracker: Mode On, Submode Firmware")
data = pack_mode_data(obyt, Modes.ON, Submode.FIRMWARE)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == "2":
q.add_log_cmd("Star tracker: Mode Normal")
data = pack_mode_data(obyt, Modes.NORMAL, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == "3":
q.add_log_cmd("Star tracker: Mode Off")
data = pack_mode_data(obyt, Modes.OFF, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == "4":
q.add_log_cmd("Star tracker: Mode Raw")
data = pack_mode_data(obyt, Modes.RAW, 0)
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
if op_code == "5":
q.add_log_cmd("Star tracker: Ping")
data = obyt + struct.pack("!I", StarTrackerActionIds.PING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "6":
q.add_log_cmd("Star tracker: Switch to bootloader program")
data = obyt + struct.pack(
"!I", StarTrackerActionIds.SWITCH_TO_BOOTLOADER_PROGRAM
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "7":
q.add_log_cmd("Star tracker: Temperature request")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_TEMPERATURE)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "8":
q.add_log_cmd("Star tracker: Request version")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_VERSION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "9":
q.add_log_cmd("Star tracker: Request interface")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_INTERFACE)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "10":
q.add_log_cmd("Star tracker: Request power")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_POWER)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "11":
q.add_log_cmd("Star tracker: Set subscription parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.SUBSCRIPTION)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "12":
q.add_log_cmd("Star tracker: Boot")
data = obyt + struct.pack("!I", StarTrackerActionIds.BOOT)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "13":
q.add_log_cmd("Star tracker: Request time")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_TIME)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "14":
q.add_log_cmd("Star tracker: Request solution")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_SOLUTION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "15":
q.add_log_cmd("Star tracker: Upload image")
image = get_upload_image()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE)
+ bytearray(image, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "16":
q.add_log_cmd("Star tracker: Download image")
path = input("Specify storage location (default - /mnt/sd0/startracker): ")
if not path:
path = FileDefs.download_path
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.TAKE_IMAGE)
+ struct.pack("!B", actionid)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "28":
q.add_log_cmd("Star tracker: Stop str helper")
data = obyt + struct.pack("!I", StarTrackerActionIds.STOP_STR_HELPER)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "30":
q.add_log_cmd("Star tracker: Set name of download image")
filename = input("Specify download image name: ")
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.CHANGE_DOWNLOAD_IMAGE)
+ bytearray(filename, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "31":
q.add_log_cmd("Star tracker: Request histogram")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_HISTOGRAM)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "32":
q.add_log_cmd("Star tracker: Request contrast")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_CONTRAST)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "33":
q.add_log_cmd("Star tracker: Set json filename")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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":
q.add_log_cmd("Star tracker: Flash read")
data = pack_read_command(obyt)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "36":
q.add_log_cmd("Star tracker: Set flash read filename")
filename = input("Specify filename: ")
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.SET_FLASH_READ_FILENAME)
+ bytearray(filename, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "37":
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 == "38":
q.add_log_cmd("Star tracker: Set time")
unix_time = 1640783543
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.DOWNLOAD_DBIMAGE)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "43":
q.add_log_cmd("Star tracker: Download Blob Pixel")
id = 0
type = 1 # 0 - normal, 1 - fast
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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":
q.add_log_cmd("Star tracker: Download FPGA Image")
position = int(input("Start position: "))
length = int(input("Size to download: "))
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.FPGA_ACTION)
+ struct.pack("!B", id)
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "48":
q.add_log_cmd("Star tracker: Unlock")
data = obyt + struct.pack("!I", StarTrackerActionIds.UNLOCK)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "49":
q.add_log_cmd("Star tracker: Request camera parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_CAMERA_PARAMS)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "50":
q.add_log_cmd("Star tracker: Request limits")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_LIMITS)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "51":
q.add_log_cmd("Star tracker: Set image processor parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.CAMERA)
+ bytearray(FileDefs.egse_flight_config, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "54":
q.add_log_cmd("Star tracker: Request log level parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_LOG_LEVEL)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "55":
q.add_log_cmd("Star tracker: Request mounting parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_MOUNTING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "56":
q.add_log_cmd("Star tracker: Request image processor parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_IMAGE_PROCESSOR)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "57":
q.add_log_cmd("Star tracker: Request centroiding parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_CENTROIDING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "58":
q.add_log_cmd("Star tracker: Request lisa parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_LISA)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "59":
q.add_log_cmd("Star tracker: Request matching parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_MATCHING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "60":
q.add_log_cmd("Star tracker: Request tracking parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_TRACKING)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "61":
q.add_log_cmd("Star tracker: Request validation parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_VALIDATION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "62":
q.add_log_cmd("Star tracker: Request algo parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_ALGO)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "63":
q.add_log_cmd("Star tracker: Request subscription parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_SUBSCRIPTION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "64":
q.add_log_cmd("Star tracker: Request log subscription parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_LOG_SUBSCRIPTION)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "65":
q.add_log_cmd("Star tracker: Request debug camera parameters")
data = obyt + struct.pack("!I", StarTrackerActionIds.REQ_DEBUG_CAMERA)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "66":
q.add_log_cmd("Star tracker: Set log level parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.LOGLEVEL)
+ bytearray(json_file, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "67":
q.add_log_cmd("Star tracker: Set log subscription parameters")
json_file = get_config_file()
data = (
obyt
+ struct.pack("!I", StarTrackerActionIds.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", StarTrackerActionIds.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", StarTrackerActionIds.FIRMWARE_UPDATE)
+ bytearray(firmware, "utf-8")
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=data))
if op_code == "70":
q.add_log_cmd("Star tracker: Disable timestamp generation")
command = obyt + struct.pack(
"!I", StarTrackerActionIds.DISBALE_TIMESTAMP_GENERATION
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
if op_code == "71":
q.add_log_cmd("Star tracker: Enable timestamp generation")
command = obyt + struct.pack(
"!I", StarTrackerActionIds.ENABLE_TIMESTAMP_GENERATION
)
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
def pack_read_command(object_id: bytes) -> bytearray:
start_region = StartRegion.STAR_TRACKER_FIRMWARE
size = PartitionSize.STAR_TRACKER_FIRMWARE
path = input("Specify storage location (default - /mnt/sd0/startracker): ")
if not path:
path = FileDefs.download_path
data = (
object_id
+ struct.pack("!I", StarTrackerActionIds.FLASH_READ)
+ struct.pack("!B", start_region)
+ struct.pack("!I", size)
+ bytearray(path, "utf-8")
)
return bytearray(data)
def pack_checksum_command(object_id: bytes) -> bytearray:
start_region = StartRegion.STAR_TRACKER_FIRMWARE
address = 0
size = PartitionSize.STAR_TRACKER_FIRMWARE
data = (
object_id
+ struct.pack("!I", StarTrackerActionIds.CHECKSUM)
+ struct.pack("!B", start_region)
+ struct.pack("!I", address)
+ struct.pack("!I", size)
)
return bytearray(data)
def get_config_file() -> str:
LOGGER.info("Specify json file")
input_helper = InputHelper(json_dict)
key = input_helper.get_key()
json_file = json_dict[key][1]
return json_file
def get_firmware() -> str:
LOGGER.info("Specify firmware file")
input_helper = InputHelper(firmware_dict)
key = input_helper.get_key()
firmware = firmware_dict[key][1]
return firmware
def get_upload_image() -> str:
LOGGER.info("Specify image to upload")
input_helper = InputHelper(upload_image_dict)
key = input_helper.get_key()
image = upload_image_dict[key][1]
return image