Merge remote-tracking branch 'origin/develop' into mueller/heater-cmds

This commit is contained in:
2022-05-05 00:44:56 +02:00
6 changed files with 335 additions and 505 deletions

View File

@ -50,7 +50,6 @@ event_buffer_path_dict = {
class SupvActionIds:
HK_REPORT = 1
RESTART_MPSOC = 2
START_MPSOC = 3
SHUTWOWN_MPSOC = 4
SEL_MPSOC_BOOT_IMAGE = 5
@ -61,27 +60,19 @@ class SupvActionIds:
DISABLE_HK = 10
GET_BOOT_STATUS_REPORT = 11
UPDATE_AVAILABLE = 12
WATCHDOGS_ENABLE = 13
WATCHDOGS_CONFIG_TIMEOUT = 14
ENABLE_LATCHUP_ALERT = 15
DISABLE_LATCHUP_ALERT = 16
AUTO_CALIBRATE_ALERT = 17
SET_ALERT_LIMIT = 18
SET_ALERT_IRQ_FILTER = 19
SET_ADC_SWEEP_PERIOD = 20
SET_ADC_ENABLED_CHANNELS = 21
SET_ADC_WINDOW_AND_STRIDE = 22
SET_ADC_THRESHOLD = 23
GET_LATCHUP_STATUS_REPORT = 24
COPY_ADC_DATA_TO_MRAM = 25
ENABLE_NVMS = 26
SELECT_NVM = 27
RUN_AUTO_EM_TESTS = 28
WIPE_MRAM = 29
DUMP_MRAM = 30
SET_DBG_VERBOSITY = 31
CAN_LOOPBACK_TEST = 32
PRINT_CPU_STATS = 33
SET_GPIO = 34
READ_GPIO = 35
RESTART_SUPERVISOR = 36
@ -97,8 +88,6 @@ class SupvActionIds:
TERMINATE_SUPV_HELPER = 49
ENABLE_AUTO_TM = 50
DISABLE_AUTO_TM = 51
ENABLE_ADC_MONITOR_TASK = 52
DISABLE_ADC_MONITOR_TASK = 53
LOGGING_REQUEST_EVENT_BUFFERS = 54
LOGGING_CLEAR_COUNTERS = 55
LOGGING_SET_TOPIC = 56
@ -140,11 +129,6 @@ def pack_ploc_supv_commands(
command = object_id + struct.pack("!I", SupvActionIds.HK_REPORT)
command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "4":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Restart MPSoC"))
command = object_id + struct.pack("!I", SupvActionIds.RESTART_MPSOC)
command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "5":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Start MPSoC"))
command = object_id + struct.pack("!I", SupvActionIds.START_MPSOC)
@ -168,9 +152,9 @@ def pack_ploc_supv_commands(
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "8":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Set max restart tries: ")
(QueueCommands.PRINT, "PLOC Supervisor: Set max restart tries")
)
restart_tries = int(input("Set maximum restart tries:"))
restart_tries = int(input("Specify maximum restart tries: "))
command = (
object_id
+ struct.pack("!I", SupvActionIds.SET_MAX_RESTART_TRIES)
@ -192,7 +176,7 @@ def pack_ploc_supv_commands(
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "11":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set boot timeout"))
boot_timeout = int(input("Specify boot timeout [ms]:"))
boot_timeout = int(input("Specify boot timeout [ms]: "))
command = (
object_id
+ struct.pack("!I", SupvActionIds.SET_BOOT_TIMEOUT)
@ -212,23 +196,6 @@ def pack_ploc_supv_commands(
command = object_id + struct.pack("!I", SupvActionIds.GET_BOOT_STATUS_REPORT)
command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "14":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Update available"))
command = pack_update_available_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "15":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Watchdogs Enable"))
command = pack_watchdogs_enable_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "16":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Watchdog configure timeout")
)
command = pack_watchdog_config_timeout_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "17":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Enable latchup alert")
@ -243,32 +210,11 @@ def pack_ploc_supv_commands(
command = pack_lachtup_alert_cmd(object_id, False)
command = PusTelecommand(service=8, subservice=128, ssc=35, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "19":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Auto calibrate alert")
)
command = pack_auto_calibrate_alert_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "20":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set alert limit"))
command = pack_set_alert_limit_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=37, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "21":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Set alert irq filter")
)
command = pack_set_alert_irq_filter_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=38, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "22":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Set ADC sweep period")
)
command = pack_set_adc_sweep_period_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=39, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "23":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Set ADC enabled channels")
@ -312,18 +258,6 @@ def pack_ploc_supv_commands(
command = pack_mram_wipe_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "33":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Print CPU stats"))
command = pack_print_cpu_stats_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=48, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "34":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Set debug verbosity")
)
command = pack_set_debug_verbosity_cmd(object_id)
command = PusTelecommand(service=8, subservice=128, ssc=49, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "35":
tc_queue.appendleft((QueueCommands.PRINT, "PLOC Supervisor: Set GPIO command"))
command = pack_set_gpio_cmd(object_id)
@ -412,20 +346,6 @@ def pack_ploc_supv_commands(
command = object_id + struct.pack("!I", SupvActionIds.DISABLE_AUTO_TM)
command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "49":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Enable ADC monitor task")
)
command = object_id + struct.pack("!I", SupvActionIds.ENABLE_ADC_MONITOR_TASK)
command = PusTelecommand(service=8, subservice=128, ssc=64, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "50":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Disable ADC monitor task")
)
command = object_id + struct.pack("!I", SupvActionIds.DISABLE_ADC_MONITOR_TASK)
command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command)
tc_queue.appendleft(command.pack_command_tuple())
elif op_code == "51":
tc_queue.appendleft(
(QueueCommands.PRINT, "PLOC Supervisor: Logging request event buffers")
@ -558,7 +478,7 @@ def pack_auto_calibrate_alert_cmd(object_id: bytearray) -> bytearray:
@param object_id The object id of the PLOC supervisor handler.
"""
latchup_id = get_latchup_id()
mg = int(input("Specify MG:"))
mg = int(input("Specify MG: "))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.AUTO_CALIBRATE_ALERT)
command = command + struct.pack("!B", latchup_id)
@ -579,7 +499,7 @@ def get_latchup_id() -> int:
key_string = key.ljust(key_column_width)
description_string = latchup_id_dict[key].ljust(description_column_width)
print(f"{key_string} | {description_string}")
return int(input("Specify latchup ID:"))
return int(input("Specify latchup ID: "))
def pack_set_alert_limit_cmd(object_id: bytearray) -> bytearray:
@ -588,7 +508,7 @@ def pack_set_alert_limit_cmd(object_id: bytearray) -> bytearray:
@param object_id The object id of the PLOC supervisor handler.
"""
latchup_id = get_latchup_id()
dutycycle = int(input("Specify dutycycle:"))
dutycycle = int(input("Specify dutycycle: "))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SET_ALERT_LIMIT)
command = command + struct.pack("!B", latchup_id)
@ -596,49 +516,20 @@ def pack_set_alert_limit_cmd(object_id: bytearray) -> bytearray:
return command
def pack_set_alert_irq_filter_cmd(object_id: bytearray) -> bytearray:
"""
@brief This function packs the command to configure the latchup alert irq filter.
@param object_id The object id of the PLOC supervisor handler.
"""
latchup_id = get_latchup_id()
tp = int(input("Specify filter type (TP):"))
div = int(input("Specify clock divider (DIV):"))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SET_ALERT_IRQ_FILTER)
command = command + struct.pack("!B", latchup_id)
command = command + struct.pack("!B", tp)
command = command + struct.pack("!B", div)
return command
def pack_set_adc_sweep_period_cmd(object_id: bytearray) -> bytearray:
"""
@brief This function packs the command to set the limit of a latchup alert.
@param object_id The object id of the PLOC supervisor handler.
"""
sweep_period = int(input("Specify sweep period (min 21 us):"))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SET_ADC_SWEEP_PERIOD)
command = command + struct.pack("!I", sweep_period)
return command
def pack_set_adc_enabled_channels_cmd(object_id: bytearray) -> bytearray:
"""
@brief This function packs the command to enable or disable channels of the ADC.
@param object_id The object id of the PLOC supervisor handler.
"""
ch = int(input("Specify ch: 0x"), 16)
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SET_ADC_ENABLED_CHANNELS)
command = command + struct.pack("!H", ch)
return command
cmd = object_id + struct.pack("!I", SupvActionIds.SET_ADC_ENABLED_CHANNELS)
cmd = cmd + struct.pack("!H", ch)
return cmd
def pack_set_adc_window_and_stride_cmd(object_id: bytearray) -> bytearray:
window_size = int(input("Specify window size:"))
striding_step_size = int(input("Specify striding step size:"))
window_size = int(input("Specify window size: "))
striding_step_size = int(input("Specify striding step size: "))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SET_ADC_WINDOW_AND_STRIDE)
command = command + struct.pack("!H", window_size)
@ -654,18 +545,8 @@ def pack_set_adc_threshold_cmd(object_id: bytearray) -> bytearray:
return command
def pack_enable_nvms_cmd(object_id: bytearray) -> bytearray:
n01 = int(input("NVM0/1 (0 - off, 1 - on):"))
n3 = int(input("NVM3 (0 - off, 1 - on):"))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.ENABLE_NVMS)
command = command + struct.pack("!B", n01)
command = command + struct.pack("!B", n3)
return command
def pack_select_nvm_cmd(object_id: bytearray) -> bytearray:
mem = int(input("Specify NVM (0 - NVM0, 1 - MVM1):"))
mem = int(input("Specify NVM (0 - NVM0, 1 - MVM1): "))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.SELECT_NVM)
command = command + struct.pack("!B", mem)
@ -673,7 +554,7 @@ def pack_select_nvm_cmd(object_id: bytearray) -> bytearray:
def pack_auto_em_tests_cmd(object_id: bytearray) -> bytearray:
test = int(input("Specify test (1 - complete, 2 - short):"))
test = int(input("Specify test (1 - complete, 2 - short): "))
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.RUN_AUTO_EM_TESTS)
command = command + struct.pack("!B", test)
@ -690,22 +571,6 @@ def pack_mram_wipe_cmd(object_id: bytearray) -> bytearray:
return command
def pack_print_cpu_stats_cmd(object_id: bytearray) -> bytearray:
en = 1
command = bytearray()
command = object_id + struct.pack("!I", SupvActionIds.PRINT_CPU_STATS)
command = command + struct.pack("!B", en)
return command
def pack_set_debug_verbosity_cmd(object_id: bytearray) -> bytearray:
command = bytearray()
verbosity = get_debug_verbosity()
command = object_id + struct.pack("!I", SupvActionIds.SET_DBG_VERBOSITY)
command = command + struct.pack("!B", verbosity)
return command
def pack_update_command(object_id: bytearray) -> bytearray:
command = bytearray()
memory_id = int(input("Specify memory ID: "))
@ -739,31 +604,6 @@ def pack_logging_buffer_request(object_id: bytearray) -> bytearray:
return command
def get_debug_verbosity() -> int:
tries = 0
while tries < 3:
try:
print("Debug verbosity options")
verbosity_options_dict = {
0: "None",
1: "Error",
2: "Warn",
3: "Info",
}
print("{:<6} | {}".format("Key", "Description"))
for entry in verbosity_options_dict.items():
print("{:<6} | {}".format(entry[0], entry[1]))
verbosity = int(input("Specify verbosity key: "))
if verbosity > len(verbosity_options_dict) - 1:
raise ValueError
return verbosity
except ValueError:
LOGGER.warning("Invalid verbosity key specified")
tries = tries + 1
LOGGER.error("get_debug_verbosity: Exceeded max tries to input verbosity key")
quit()
def pack_set_gpio_cmd(object_id: bytearray) -> bytearray:
port = int(input("Specify port : 0x"), 16)
pin = int(input("Specify pin: 0x"), 16)