improve STR code
This commit is contained in:
parent
b32a9273ae
commit
c9b269b01a
@ -16,6 +16,7 @@ from eive_tmtc.utility.input_helper import InputHelper
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
|
||||
from tmtccmd.config.tmtc import tmtc_definitions_provider
|
||||
from tmtccmd.tc.pus_3_fsfw_hk import create_request_one_diag_command, make_sid
|
||||
from tmtccmd.tc import DefaultPusQueueHelper
|
||||
from tmtccmd.tc.pus_200_fsfw_mode import pack_mode_data, Mode
|
||||
from tmtccmd.util import ObjectIdU32
|
||||
@ -96,6 +97,13 @@ class OpCodes:
|
||||
NORMAL = "nml"
|
||||
OFF = "off"
|
||||
PING = "ping"
|
||||
REQUEST_SOLUTION_SET = "request_sol_set"
|
||||
TAKE_IMAGE = "take_image"
|
||||
|
||||
|
||||
class Info:
|
||||
REQUEST_SOLUTION_SET = "Request Solution Set HK once"
|
||||
|
||||
|
||||
|
||||
class SetId(enum.IntEnum):
|
||||
@ -196,6 +204,9 @@ def pack_star_tracker_commands(
|
||||
q.add_log_cmd("Star tracker: Mode Off")
|
||||
data = pack_mode_data(obyt, Mode.OFF, 0)
|
||||
q.add_pus_tc(PusTelecommand(service=200, subservice=1, app_data=data))
|
||||
if op_code == OpCodes.REQUEST_SOLUTION_SET:
|
||||
q.add_log_cmd(Info.REQUEST_SOLUTION_SET)
|
||||
q.add_pus_tc(create_request_one_diag_command(make_sid(obyt, SetId.SOLUTION)))
|
||||
if op_code == "4":
|
||||
q.add_log_cmd("Star tracker: Mode Raw")
|
||||
data = pack_mode_data(obyt, Mode.RAW, 0)
|
||||
@ -348,7 +359,7 @@ 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 == "27":
|
||||
if op_code == OpCodes.TAKE_IMAGE:
|
||||
q.add_log_cmd("Star tracker: Take image")
|
||||
actionid = int(input("Specify parameter ID (take image - 4): "))
|
||||
data = (
|
||||
@ -610,18 +621,6 @@ def pack_star_tracker_commands(
|
||||
+ 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", StarTrackerActionId.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", StarTrackerActionId.ENABLE_TIMESTAMP_GENERATION
|
||||
)
|
||||
q.add_pus_tc(PusTelecommand(service=8, subservice=128, app_data=command))
|
||||
|
||||
|
||||
def pack_read_command(object_id: bytes) -> bytearray:
|
||||
@ -695,7 +694,10 @@ def unpack_time_hk(hk_data: bytes, current_idx: int, pw: PrintWrapper) -> int:
|
||||
(ticks, unix_time) = struct.unpack(
|
||||
ticks_time_fmt, hk_data[current_idx : current_idx + fmt_len]
|
||||
)
|
||||
unix_as_dt = datetime.datetime.fromtimestamp(unix_time, tz=datetime.timezone.utc)
|
||||
unix_as_dt = datetime.datetime.fromtimestamp(
|
||||
int(round(unix_time / 10e6)),
|
||||
tz=datetime.timezone.utc
|
||||
)
|
||||
pw.dlog(f"Ticks: {ticks} | UNIX time: {unix_time}")
|
||||
pw.dlog(f"UNIX as datetime: {unix_as_dt}")
|
||||
current_idx += fmt_len
|
||||
@ -786,18 +788,21 @@ def handle_solution_set(hk_data: bytes, pw: PrintWrapper):
|
||||
current_idx += 4
|
||||
solution_strategy = hk_data[current_idx]
|
||||
pw.dlog(f"Solution strategy: {solution_strategy}")
|
||||
current_idx += 1
|
||||
pw.printer.print_validity_buffer(hk_data[current_idx:], 23)
|
||||
|
||||
|
||||
@tmtc_definitions_provider
|
||||
def add_str_cmds(defs: TmtcDefinitionWrapper):
|
||||
oce = OpCodeEntry()
|
||||
oce.add(OpCodes.ON_BOOTLOADER, "Star Tracker: Mode On, Submode Bootloader")
|
||||
oce.add(OpCodes.ON_FIRMWARE, "Star Tracker: Mode On, Submode Firmware")
|
||||
oce.add(OpCodes.NORMAL, "Star Tracker: Mode Normal")
|
||||
oce.add(OpCodes.OFF, "Star Tracker: Mode Off")
|
||||
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("4", "Star Tracker: Mode Raw")
|
||||
oce.add(OpCodes.PING, "Star Tracker: Ping")
|
||||
oce.add(OpCodes.TAKE_IMAGE, "Take Image")
|
||||
oce.add(OpCodes.REQUEST_SOLUTION_SET, "Request Solution Set HK")
|
||||
oce.add("6", "Star Tracker: Switch to bootloader program")
|
||||
oce.add("7", "Star Tracker: Request temperature")
|
||||
oce.add("8", "Star Tracker: Request version")
|
||||
@ -819,7 +824,6 @@ def add_str_cmds(defs: TmtcDefinitionWrapper):
|
||||
oce.add("24", "Star Tracker: Set matching parameters")
|
||||
oce.add("25", "Star Tracker: Set validation parameters")
|
||||
oce.add("26", "Star Tracker: Set algo parameters")
|
||||
oce.add("27", "Star Tracker: Take image")
|
||||
oce.add("28", "Star Tracker: Stop str helper")
|
||||
oce.add("30", "Star Tracker: Set name of download image")
|
||||
oce.add("31", "Star Tracker: Request histogram")
|
||||
|
Loading…
Reference in New Issue
Block a user