this is more pythonic

This commit is contained in:
Robin Müller 2023-02-08 11:51:55 +01:00
parent ca04b6018b
commit 4086e7947b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 19 additions and 11 deletions

View File

@ -1,6 +1,7 @@
import logging
import datetime
import struct
import sys
from eive_tmtc.config.events import get_event_dict
from eive_tmtc.config.object_ids import get_object_ids
@ -76,13 +77,13 @@ def handle_event_packet(raw_tm: bytes, printer: FsfwTmTcPrinter):
pw.dlog(f"Mode Number {event_def.param1}, Mode Name {mode_name}")
pw.dlog(f"Submode: {event_def.param2}")
elif info.name == "VERSION_INFO":
ver_major = (event_def.param1 >> 24) & 0xff
ver_minor = (event_def.param1 >> 16) & 0xff
ver_rev = (event_def.param1 >> 8) & 0xff
has_git_sha = bool(event_def.param1 & 0xff)
ver_major = (event_def.param1 >> 24) & 0xFF
ver_minor = (event_def.param1 >> 16) & 0xFF
ver_rev = (event_def.param1 >> 8) & 0xFF
has_git_sha = bool(event_def.param1 & 0xFF)
git_sha = ""
if has_git_sha:
p2_as_bytes = struct.pack("@I", event_def.param2)
p2_as_bytes = event_def.param2.to_bytes(4, sys.byteorder)
git_sha = p2_as_bytes.decode("ascii")
version_string = f"v{ver_major}.{ver_minor}.{ver_rev}"
pw.dlog(f"Version {version_string}")

View File

@ -10,7 +10,12 @@ from tmtccmd.config.tmtc import (
)
from tmtccmd.tc import service_provider
from tmtccmd.tc.decorator import ServiceProviderParams
from tmtccmd.tc.pus_200_fsfw_mode import create_mode_command, create_read_mode_command, create_announce_mode_command, create_announce_mode_recursive_command
from tmtccmd.tc.pus_200_fsfw_mode import (
create_mode_command,
create_read_mode_command,
create_announce_mode_command,
create_announce_mode_recursive_command,
)
from tmtccmd.tc.pus_20_fsfw_param import (
create_load_param_cmd,
pack_scalar_u8_parameter_app_data,
@ -51,7 +56,7 @@ class Info:
UPDATE_DEFAULT_DATARATE_LOW = "Configure default low datarate (BPSK modulation)"
UPDATE_DEFAULT_DATARATE_HIGH = "Configure default high datarate (0QPSK modulation)"
READ_MODE = "Read Mode"
ANNOUNCE_MODE = "Announce Mode"
ANNOUNCE_MODE = "Announce Mode"
ANNOUNCE_MODE_RECURSIVE = "Announce mode recursively"

View File

@ -21,7 +21,7 @@ _LOGGER = logging.getLogger(__name__)
class ActionId(enum.IntEnum):
LIST_DIR_INTO_FILE = 0
ANNOUNCE_VERSION = 1
ANNOUNCE_CURRENT_IMAGE= 2
ANNOUNCE_CURRENT_IMAGE = 2
SWITCH_REBOOT_FILE_HANDLING = 5
RESET_REBOOT_COUNTER = 6
SWITCH_IMG_LOCK = 7
@ -41,8 +41,8 @@ class SetId(enum.IntEnum):
class OpCode:
ANNOUNCE_VERSION= "announce_version"
ANNOUNCE_CURRENT_IMAGE= "announce_current_image"
ANNOUNCE_VERSION = "announce_version"
ANNOUNCE_CURRENT_IMAGE = "announce_current_image"
REBOOT_XSC = ["0", "reboot_xsc"]
XSC_REBOOT_SELF = ["1", "reboot_self"]
XSC_REBOOT_0_0 = ["2", "reboot_00"]
@ -155,7 +155,9 @@ def pack_core_commands(q: DefaultPusQueueHelper, op_code: str):
q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_VERSION))
if op_code == OpCode.ANNOUNCE_CURRENT_IMAGE:
q.add_log_cmd(f"{Info.ANNOUNCE_CURRENT_IMAGE}")
q.add_pus_tc(create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_CURRENT_IMAGE))
q.add_pus_tc(
create_action_cmd(CORE_CONTROLLER_ID, ActionId.ANNOUNCE_CURRENT_IMAGE)
)
if op_code in OpCode.REBOOT_XSC:
reboot_self, chip_select, copy_select = determine_reboot_params()
add_xsc_reboot_cmd(