From c50ef12729309f9851d91621e2f289d574735ab8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 29 Jan 2022 18:37:28 +0100 Subject: [PATCH 01/14] star tracker load image processor parameters --- config/hook_implementations.py | 1 + pus_tc/star_tracker.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index af96d27..22d8330 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -330,6 +330,7 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "44": ("Star Tracker: Change download FPGA image name", {OpCodeDictKeys.TIMEOUT: 2.0}), "45": ("Star Tracker: Upload FPGA image", {OpCodeDictKeys.TIMEOUT: 2.0}), "46": ("Star Tracker: FPGA action", {OpCodeDictKeys.TIMEOUT: 2.0}), + "47": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index 82462b0..e622a50 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -28,6 +28,7 @@ class StarTrackerActionIds: DOWNLOAD_CENTROID = 16 UPLOAD_CENTROID = 17 SUBSCRIBE_TO_TM = 18 + IMAGE_PROCESSOR = 19 REQ_SOLUTION = 24 REQ_TEMPERATURE = 25 REQ_HISTOGRAM = 28 @@ -64,7 +65,7 @@ class ImagePathDefs: uploadFile = "/mnt/sd0/startracker/gemma.bin" downloadFile = "test_image.bin" downloadPath = "/mnt/sd0/startracker" - jsonFile = "/mnt/sd0/startracker/test.json" + jsonFile = "/mnt/sd0/startracker/full.json" flashFile = "/mnt/sd0/startracker/flash.bin" flashReadPath = "/mnt/sd0/startracker" uploadCentroidJson = "/mnt/sd0/startracker/upload-centroid.json" @@ -364,6 +365,12 @@ def pack_star_tracker_commands(object_id: bytearray, tc_queue: TcQueueT, op_code command = object_id + struct.pack('!I', StarTrackerActionIds.FPGA_ACTION) + struct.pack('!B', id) command = PusTelecommand(service=8, subservice=128, ssc=69, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "47": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ + bytearray(ImagePathDefs.jsonFile, 'utf-8') + command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) def pack_write_command(object_id: bytearray) -> bytearray: From 7698e92a9478346993ee798ce85ff103f44e881f Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 31 Jan 2022 07:34:20 +0100 Subject: [PATCH 02/14] ccsds handler commands --- config/hook_implementations.py | 4 +++ pus_tc/ccsds_handler.py | 46 ++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 22d8330..dbd42c1 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -340,6 +340,10 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "2": ("CCSDS Handler: Enable transmitter", {OpCodeDictKeys.TIMEOUT: 2.0}), "3": ("CCSDS Handler: Disable transmitter", {OpCodeDictKeys.TIMEOUT: 2.0}), "4": ("CCSDS Handler: Set arbitrary bitrate", {OpCodeDictKeys.TIMEOUT: 2.0}), + "5": ("CCSDS Handler: Enable tx clock manipulator", {OpCodeDictKeys.TIMEOUT: 2.0}), + "6": ("CCSDS Handler: Disable tx clock manipulator", {OpCodeDictKeys.TIMEOUT: 2.0}), + "7": ("CCSDS Handler: Update tx data on rising edge", {OpCodeDictKeys.TIMEOUT: 2.0}), + "8": ("CCSDS Handler: Update tx data on falling edge", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_ccsds_handler_tuple = ("CCSDS Handler", op_code_dict_srv_ccsds_handler) diff --git a/pus_tc/ccsds_handler.py b/pus_tc/ccsds_handler.py index bf9efb0..3dc66e9 100644 --- a/pus_tc/ccsds_handler.py +++ b/pus_tc/ccsds_handler.py @@ -14,16 +14,22 @@ from spacepackets.ecss.tc import PusTelecommand class CommandIds: # Configures input rate of syrlinks to 400 Khz (results in downlink rate of 200 kbps) - SET_LOW_RATE = bytearray([0x0, 0x0, 0x0, 0x0]) + SET_LOW_RATE = 0 # Configures input rate of syrlinks to 2000 Khz (results in downlink rate of 1000 kbps) - SET_HIGH_RATE = bytearray([0x0, 0x0, 0x0, 0x1]) + SET_HIGH_RATE = 1 # Enables the syrlinks transmitter (by using RS485 enables lines) - EN_TRANSMITTER = bytearray([0x0, 0x0, 0x0, 0x2]) + EN_TRANSMITTER = 2 # Disables the syrlinks transmitter (by using RS485 enables lines) - DIS_TRANSMITTER = bytearray([0x0, 0x0, 0x0, 0x3]) + DIS_TRANSMITTER = 3 # Sets an arbitrary bitrate. Normally only set low and set high rate commands should be # required - ARBITRARY_BITRATE = bytearray([0x0, 0x0, 0x0, 0x4]) + ARBITRARY_BITRATE = 4 + ENABLE_TX_CLK_MANIPULATOR = 5 + DISABLE_TX_CLK_MANIPULATOR = 6 + # Tx data will be updated on rising edge of tx clock + UPDATE_ON_RISING_EDGE = 7 + # Tx data will be updated on falling edge of tx clock + UPDATE_ON_FALLING_EDGE = 8 def pack_ccsds_handler_test(object_id: bytearray, tc_queue: TcQueueT, op_code: str) -> TcQueueT: @@ -33,28 +39,48 @@ def pack_ccsds_handler_test(object_id: bytearray, tc_queue: TcQueueT, op_code: s ) if op_code == "0": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set low rate")) - command = object_id + CommandIds.SET_LOW_RATE + command = object_id + struct.pack('!I', CommandIds.SET_LOW_RATE) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "1": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set high rate")) - command = object_id + CommandIds.SET_HIGH_RATE + command = object_id + struct.pack('!I', CommandIds.SET_HIGH_RATE) command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "2": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enables the transmitter")) - command = object_id + CommandIds.EN_TRANSMITTER + command = object_id + struct.pack('!I', CommandIds.EN_TRANSMITTER) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "3": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disables the transmitter")) - command = object_id + CommandIds.DIS_TRANSMITTER + command = object_id + struct.pack('!I', CommandIds.DIS_TRANSMITTER) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "4": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set arbitrary bitrate")) bitrate = int(input("Specify bit rate (bps): ")) - command = object_id + CommandIds.ARBITRARY_BITRATE + struct.pack('!I', bitrate) + command = object_id + struct.pack('!I', CommandIds.ARBITRARY_BITRATE) + struct.pack('!I', bitrate) + command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "5": + tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enable tx clock manipulator")) + command = object_id + struct.pack('!I', CommandIds.ENABLE_TX_CLK_MANIPULATOR) + command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "6": + tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disable tx clock manipulator")) + command = object_id + struct.pack('!I', CommandIds.DISABLE_TX_CLK_MANIPULATOR) + command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "7": + tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on rising edge of tx clock")) + command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_RISING_EDGE) + command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "8": + tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on falling edge of tx clock")) + command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_FALLING_EDGE) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) From 8da50e2c3f709def5b26fd9df1cd23beac35482e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Feb 2022 09:44:27 +0100 Subject: [PATCH 03/14] submdule update --- spacepackets | 2 +- tmtccmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spacepackets b/spacepackets index 0039a0e..3265de6 160000 --- a/spacepackets +++ b/spacepackets @@ -1 +1 @@ -Subproject commit 0039a0ec67217765b9dabfbc35dcb34b6ff81c08 +Subproject commit 3265de69717e2f718f4c740d77a823f9811f8348 diff --git a/tmtccmd b/tmtccmd index bfa459c..7b8b936 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit bfa459ccc3c7189a77374a68f0217d448525b34b +Subproject commit 7b8b936f0d18fdbd375da92d43ecdd37d71ded57 From 1702d895761311d115c2e79b459b4a6d6843fc97 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 15:03:02 +0100 Subject: [PATCH 04/14] added bpx handling, reworked srv3/8 returnvalues --- .idea/runConfigurations/BPX_Request_HK.xml | 24 ++++ .../BPX_Reset_Reboot_Counter.xml | 24 ++++ config/definitions.py | 1 + config/hook_implementations.py | 8 +- config/object_ids.py | 1 + pus_tc/bpx_batt.py | 31 ++++ pus_tc/tc_packer_hook.py | 3 + pus_tm/hk_handling.py | 135 ++++++++++++------ pus_tm/service_8_hook.py | 61 ++++---- tmtccmd | 2 +- 10 files changed, 207 insertions(+), 83 deletions(-) create mode 100644 .idea/runConfigurations/BPX_Request_HK.xml create mode 100644 .idea/runConfigurations/BPX_Reset_Reboot_Counter.xml create mode 100644 pus_tc/bpx_batt.py diff --git a/.idea/runConfigurations/BPX_Request_HK.xml b/.idea/runConfigurations/BPX_Request_HK.xml new file mode 100644 index 0000000..9783034 --- /dev/null +++ b/.idea/runConfigurations/BPX_Request_HK.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations/BPX_Reset_Reboot_Counter.xml b/.idea/runConfigurations/BPX_Reset_Reboot_Counter.xml new file mode 100644 index 0000000..6d0b32d --- /dev/null +++ b/.idea/runConfigurations/BPX_Reset_Reboot_Counter.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/config/definitions.py b/config/definitions.py index 990b4c1..3a104aa 100644 --- a/config/definitions.py +++ b/config/definitions.py @@ -17,6 +17,7 @@ class CustomServiceList(enum.Enum): PDU2 = "pdu2" ACU = "acu" ACS = "acs" + BPX_BATTERY = "bpx" TMP1075_1 = "tmp1075_1" TMP1075_2 = "tmp1075_2" HEATER = "heater" diff --git a/config/hook_implementations.py b/config/hook_implementations.py index c3c7663..872ea4e 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -1,7 +1,7 @@ import argparse from typing import Union, Dict, Tuple -from tmtccmd.config.definitions import ServiceOpCodeDictT +from tmtccmd.config.definitions import ServiceOpCodeDictT, HkReplyUnpacked, DataReplyUnpacked from tmtccmd.tm.service_3_base import Service3Base from tmtccmd.tc.definitions import TcQueueT from tmtccmd.com_if.com_interface_base import CommunicationInterface @@ -79,9 +79,8 @@ class EiveHookObject(TmTcHookBase): @staticmethod def handle_service_8_telemetry( object_id: bytes, action_id: int, custom_data: bytearray - ) -> Tuple[list, list]: + ) -> DataReplyUnpacked: from pus_tm.service_8_hook import user_analyze_service_8_data - return user_analyze_service_8_data( object_id=object_id, action_id=action_id, custom_data=custom_data ) @@ -89,9 +88,8 @@ class EiveHookObject(TmTcHookBase): @staticmethod def handle_service_3_housekeeping( object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base - ) -> Tuple[list, list, bytearray, int]: + ) -> HkReplyUnpacked: from pus_tm.hk_handling import handle_user_hk_packet - return handle_user_hk_packet( object_id=object_id, set_id=set_id, diff --git a/config/object_ids.py b/config/object_ids.py index 387418a..2bbe62d 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -15,6 +15,7 @@ P60_DOCK_HANDLER = bytes([0x44, 0x25, 0x00, 0x00]) PDU_1_HANDLER_ID = bytes([0x44, 0x25, 0x00, 0x01]) PDU_2_HANDLER_ID = bytes([0x44, 0x25, 0x00, 0x02]) ACU_HANDLER_ID = bytes([0x44, 0x25, 0x00, 0x03]) +BPX_HANDLER_ID = bytes([0x44, 0x26, 0x00, 0x00]) # Thermal Object IDs HEATER_ID = bytes([0x44, 0x41, 0x00, 0xA4]) diff --git a/pus_tc/bpx_batt.py b/pus_tc/bpx_batt.py new file mode 100644 index 0000000..2a5a475 --- /dev/null +++ b/pus_tc/bpx_batt.py @@ -0,0 +1,31 @@ +from tmtccmd.tc.definitions import TcQueueT, QueueCommands +from config.object_ids import BPX_HANDLER_ID +from tmtccmd.tc.service_8_functional_cmd import generate_action_command +from tmtccmd.tc.service_3_housekeeping import generate_one_hk_command, make_sid + + +class BpxSetIds: + GET_HK_SET = 0 + GET_CFG_SET = 5 + + +class BpxActionIds: + REBOOT = 2 + RESET_COUNTERS = 3 + SET_CFG = 4 + GET_CFG = 5 + + +def pack_bpx_commands(tc_queue: TcQueueT, op_code: str): + if op_code in ["0", "hk"]: + tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX battery HK set")) + sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET) + cmd = generate_one_hk_command(sid=sid, ssc=0) + tc_queue.appendleft(cmd.pack_command_tuple()) + if op_code in ["1", "rst_boot_cnt"]: + tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters")) + cmd = generate_action_command( + object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS + ) + tc_queue.appendleft(cmd.pack_command_tuple()) + pass diff --git a/pus_tc/tc_packer_hook.py b/pus_tc/tc_packer_hook.py index 853953c..0989deb 100644 --- a/pus_tc/tc_packer_hook.py +++ b/pus_tc/tc_packer_hook.py @@ -14,6 +14,7 @@ from pus_tc.service_200_mode import pack_service200_test_into from pus_tc.p60dock import pack_p60dock_test_into from pus_tc.pdu2 import pack_pdu2_commands from pus_tc.pdu1 import pack_pdu1_commands +from pus_tc.bpx_batt import pack_bpx_commands from pus_tc.acu import pack_acu_test_into from pus_tc.imtq import pack_imtq_test_into from pus_tc.tmp1075 import pack_tmp1075_test_into @@ -94,6 +95,8 @@ def pack_service_queue_user( return pack_acu_test_into( object_id=object_id, tc_queue=service_queue, op_code=op_code ) + if service == CustomServiceList.BPX_BATTERY.value: + return pack_bpx_commands(tc_queue=service_queue, op_code=op_code) if service == CustomServiceList.TMP1075_1.value: object_id = TMP_1075_1_HANDLER_ID return pack_tmp1075_test_into( diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index cb6896a..075de72 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -2,8 +2,8 @@ import struct import os import datetime -from typing import Tuple +from tmtccmd.config.definitions import HkReplyUnpacked from tmtccmd.tm.service_3_housekeeping import Service3Base from tmtccmd.utility.logger import get_console_logger from pus_tc.syrlinks_hk_handler import SetIds @@ -13,6 +13,7 @@ from config.object_ids import ( IMTQ_HANDLER_ID, GPS_HANDLER_0_ID, GPS_HANDLER_1_ID, + BPX_HANDLER_ID ) LOGGER = get_console_logger() @@ -20,7 +21,7 @@ LOGGER = get_console_logger() def handle_user_hk_packet( object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base -) -> Tuple[list, list, bytearray, int]: +) -> HkReplyUnpacked: """This function is called when a Service 3 Housekeeping packet is received.""" if object_id == SYRLINKS_HANDLER_ID: if set_id == SetIds.RX_REGISTERS_DATASET: @@ -29,7 +30,6 @@ def handle_user_hk_packet( return handle_syrlinks_tx_registers_dataset(hk_data) else: LOGGER.info("Serive 3 TM: Syrlinks handler reply with unknown set id") - return [], [], bytearray(), 0 elif object_id == IMTQ_HANDLER_ID: if (set_id >= ImtqSetIds.POSITIVE_X_TEST) and ( set_id <= ImtqSetIds.NEGATIVE_Z_TEST @@ -37,21 +37,20 @@ def handle_user_hk_packet( return handle_self_test_data(hk_data) else: LOGGER.info("Serive 3 TM: Syrlinks handler reply with unknown set id") - return [], [], bytearray(), 0 elif object_id == GPS_HANDLER_0_ID or object_id == GPS_HANDLER_1_ID: return handle_gps_data(hk_data=hk_data) + elif object_id == BPX_HANDLER_ID: + return handle_bpx_hk_data(hk_data=hk_data) else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") - return [], [], bytearray(), 0 + return HkReplyUnpacked() def handle_syrlinks_rx_registers_dataset( hk_data: bytearray, -) -> Tuple[list, list, bytearray, int]: - hk_header = [] - hk_content = [] - validity_buffer = bytearray() - hk_header = [ +) -> HkReplyUnpacked: + reply = HkReplyUnpacked() + reply.header_list = [ "RX Status", "RX Sensitivity", "RX Frequency Shift", @@ -69,7 +68,7 @@ def handle_syrlinks_rx_registers_dataset( rx_demod_eb = struct.unpack("!I", hk_data[13:17]) rx_demod_n0 = struct.unpack("!I", hk_data[17:21]) rx_data_rate = hk_data[21] - hk_content = [ + reply.content_list = [ rx_status, rx_sensitivity, rx_frequency_shift, @@ -79,28 +78,28 @@ def handle_syrlinks_rx_registers_dataset( rx_demod_n0, rx_data_rate, ] - return hk_header, hk_content, validity_buffer, 8 + reply.validity_buffer = hk_data[22:] + reply.num_of_vars = 8 + return reply def handle_syrlinks_tx_registers_dataset( hk_data: bytearray, -) -> Tuple[list, list, bytearray, int]: - hk_header = [] - hk_content = [] - validity_buffer = bytearray() - hk_header = ["TX Status", "TX Waveform", "TX AGC value"] +) -> HkReplyUnpacked: + reply = HkReplyUnpacked() + reply.header_list = ["TX Status", "TX Waveform", "TX AGC value"] tx_status = hk_data[0] tx_waveform = hk_data[1] tx_agc_value = struct.unpack("!H", hk_data[2:4]) - hk_content = [tx_status, tx_waveform, tx_agc_value] - return hk_header, hk_content, validity_buffer, 3 + reply.content_list = [tx_status, tx_waveform, tx_agc_value] + reply.validity_buffer = hk_data[4:] + reply.num_of_vars = 3 + return reply -def handle_self_test_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]: - hk_header = [] - hk_content = [] - validity_buffer = bytearray() - hk_header = [ +def handle_self_test_data(hk_data: bytearray) -> HkReplyUnpacked: + reply = HkReplyUnpacked() + reply.hk_header = [ "Init Err", "Init Raw Mag X [nT]", "Init Raw Mag Y [nT]", @@ -186,7 +185,8 @@ def handle_self_test_data(hk_data: bytearray) -> Tuple[list, list, bytearray, in fina_coil_y_temperature = struct.unpack("!H", hk_data[125:127])[0] fina_coil_z_temperature = struct.unpack("!H", hk_data[127:129])[0] - hk_content = [ + reply.validity_buffer = hk_data[129:] + reply.content_list = [ init_err, init_raw_mag_x, init_raw_mag_y, @@ -227,43 +227,49 @@ def handle_self_test_data(hk_data: bytearray) -> Tuple[list, list, bytearray, in fina_coil_y_temperature, fina_coil_z_temperature, ] - - return hk_header, hk_content, validity_buffer, len(hk_header) + reply.num_of_vars = len(reply.hk_header) + return reply -def handle_gps_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]: +def handle_gps_data(hk_data: bytearray) -> HkReplyUnpacked: LOGGER.info(f"Received GPS data, HK data length {len(hk_data)}") + reply = HkReplyUnpacked() var_index = 0 header_array = [] content_array = [] + reply.header_list = [ + "Latitude", + "Longitude", + "Altitude", + "Fix Mode", + "Sats in Use", + "Date", + "Unix Seconds" + ] latitude = struct.unpack("!d", hk_data[0:8])[0] - header_array.append("Latitude") - content_array.append(latitude) longitude = struct.unpack("!d", hk_data[8:16])[0] - header_array.append("Longitude") - content_array.append(longitude) altitude = struct.unpack("!d", hk_data[16:24])[0] - header_array.append("Altitude") - content_array.append(altitude) fix_mode = hk_data[24] - header_array.append("Fix Mode") - content_array.append(fix_mode) sat_in_use = hk_data[25] - header_array.append("Sats in Use") - content_array.append(sat_in_use) year = struct.unpack("!H", hk_data[26:28])[0] month = hk_data[28] day = hk_data[29] hours = hk_data[30] minutes = hk_data[31] seconds = hk_data[32] - header_array.append("Date") date_string = f"{day}.{month}.{year} {hours}:{minutes}:{seconds}" - content_array.append(date_string) unix_seconds = struct.unpack("!I", hk_data[33:37])[0] - header_array.append("Unix Seconds") - content_array.append(unix_seconds) + content_array = [ + latitude, + longitude, + altitude, + fix_mode, + sat_in_use, + date_string, + unix_seconds + ] var_index += 13 + reply.num_of_vars = var_index if not os.path.isfile("gps_log.txt"): with open("gps_log.txt", "w") as gps_file: gps_file.write( @@ -275,5 +281,46 @@ def handle_gps_data(hk_data: bytearray) -> Tuple[list, list, bytearray, int]: f"{datetime.datetime.now()}, {latitude}, {longitude}, {altitude}, " f"{fix_mode}, {sat_in_use}, {date_string}, {unix_seconds}\n" ) - validity_buffer = hk_data[37:39] - return header_array, content_array, validity_buffer, var_index + reply.validity_buffer = hk_data[37:39] + return reply + + +def handle_bpx_hk_data(hk_data: bytes) -> HkReplyUnpacked: + LOGGER.info(f"Received BPX data, HK data length {len(hk_data)}") + reply = HkReplyUnpacked() + charge_current = struct.unpack('!H', hk_data[0:2])[0] + discharge_current = struct.unpack('!H', hk_data[2:4])[0] + heater_current = struct.unpack('!H', hk_data[4:6])[0] + batt_voltage = struct.unpack('!H', hk_data[6:8])[0] + batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0] + batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0] + batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0] + batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0] + reboot_cntr = struct.unpack('!I', hk_data[16:20])[0] + boot_cause = hk_data[20] + reply.header_list = [ + "Charge Current", + "Discharge Current", + "Heater Current", + "Battery Voltage", + "Batt Temp 1", + "Batt Temp 2", + "Batt Temp 3", + "Batt Temp 4", + "Reboot Counter", + "Boot Cause" + ] + reply.content_list = [ + charge_current, + discharge_current, + heater_current, + batt_voltage, + batt_temp_1, + batt_temp_2, + batt_temp_3, + batt_temp_4, + reboot_cntr, + boot_cause + ] + reply.validity_buffer = hk_data[21:] + return reply diff --git a/pus_tm/service_8_hook.py b/pus_tm/service_8_hook.py index f1910b6..b157092 100644 --- a/pus_tm/service_8_hook.py +++ b/pus_tm/service_8_hook.py @@ -1,18 +1,18 @@ import struct -from typing import Tuple from config.object_ids import * from pus_tc.imtq import ImtqActionIds from pus_tc.ploc_mpsoc import PlocReplyIds from pus_tc.ploc_supervisor import SupvActionIds from pus_tc.star_tracker import StarTrackerActionIds from tmtccmd.utility.logger import get_console_logger +from tmtccmd.config.definitions import DataReplyUnpacked LOGGER = get_console_logger() def user_analyze_service_8_data( object_id: bytes, action_id: int, custom_data: bytearray -) -> Tuple[list, list]: +) -> DataReplyUnpacked: """ This function is called by the TMTC core if a Service 8 data reply (subservice 130) is received. The user can return a tuple of two lists, where the first list @@ -25,15 +25,16 @@ def user_analyze_service_8_data( @return: """ if object_id == PDU_2_HANDLER_ID: - header_list = ["PDU2 Service 8 Reply"] - + reply = DataReplyUnpacked() + reply.header_list = ["PDU2 Service 8 Reply"] data_string = str() for index in range(len(custom_data)): data_string += str(hex(custom_data[index])) + " , " data_string = data_string.rstrip() data_string = data_string.rstrip(",") data_string = data_string.rstrip() - content_list = [data_string] + reply.content_list = [data_string] + return reply elif object_id == IMTQ_HANDLER_ID: return handle_imtq_replies(action_id, custom_data) elif object_id == PLOC_MPSOC_ID: @@ -42,56 +43,50 @@ def user_analyze_service_8_data( return handle_supervisor_replies(action_id, custom_data) elif object_id == STAR_TRACKER_ID: return handle_startracker_replies(action_id, custom_data) - else: - header_list = [] - content_list = [] - return header_list, content_list + return DataReplyUnpacked() -def handle_imtq_replies(action_id: int, custom_data: bytearray) -> Tuple[list, list]: - header_list = [] - content_list = [] +def handle_imtq_replies(action_id: int, custom_data: bytearray) -> DataReplyUnpacked: + reply = DataReplyUnpacked() if action_id == struct.unpack("!I", ImtqActionIds.get_commanded_dipole)[0]: - header_list = ["Commanded X-Dipole", "Commanded Y-Dipole", "Commanded Z-Dipole"] + reply.header_list = ["Commanded X-Dipole", "Commanded Y-Dipole", "Commanded Z-Dipole"] x_dipole = struct.unpack("!H", custom_data[:2]) y_dipole = struct.unpack("!H", custom_data[2:4]) z_dipole = struct.unpack("!H", custom_data[4:6]) - content_list = [x_dipole[0], y_dipole[0], z_dipole[0]] + reply.content_list = [x_dipole[0], y_dipole[0], z_dipole[0]] + return reply -def handle_ploc_replies(action_id: int, custom_data: bytearray) -> Tuple[list, list]: - header_list = [] - content_list = [] +def handle_ploc_replies(action_id: int, custom_data: bytearray) -> DataReplyUnpacked: + reply = DataReplyUnpacked() if action_id == PlocReplyIds.tm_mem_read_report: - header_list = ["PLOC Memory Address", "PLOC Mem Len", "PLOC Read Memory Data"] - content_list = [custom_data[:4], custom_data[4:6], custom_data[6:10]] - return header_list, content_list + reply.header_list = ["PLOC Memory Address", "PLOC Mem Len", "PLOC Read Memory Data"] + reply.content_list = [custom_data[:4], custom_data[4:6], custom_data[6:10]] + return reply def handle_supervisor_replies( action_id: int, custom_data: bytearray -) -> Tuple[list, list]: - header_list = [] - content_list = [] +) -> DataReplyUnpacked: + reply = DataReplyUnpacked() if action_id == SupvActionIds.DUMP_MRAM: - header_list = ["MRAM Dump"] - content_list = [custom_data[: len(custom_data)]] - return header_list, content_list + reply.header_list = ["MRAM Dump"] + reply.content_list = [custom_data[: len(custom_data)]] + return reply def handle_startracker_replies( action_id: int, custom_data: bytearray -) -> Tuple[list, list]: - header_list = [] - content_list = [] +) -> DataReplyUnpacked: + reply = DataReplyUnpacked() if action_id == StarTrackerActionIds.CHECKSUM: if len(custom_data) != 5: LOGGER.warning( "Star tracker reply has invalid length {0}".format(len(custom_data)) ) - return header_list, content_list - header_list = ["Checksum", "Checksum valid"] + return reply + reply.header_list = ["Checksum", "Checksum valid"] print(custom_data[4]) checksum_valid_flag = custom_data[4] >> 8 - content_list = ["0x" + custom_data[:4].hex(), checksum_valid_flag] - return header_list, content_list + reply.content_list = ["0x" + custom_data[:4].hex(), checksum_valid_flag] + return reply diff --git a/tmtccmd b/tmtccmd index 7b8b936..683ae40 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 7b8b936f0d18fdbd375da92d43ecdd37d71ded57 +Subproject commit 683ae401c7b4b2503bd91f23c3e069ced1b0db9c From 890a20a07895bc1d06ad49f281a107a042a5dd03 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 15:30:58 +0100 Subject: [PATCH 05/14] handling for bpx cfg set --- pus_tc/bpx_batt.py | 11 ++++++ pus_tm/hk_handling.py | 91 +++++++++++++++++++++++++------------------ tmtccmd | 2 +- 3 files changed, 66 insertions(+), 38 deletions(-) diff --git a/pus_tc/bpx_batt.py b/pus_tc/bpx_batt.py index 2a5a475..a69978a 100644 --- a/pus_tc/bpx_batt.py +++ b/pus_tc/bpx_batt.py @@ -28,4 +28,15 @@ def pack_bpx_commands(tc_queue: TcQueueT, op_code: str): object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS ) tc_queue.appendleft(cmd.pack_command_tuple()) + if op_code in ["2", "cfg"]: + tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters")) + cmd = generate_action_command( + object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG + ) + tc_queue.appendleft(cmd.pack_command_tuple()) + if op_code in ["3", "cfg_hk"]: + tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX Configuration Struct")) + sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET) + cmd = generate_one_hk_command(sid=sid, ssc=0) + tc_queue.appendleft(cmd.pack_command_tuple()) pass diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 075de72..cf78f16 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -6,6 +6,7 @@ import datetime from tmtccmd.config.definitions import HkReplyUnpacked from tmtccmd.tm.service_3_housekeeping import Service3Base from tmtccmd.utility.logger import get_console_logger +from pus_tc.bpx_batt import BpxSetIds from pus_tc.syrlinks_hk_handler import SetIds from pus_tc.imtq import ImtqSetIds from config.object_ids import ( @@ -40,7 +41,7 @@ def handle_user_hk_packet( elif object_id == GPS_HANDLER_0_ID or object_id == GPS_HANDLER_1_ID: return handle_gps_data(hk_data=hk_data) elif object_id == BPX_HANDLER_ID: - return handle_bpx_hk_data(hk_data=hk_data) + return handle_bpx_hk_data(hk_data=hk_data, set_id=set_id) else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") return HkReplyUnpacked() @@ -285,42 +286,58 @@ def handle_gps_data(hk_data: bytearray) -> HkReplyUnpacked: return reply -def handle_bpx_hk_data(hk_data: bytes) -> HkReplyUnpacked: +def handle_bpx_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: LOGGER.info(f"Received BPX data, HK data length {len(hk_data)}") reply = HkReplyUnpacked() - charge_current = struct.unpack('!H', hk_data[0:2])[0] - discharge_current = struct.unpack('!H', hk_data[2:4])[0] - heater_current = struct.unpack('!H', hk_data[4:6])[0] - batt_voltage = struct.unpack('!H', hk_data[6:8])[0] - batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0] - batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0] - batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0] - batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0] - reboot_cntr = struct.unpack('!I', hk_data[16:20])[0] - boot_cause = hk_data[20] - reply.header_list = [ - "Charge Current", - "Discharge Current", - "Heater Current", - "Battery Voltage", - "Batt Temp 1", - "Batt Temp 2", - "Batt Temp 3", - "Batt Temp 4", - "Reboot Counter", - "Boot Cause" - ] - reply.content_list = [ - charge_current, - discharge_current, - heater_current, - batt_voltage, - batt_temp_1, - batt_temp_2, - batt_temp_3, - batt_temp_4, - reboot_cntr, - boot_cause - ] - reply.validity_buffer = hk_data[21:] + if set_id == BpxSetIds.GET_HK_SET: + charge_current = struct.unpack('!H', hk_data[0:2])[0] + discharge_current = struct.unpack('!H', hk_data[2:4])[0] + heater_current = struct.unpack('!H', hk_data[4:6])[0] + batt_voltage = struct.unpack('!H', hk_data[6:8])[0] + batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0] + batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0] + batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0] + batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0] + reboot_cntr = struct.unpack('!I', hk_data[16:20])[0] + boot_cause = hk_data[20] + reply.header_list = [ + "Charge Current", + "Discharge Current", + "Heater Current", + "Battery Voltage", + "Batt Temp 1", + "Batt Temp 2", + "Batt Temp 3", + "Batt Temp 4", + "Reboot Counter", + "Boot Cause" + ] + reply.content_list = [ + charge_current, + discharge_current, + heater_current, + batt_voltage, + batt_temp_1, + batt_temp_2, + batt_temp_3, + batt_temp_4, + reboot_cntr, + boot_cause + ] + reply.validity_buffer = hk_data[21:] + elif set_id == BpxSetIds.GET_CFG_SET: + battheat_mode = hk_data[0] + battheat_low = struct.unpack('!b', hk_data[1:2])[0] + battheat_high = struct.unpack('!b', hk_data[2:3])[0] + reply.header_list = [ + "Battery Heater Mode", + "Battery Heater Low Limit", + "Battery Heater High Limit" + ] + reply.content_list = [ + battheat_mode, + battheat_low, + battheat_high + ] + reply.validity_buffer = hk_data[3:] return reply diff --git a/tmtccmd b/tmtccmd index 683ae40..892d131 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 683ae401c7b4b2503bd91f23c3e069ced1b0db9c +Subproject commit 892d13117f0e3c6d598f157668bff9ed6b31574d From 2b89a7f2697a21e9fc9101ca320afb7bf49c8e9d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 16:02:55 +0100 Subject: [PATCH 06/14] extracted some command definitions --- .idea/runConfigurations/BPX.xml | 24 ++++ config/cmd_definitions.py | 213 +++++++++++++++++++++++++++++ config/hook_implementations.py | 228 +++++--------------------------- pus_tc/bpx_batt.py | 26 +++- pus_tc/ccsds_handler.py | 52 +++++--- pus_tc/star_tracker.py | 11 +- pus_tm/hk_handling.py | 40 +++--- pus_tm/service_8_hook.py | 12 +- tmtccmd | 2 +- 9 files changed, 367 insertions(+), 241 deletions(-) create mode 100644 .idea/runConfigurations/BPX.xml create mode 100644 config/cmd_definitions.py diff --git a/.idea/runConfigurations/BPX.xml b/.idea/runConfigurations/BPX.xml new file mode 100644 index 0000000..a1fc5d3 --- /dev/null +++ b/.idea/runConfigurations/BPX.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/config/cmd_definitions.py b/config/cmd_definitions.py new file mode 100644 index 0000000..7ffac58 --- /dev/null +++ b/config/cmd_definitions.py @@ -0,0 +1,213 @@ +from tmtccmd.config import ( + add_op_code_entry, + add_service_op_code_entry, + ServiceOpCodeDictT, + OpCodeDictKeys, +) +from config.definitions import CustomServiceList +from pus_tc.bpx_batt import BpxOpCodes + + +def add_bpx_cmd_definitions(cmd_dict: ServiceOpCodeDictT): + op_code_dict = dict() + add_op_code_entry( + op_code_dict=op_code_dict, keys=BpxOpCodes.HK, info="Request BPX HK" + ) + add_op_code_entry( + op_code_dict=op_code_dict, keys=BpxOpCodes.RST_BOOT_CNT, info="Reset Boot Count" + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=BpxOpCodes.REQUEST_CFG, + info="Request Configuration Struct (Step 1)", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=BpxOpCodes.REQUEST_CFG_HK, + info="Request Configuration Struct HK (Step 2)", + ) + add_op_code_entry( + op_code_dict=op_code_dict, keys=BpxOpCodes.REBOOT, info="Reboot Command" + ) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.BPX_BATTERY.value, + info="BPX Battery Handler", + op_code_entry=op_code_dict, + ) + + +def add_core_controller_definitions(cmd_dict: ServiceOpCodeDictT): + od = dict() + add_op_code_entry(op_code_dict=od, keys=["0", "reboot"], info="Reboot with Prompt") + add_op_code_entry(op_code_dict=od, keys=["1", "reboot_0_0"], info="Reboot 0 0") + add_op_code_entry(op_code_dict=od, keys=["2", "reboot_0_1"], info="Reboot 0 1") + add_op_code_entry(op_code_dict=od, keys=["3", "reboot_1_0"], info="Reboot 1 0") + add_op_code_entry(op_code_dict=od, keys=["4", "reboot_1_1"], info="Reboot 1 1") + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.CORE.value, + info="Reboot Self", + op_code_entry=od, + ) + + +def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): + from pus_tc.p60dock import P60OpCodes, GomspaceOpCodes + from pus_tc.pdu1 import Pdu1OpCodes + from pus_tc.pdu2 import Pdu2OpCodes + + op_code_dict = dict() + add_op_code_entry(op_code_dict=op_code_dict, keys="0", info="P60 Tests") + add_op_code_entry( + op_code_dict=op_code_dict, + keys=P60OpCodes.STACK_3V3_ON.value, + info="P60 Dock: Turn stack 3V3 on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=P60OpCodes.STACK_3V3_OFF.value, + info="P60 Dock: Turn stack 3V3 off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=P60OpCodes.STACK_5V_ON.value, + info="P60 Dock: Turn stack 5V on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=P60OpCodes.STACK_5V_OFF.value, + info="P60 Dock: Turn stack 5V off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + info="P60 Dock: Print Switches, Voltages, Currents", + ) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.P60DOCK.value, + info="P60 Device", + op_code_entry=op_code_dict, + ) + + op_code_dict_srv_pdu1 = { + "0": ("PDU1 Tests", {OpCodeDictKeys.TIMEOUT: 2.0}), + Pdu1OpCodes.TCS_BOARD_ON.value: ( + "PDU1: Turn TCS board on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.TCS_BOARD_OFF.value: ( + "PDU1: Turn TCS board off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.STAR_TRACKER_ON.value: ( + "PDU1: Turn star tracker on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.STAR_TRACKER_OFF.value: ( + "PDU1: Turn star tracker off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.SUS_NOMINAL_ON.value: ( + "PDU1: Turn SUS nominal on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.SUS_NOMINAL_OFF.value: ( + "PDU1: Turn SUS nominal off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.ACS_A_SIDE_ON.value: ( + "PDU1: Turn ACS Side A on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.ACS_A_SIDE_OFF.value: ( + "PDU1: Turn ACS Side A off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.SYRLINKS_ON.value: ( + "PDU1: Turn Syrlinks on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.SYRLINKS_OFF.value: ( + "PDU1: Turn Syrlinks off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.MGT_ON.value: ( + "PDU1: Turn MGT on", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + Pdu1OpCodes.MGT_OFF.value: ( + "PDU1: Turn MGT off", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + GomspaceOpCodes.PRINT_SWITCH_V_I.value: ( + "PDU1: Print Switches, Voltages, Currents", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + } + service_pdu1_tuple = ("PDU1 Device", op_code_dict_srv_pdu1) + cmd_dict[CustomServiceList.PDU1.value] = service_pdu1_tuple + + op_code_dict = dict() + add_op_code_entry( + op_code_dict=op_code_dict, + keys="0", + info="PDU2 Tests", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.ACS_SIDE_B_ON.value, + info="PDU2: Turn ACS Side B on", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.ACS_SIDE_B_OFF.value, + info="PDU2: Turn ACS Side B off", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.SUS_REDUNDANT_ON.value, + info="PDU2: Turn SUS redundant on", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.SUS_REDUNDANT_OFF.value, + info="PDU2: Turn SUS redundant off", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.RW_ON.value, + info="PDU2: Turn reaction wheels on", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.RW_OFF.value, + info="PDU2: Turn reaction wheels off", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu2OpCodes.Q7S_OFF.value, + info="Q7S Off", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + info="PDU2: Print Switches, Voltages, Currents", + options={OpCodeDictKeys.TIMEOUT: 2.0}, + ) + + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name="pdu2", + info="PDU2 Device", + op_code_entry=op_code_dict, + ) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 872ea4e..9fa73ef 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -1,18 +1,18 @@ import argparse from typing import Union, Dict, Tuple -from tmtccmd.config.definitions import ServiceOpCodeDictT, HkReplyUnpacked, DataReplyUnpacked +from tmtccmd.config.definitions import ( + ServiceOpCodeDictT, + HkReplyUnpacked, + DataReplyUnpacked, +) from tmtccmd.tm.service_3_base import Service3Base from tmtccmd.tc.definitions import TcQueueT from tmtccmd.com_if.com_interface_base import CommunicationInterface from tmtccmd.core.backend import TmTcHandler from tmtccmd.config.hook import TmTcHookBase from tmtccmd.utility.tmtc_printer import TmTcPrinter -from tmtccmd.config.globals import ( - OpCodeDictKeys, - add_op_code_entry, - add_service_op_code_entry, -) +from tmtccmd.config.globals import OpCodeDictKeys from config.object_ids import RW1_ID from config.definitions import CustomServiceList @@ -81,6 +81,7 @@ class EiveHookObject(TmTcHookBase): object_id: bytes, action_id: int, custom_data: bytearray ) -> DataReplyUnpacked: from pus_tm.service_8_hook import user_analyze_service_8_data + return user_analyze_service_8_data( object_id=object_id, action_id=action_id, custom_data=custom_data ) @@ -90,6 +91,7 @@ class EiveHookObject(TmTcHookBase): object_id: bytes, set_id: int, hk_data: bytearray, service3_packet: Service3Base ) -> HkReplyUnpacked: from pus_tm.hk_handling import handle_user_hk_packet + return handle_user_hk_packet( object_id=object_id, set_id=set_id, @@ -108,22 +110,15 @@ class EiveHookObject(TmTcHookBase): def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): - from pus_tc.pdu1 import Pdu1OpCodes - from pus_tc.pdu2 import Pdu2OpCodes - from pus_tc.p60dock import P60OpCodes - from gomspace.gomspace_common import GomspaceOpCodes + from config.cmd_definitions import ( + add_bpx_cmd_definitions, + add_core_controller_definitions, + add_pcdu_cmds, + ) from pus_tc.gps import GpsOpCodes - op_code_dict = { - "reboot": ("Reboot with Prompt", {OpCodeDictKeys.TIMEOUT: 2.0}), - "reboot_self": ("Reboot Self", {OpCodeDictKeys.TIMEOUT: 4.0}), - "reboot_0_0": ("Reboot 0 0", {OpCodeDictKeys.TIMEOUT: 4.0}), - "reboot_0_1": ("Reboot 0 1", {OpCodeDictKeys.TIMEOUT: 4.0}), - "reboot_1_0": ("Reboot 1 0", {OpCodeDictKeys.TIMEOUT: 4.0}), - "reboot_1_1": ("Reboot 1 1", {OpCodeDictKeys.TIMEOUT: 4.0}), - } - service_tuple = ("Core Controller", op_code_dict) - service_op_code_dict[CustomServiceList.CORE.value] = service_tuple + add_bpx_cmd_definitions(cmd_dict=service_op_code_dict) + add_core_controller_definitions(cmd_dict=service_op_code_dict) op_code_dict = { GpsOpCodes.RESET_GNSS.value: ("Reset GPS", {OpCodeDictKeys.TIMEOUT: 2.0}) @@ -147,170 +142,7 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): service_tuple = ("TMP1075 2", op_code_dict) service_op_code_dict[CustomServiceList.TMP1075_2.value] = service_tuple - op_code_dict = dict() - add_op_code_entry( - op_code_dict=op_code_dict, - keys="0", - info="P60 Tests", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_3V3_ON.value, - info="P60 Dock: Turn stack 3V3 on", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_3V3_OFF.value, - info="P60 Dock: Turn stack 3V3 off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_5V_ON.value, - info="P60 Dock: Turn stack 5V on", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=P60OpCodes.STACK_5V_OFF.value, - info="P60 Dock: Turn stack 5V off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, - info="P60 Dock: Print Switches, Voltages, Currents", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_service_op_code_entry( - srv_op_code_dict=service_op_code_dict, - name=CustomServiceList.P60DOCK.value, - info="P60 Device", - op_code_entry=op_code_dict, - ) - - op_code_dict_srv_pdu1 = { - "0": ("PDU1 Tests", {OpCodeDictKeys.TIMEOUT: 2.0}), - Pdu1OpCodes.TCS_BOARD_ON.value: ( - "PDU1: Turn TCS board on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.TCS_BOARD_OFF.value: ( - "PDU1: Turn TCS board off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.STAR_TRACKER_ON.value: ( - "PDU1: Turn star tracker on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.STAR_TRACKER_OFF.value: ( - "PDU1: Turn star tracker off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SUS_NOMINAL_ON.value: ( - "PDU1: Turn SUS nominal on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SUS_NOMINAL_OFF.value: ( - "PDU1: Turn SUS nominal off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.ACS_A_SIDE_ON.value: ( - "PDU1: Turn ACS Side A on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.ACS_A_SIDE_OFF.value: ( - "PDU1: Turn ACS Side A off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SYRLINKS_ON.value: ( - "PDU1: Turn Syrlinks on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SYRLINKS_OFF.value: ( - "PDU1: Turn Syrlinks off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.MGT_ON.value: ( - "PDU1: Turn MGT on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.MGT_OFF.value: ( - "PDU1: Turn MGT off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - GomspaceOpCodes.PRINT_SWITCH_V_I.value: ( - "PDU1: Print Switches, Voltages, Currents", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - } - service_pdu1_tuple = ("PDU1 Device", op_code_dict_srv_pdu1) - - op_code_dict = dict() - add_op_code_entry( - op_code_dict=op_code_dict, - keys="0", - info="PDU2 Tests", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.ACS_SIDE_B_ON.value, - info="PDU2: Turn ACS Side B on", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.ACS_SIDE_B_OFF.value, - info="PDU2: Turn ACS Side B off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.SUS_REDUNDANT_ON.value, - info="PDU2: Turn SUS redundant on", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.SUS_REDUNDANT_OFF.value, - info="PDU2: Turn SUS redundant off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.RW_ON.value, - info="PDU2: Turn reaction wheels on", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.RW_OFF.value, - info="PDU2: Turn reaction wheels off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=Pdu2OpCodes.Q7S_OFF.value, - info="Q7S Off", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - add_op_code_entry( - op_code_dict=op_code_dict, - keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, - info="PDU2: Print Switches, Voltages, Currents", - options={OpCodeDictKeys.TIMEOUT: 2.0}, - ) - - add_service_op_code_entry( - srv_op_code_dict=service_op_code_dict, - name="pdu2", - info="PDU2 Device", - op_code_entry=op_code_dict, - ) - # service_pdu2_tuple = ("PDU2 Device", op_code_dict_srv_pdu2) + add_pcdu_cmds(cmd_dict=service_op_code_dict) op_code_dict_srv_heater = { "0": ("Heater Tests", {OpCodeDictKeys.TIMEOUT: 2.0}), @@ -536,7 +368,10 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "48": ("Star Tracker: Request camera parameter", {OpCodeDictKeys.TIMEOUT: 2.0}), "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), "50": ("Star Tracker: Request blob parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "51": ( + "Star Tracker: Set image processor parameters", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) @@ -546,10 +381,22 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "2": ("CCSDS Handler: Enable transmitter", {OpCodeDictKeys.TIMEOUT: 2.0}), "3": ("CCSDS Handler: Disable transmitter", {OpCodeDictKeys.TIMEOUT: 2.0}), "4": ("CCSDS Handler: Set arbitrary bitrate", {OpCodeDictKeys.TIMEOUT: 2.0}), - "5": ("CCSDS Handler: Enable tx clock manipulator", {OpCodeDictKeys.TIMEOUT: 2.0}), - "6": ("CCSDS Handler: Disable tx clock manipulator", {OpCodeDictKeys.TIMEOUT: 2.0}), - "7": ("CCSDS Handler: Update tx data on rising edge", {OpCodeDictKeys.TIMEOUT: 2.0}), - "8": ("CCSDS Handler: Update tx data on falling edge", {OpCodeDictKeys.TIMEOUT: 2.0}), + "5": ( + "CCSDS Handler: Enable tx clock manipulator", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + "6": ( + "CCSDS Handler: Disable tx clock manipulator", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + "7": ( + "CCSDS Handler: Update tx data on rising edge", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), + "8": ( + "CCSDS Handler: Update tx data on falling edge", + {OpCodeDictKeys.TIMEOUT: 2.0}, + ), } service_ccsds_handler_tuple = ("CCSDS Handler", op_code_dict_srv_ccsds_handler) @@ -578,9 +425,6 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "Syrlinks Handler", op_code_dict_srv_syrlinks_handler, ) - - service_op_code_dict[CustomServiceList.PDU1.value] = service_pdu1_tuple - # service_op_code_dict[CustomServiceList.PDU2.value] = service_pdu2_tuple service_op_code_dict[CustomServiceList.HEATER.value] = service_heater_tuple service_op_code_dict[CustomServiceList.IMTQ.value] = service_imtq_tuple service_op_code_dict[CustomServiceList.REACTION_WHEEL_1.value] = service_rw_tuple diff --git a/pus_tc/bpx_batt.py b/pus_tc/bpx_batt.py index a69978a..a9f6311 100644 --- a/pus_tc/bpx_batt.py +++ b/pus_tc/bpx_batt.py @@ -16,27 +16,41 @@ class BpxActionIds: GET_CFG = 5 +class BpxOpCodes: + HK = ["0", "hk"] + RST_BOOT_CNT = ["1", "rst_boot_cnt"] + REQUEST_CFG = ["2", "cfg"] + REQUEST_CFG_HK = ["3", "cfg_hk"] + REBOOT = ["4", "reboot"] + + def pack_bpx_commands(tc_queue: TcQueueT, op_code: str): - if op_code in ["0", "hk"]: + if op_code in BpxOpCodes.HK: tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX battery HK set")) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_HK_SET) cmd = generate_one_hk_command(sid=sid, ssc=0) tc_queue.appendleft(cmd.pack_command_tuple()) - if op_code in ["1", "rst_boot_cnt"]: + if op_code in BpxOpCodes.RST_BOOT_CNT: tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters")) cmd = generate_action_command( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.RESET_COUNTERS ) tc_queue.appendleft(cmd.pack_command_tuple()) - if op_code in ["2", "cfg"]: - tc_queue.appendleft((QueueCommands.PRINT, "Resetting reboot counters")) + if op_code in BpxOpCodes.REQUEST_CFG: + tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct")) cmd = generate_action_command( object_id=BPX_HANDLER_ID, action_id=BpxActionIds.GET_CFG ) tc_queue.appendleft(cmd.pack_command_tuple()) - if op_code in ["3", "cfg_hk"]: - tc_queue.appendleft((QueueCommands.PRINT, "Requesting BPX Configuration Struct")) + if op_code in BpxOpCodes.REQUEST_CFG_HK: + tc_queue.appendleft((QueueCommands.PRINT, "Requesting configuration struct HK")) sid = make_sid(object_id=BPX_HANDLER_ID, set_id=BpxSetIds.GET_CFG_SET) cmd = generate_one_hk_command(sid=sid, ssc=0) tc_queue.appendleft(cmd.pack_command_tuple()) + if op_code in BpxOpCodes.REBOOT: + tc_queue.appendleft((QueueCommands.PRINT, "Rebooting BPX battery")) + cmd = generate_action_command( + object_id=BPX_HANDLER_ID, action_id=BpxActionIds.REBOOT + ) + tc_queue.appendleft(cmd.pack_command_tuple()) pass diff --git a/pus_tc/ccsds_handler.py b/pus_tc/ccsds_handler.py index acf004f..a7e400d 100644 --- a/pus_tc/ccsds_handler.py +++ b/pus_tc/ccsds_handler.py @@ -43,22 +43,26 @@ def pack_ccsds_handler_test( ) if op_code == "0": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set low rate")) - command = object_id + struct.pack('!I', CommandIds.SET_LOW_RATE) + command = object_id + struct.pack("!I", CommandIds.SET_LOW_RATE) command = PusTelecommand(service=8, subservice=128, ssc=20, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "1": tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Set high rate")) - command = object_id + struct.pack('!I', CommandIds.SET_HIGH_RATE) + command = object_id + struct.pack("!I", CommandIds.SET_HIGH_RATE) command = PusTelecommand(service=8, subservice=128, ssc=21, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "2": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enables the transmitter")) - command = object_id + struct.pack('!I', CommandIds.EN_TRANSMITTER) + tc_queue.appendleft( + (QueueCommands.PRINT, "CCSDS Handler: Enables the transmitter") + ) + command = object_id + struct.pack("!I", CommandIds.EN_TRANSMITTER) command = PusTelecommand(service=8, subservice=128, ssc=22, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "3": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disables the transmitter")) - command = object_id + struct.pack('!I', CommandIds.DIS_TRANSMITTER) + tc_queue.appendleft( + (QueueCommands.PRINT, "CCSDS Handler: Disables the transmitter") + ) + command = object_id + struct.pack("!I", CommandIds.DIS_TRANSMITTER) command = PusTelecommand(service=8, subservice=128, ssc=23, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "4": @@ -66,27 +70,45 @@ def pack_ccsds_handler_test( (QueueCommands.PRINT, "CCSDS Handler: Set arbitrary bitrate") ) bitrate = int(input("Specify bit rate (bps): ")) - command = object_id + struct.pack('!I', CommandIds.ARBITRARY_BITRATE) + struct.pack('!I', bitrate) + command = ( + object_id + + struct.pack("!I", CommandIds.ARBITRARY_BITRATE) + + struct.pack("!I", bitrate) + ) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "5": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Enable tx clock manipulator")) - command = object_id + struct.pack('!I', CommandIds.ENABLE_TX_CLK_MANIPULATOR) + tc_queue.appendleft( + (QueueCommands.PRINT, "CCSDS Handler: Enable tx clock manipulator") + ) + command = object_id + struct.pack("!I", CommandIds.ENABLE_TX_CLK_MANIPULATOR) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "6": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Disable tx clock manipulator")) - command = object_id + struct.pack('!I', CommandIds.DISABLE_TX_CLK_MANIPULATOR) + tc_queue.appendleft( + (QueueCommands.PRINT, "CCSDS Handler: Disable tx clock manipulator") + ) + command = object_id + struct.pack("!I", CommandIds.DISABLE_TX_CLK_MANIPULATOR) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "7": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on rising edge of tx clock")) - command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_RISING_EDGE) + tc_queue.appendleft( + ( + QueueCommands.PRINT, + "CCSDS Handler: Update tx data on rising edge of tx clock", + ) + ) + command = object_id + struct.pack("!I", CommandIds.UPDATE_ON_RISING_EDGE) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "8": - tc_queue.appendleft((QueueCommands.PRINT, "CCSDS Handler: Update tx data on falling edge of tx clock")) - command = object_id + struct.pack('!I', CommandIds.UPDATE_ON_FALLING_EDGE) + tc_queue.appendleft( + ( + QueueCommands.PRINT, + "CCSDS Handler: Update tx data on falling edge of tx clock", + ) + ) + command = object_id + struct.pack("!I", CommandIds.UPDATE_ON_FALLING_EDGE) command = PusTelecommand(service=8, subservice=128, ssc=24, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index 8112271..148d4a6 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -501,9 +501,14 @@ def pack_star_tracker_commands( command = PusTelecommand(service=8, subservice=128, ssc=73, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "51": - tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) - command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ - bytearray(ImagePathDefs.jsonFile, 'utf-8') + tc_queue.appendleft( + (QueueCommands.PRINT, "Star tracker: Set image processor parameters") + ) + command = ( + object_id + + struct.pack("!I", StarTrackerActionIds.IMAGE_PROCESSOR) + + bytearray(ImagePathDefs.jsonFile, "utf-8") + ) command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index cf78f16..311a7eb 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -14,7 +14,7 @@ from config.object_ids import ( IMTQ_HANDLER_ID, GPS_HANDLER_0_ID, GPS_HANDLER_1_ID, - BPX_HANDLER_ID + BPX_HANDLER_ID, ) LOGGER = get_console_logger() @@ -245,7 +245,7 @@ def handle_gps_data(hk_data: bytearray) -> HkReplyUnpacked: "Fix Mode", "Sats in Use", "Date", - "Unix Seconds" + "Unix Seconds", ] latitude = struct.unpack("!d", hk_data[0:8])[0] longitude = struct.unpack("!d", hk_data[8:16])[0] @@ -267,7 +267,7 @@ def handle_gps_data(hk_data: bytearray) -> HkReplyUnpacked: fix_mode, sat_in_use, date_string, - unix_seconds + unix_seconds, ] var_index += 13 reply.num_of_vars = var_index @@ -290,15 +290,15 @@ def handle_bpx_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: LOGGER.info(f"Received BPX data, HK data length {len(hk_data)}") reply = HkReplyUnpacked() if set_id == BpxSetIds.GET_HK_SET: - charge_current = struct.unpack('!H', hk_data[0:2])[0] - discharge_current = struct.unpack('!H', hk_data[2:4])[0] - heater_current = struct.unpack('!H', hk_data[4:6])[0] - batt_voltage = struct.unpack('!H', hk_data[6:8])[0] - batt_temp_1 = struct.unpack('!h', hk_data[8:10])[0] - batt_temp_2 = struct.unpack('!h', hk_data[10:12])[0] - batt_temp_3 = struct.unpack('!h', hk_data[12:14])[0] - batt_temp_4 = struct.unpack('!h', hk_data[14:16])[0] - reboot_cntr = struct.unpack('!I', hk_data[16:20])[0] + charge_current = struct.unpack("!H", hk_data[0:2])[0] + discharge_current = struct.unpack("!H", hk_data[2:4])[0] + heater_current = struct.unpack("!H", hk_data[4:6])[0] + batt_voltage = struct.unpack("!H", hk_data[6:8])[0] + batt_temp_1 = struct.unpack("!h", hk_data[8:10])[0] + batt_temp_2 = struct.unpack("!h", hk_data[10:12])[0] + batt_temp_3 = struct.unpack("!h", hk_data[12:14])[0] + batt_temp_4 = struct.unpack("!h", hk_data[14:16])[0] + reboot_cntr = struct.unpack("!I", hk_data[16:20])[0] boot_cause = hk_data[20] reply.header_list = [ "Charge Current", @@ -310,7 +310,7 @@ def handle_bpx_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: "Batt Temp 3", "Batt Temp 4", "Reboot Counter", - "Boot Cause" + "Boot Cause", ] reply.content_list = [ charge_current, @@ -322,22 +322,18 @@ def handle_bpx_hk_data(hk_data: bytes, set_id: int) -> HkReplyUnpacked: batt_temp_3, batt_temp_4, reboot_cntr, - boot_cause + boot_cause, ] reply.validity_buffer = hk_data[21:] elif set_id == BpxSetIds.GET_CFG_SET: battheat_mode = hk_data[0] - battheat_low = struct.unpack('!b', hk_data[1:2])[0] - battheat_high = struct.unpack('!b', hk_data[2:3])[0] + battheat_low = struct.unpack("!b", hk_data[1:2])[0] + battheat_high = struct.unpack("!b", hk_data[2:3])[0] reply.header_list = [ "Battery Heater Mode", "Battery Heater Low Limit", - "Battery Heater High Limit" - ] - reply.content_list = [ - battheat_mode, - battheat_low, - battheat_high + "Battery Heater High Limit", ] + reply.content_list = [battheat_mode, battheat_low, battheat_high] reply.validity_buffer = hk_data[3:] return reply diff --git a/pus_tm/service_8_hook.py b/pus_tm/service_8_hook.py index b157092..735e64f 100644 --- a/pus_tm/service_8_hook.py +++ b/pus_tm/service_8_hook.py @@ -49,7 +49,11 @@ def user_analyze_service_8_data( def handle_imtq_replies(action_id: int, custom_data: bytearray) -> DataReplyUnpacked: reply = DataReplyUnpacked() if action_id == struct.unpack("!I", ImtqActionIds.get_commanded_dipole)[0]: - reply.header_list = ["Commanded X-Dipole", "Commanded Y-Dipole", "Commanded Z-Dipole"] + reply.header_list = [ + "Commanded X-Dipole", + "Commanded Y-Dipole", + "Commanded Z-Dipole", + ] x_dipole = struct.unpack("!H", custom_data[:2]) y_dipole = struct.unpack("!H", custom_data[2:4]) z_dipole = struct.unpack("!H", custom_data[4:6]) @@ -60,7 +64,11 @@ def handle_imtq_replies(action_id: int, custom_data: bytearray) -> DataReplyUnpa def handle_ploc_replies(action_id: int, custom_data: bytearray) -> DataReplyUnpacked: reply = DataReplyUnpacked() if action_id == PlocReplyIds.tm_mem_read_report: - reply.header_list = ["PLOC Memory Address", "PLOC Mem Len", "PLOC Read Memory Data"] + reply.header_list = [ + "PLOC Memory Address", + "PLOC Mem Len", + "PLOC Read Memory Data", + ] reply.content_list = [custom_data[:4], custom_data[4:6], custom_data[6:10]] return reply diff --git a/tmtccmd b/tmtccmd index 892d131..06eb6c9 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 892d13117f0e3c6d598f157668bff9ed6b31574d +Subproject commit 06eb6c9bbec1ae1cb8bea14bd4f9079ee3a29ad5 From 84c2730836e6821ff089d7567018fe4ffded62db Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Feb 2022 16:16:14 +0100 Subject: [PATCH 07/14] bump tmtccmd requirements --- requirements.txt | 2 +- tmtccmd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 344657c..4545207 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -tmtccmd>=1.10.2 +tmtccmd>=1.11.0 diff --git a/tmtccmd b/tmtccmd index 06eb6c9..c707918 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 06eb6c9bbec1ae1cb8bea14bd4f9079ee3a29ad5 +Subproject commit c7079184c9072ba4aec6d05de7627245d8c99303 From e7d735966af6a9e5d70dbf5771a65ed98c2052e1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Feb 2022 17:05:27 +0100 Subject: [PATCH 08/14] add commands to switch on/off scex --- config/cmd_definitions.py | 140 ++++++++++++++++++++++---------------- pus_tc/pdu1.py | 21 ++++++ 2 files changed, 104 insertions(+), 57 deletions(-) diff --git a/config/cmd_definitions.py b/config/cmd_definitions.py index 7ffac58..589e581 100644 --- a/config/cmd_definitions.py +++ b/config/cmd_definitions.py @@ -91,63 +91,89 @@ def add_pcdu_cmds(cmd_dict: ServiceOpCodeDictT): op_code_entry=op_code_dict, ) - op_code_dict_srv_pdu1 = { - "0": ("PDU1 Tests", {OpCodeDictKeys.TIMEOUT: 2.0}), - Pdu1OpCodes.TCS_BOARD_ON.value: ( - "PDU1: Turn TCS board on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.TCS_BOARD_OFF.value: ( - "PDU1: Turn TCS board off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.STAR_TRACKER_ON.value: ( - "PDU1: Turn star tracker on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.STAR_TRACKER_OFF.value: ( - "PDU1: Turn star tracker off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SUS_NOMINAL_ON.value: ( - "PDU1: Turn SUS nominal on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SUS_NOMINAL_OFF.value: ( - "PDU1: Turn SUS nominal off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.ACS_A_SIDE_ON.value: ( - "PDU1: Turn ACS Side A on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.ACS_A_SIDE_OFF.value: ( - "PDU1: Turn ACS Side A off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SYRLINKS_ON.value: ( - "PDU1: Turn Syrlinks on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.SYRLINKS_OFF.value: ( - "PDU1: Turn Syrlinks off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.MGT_ON.value: ( - "PDU1: Turn MGT on", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - Pdu1OpCodes.MGT_OFF.value: ( - "PDU1: Turn MGT off", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - GomspaceOpCodes.PRINT_SWITCH_V_I.value: ( - "PDU1: Print Switches, Voltages, Currents", - {OpCodeDictKeys.TIMEOUT: 2.0}, - ), - } - service_pdu1_tuple = ("PDU1 Device", op_code_dict_srv_pdu1) - cmd_dict[CustomServiceList.PDU1.value] = service_pdu1_tuple + op_code_dict = dict() + add_op_code_entry(op_code_dict=op_code_dict, keys="0", info="PDU1 Tests") + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.TCS_BOARD_ON.value, + info="PDU1: Turn TCS board on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.TCS_BOARD_OFF.value, + info="PDU1: Turn TCS board off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.STAR_TRACKER_ON.value, + info="PDU1: Turn star tracker on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.STAR_TRACKER_OFF.value, + info="PDU1: Turn star tracker off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SUS_NOMINAL_ON.value, + info="PDU1: Turn SUS nominal on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SUS_NOMINAL_OFF.value, + info="PDU1: Turn SUS nominal off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.ACS_A_SIDE_ON.value, + info="PDU1: Turn ACS A side on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.ACS_A_SIDE_OFF.value, + info="PDU1: Turn ACS A side off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SYRLINKS_ON.value, + info="PDU1: Turn Syrlinks on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SYRLINKS_OFF.value, + info="PDU1: Turn Syrlinks off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.MGT_ON.value, + info="PDU1: Turn MGT on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.MGT_OFF.value, + info="PDU1: Turn MGT on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SCEX_ON.value, + info="PDU1: Turn Solar Cell Experiment on", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=Pdu1OpCodes.SCEX_OFF.value, + info="PDU1: Turn Solar Cell Experiment off", + ) + add_op_code_entry( + op_code_dict=op_code_dict, + keys=GomspaceOpCodes.PRINT_SWITCH_V_I.value, + info="PDU1: Print Switches, Voltages, Currents", + ) + add_service_op_code_entry( + srv_op_code_dict=cmd_dict, + name=CustomServiceList.PDU1.value, + info="PDU1 Device", + op_code_entry=op_code_dict, + ) op_code_dict = dict() add_op_code_entry( diff --git a/pus_tc/pdu1.py b/pus_tc/pdu1.py index a7bd943..95419f6 100644 --- a/pus_tc/pdu1.py +++ b/pus_tc/pdu1.py @@ -27,6 +27,9 @@ class Pdu1OpCodes(enum.Enum): SYRLINKS_OFF = "10" MGT_ON = "11" MGT_OFF = "12" + # Solar Cell Experiment + SCEX_ON = "13" + SCEX_OFF = "14" class PDU1TestProcedure: @@ -130,6 +133,24 @@ def pack_pdu1_commands(object_id: bytearray, tc_queue: TcQueueT, op_code: str): Channel.off, ) tc_queue.appendleft(command.pack_command_tuple()) + if op_code == Pdu1OpCodes.SCEX_ON.value: + tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment on")) + command = pack_set_param_command( + object_id, + PDUConfigTable.out_en_5.parameter_address, + PDUConfigTable.out_en_5.parameter_size, + Channel.on, + ) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == Pdu1OpCodes.SCEX_OFF.value: + tc_queue.appendleft((QueueCommands.PRINT, "PDU1: Turn Solar Cell Experiment off")) + command = pack_set_param_command( + object_id, + PDUConfigTable.out_en_5.parameter_address, + PDUConfigTable.out_en_5.parameter_size, + Channel.off, + ) + tc_queue.appendleft(command.pack_command_tuple()) if op_code == GomspaceOpCodes.PRINT_SWITCH_V_I.value: tc_queue.appendleft( (QueueCommands.PRINT, "PDU1: Print Switches, Voltages, Currents") From 199ffe1a321c09ba9726c87413045f8b32f40e90 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 5 Feb 2022 15:44:50 +0100 Subject: [PATCH 09/14] egse specific commands --- config/hook_implementations.py | 2 ++ pus_tc/star_tracker.py | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index c3c7663..38b09ec 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -539,6 +539,8 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), "50": ("Star Tracker: Request blob parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "52": ("Star Tracker: (EGSE only) Load image processor ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), + "53": ("Star Tracker: (EGSE only) Load image processor flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index 8112271..db146a0 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -76,7 +76,8 @@ class ImagePathDefs: downloadFpgaImagePath = "/mnt/sd0/startracker" downloadFpgaImageName = "testname" uploadFpgaImageName = "/mnt/sd0/startracker/fpga-image.bin" - + egseGroundConfig = "/home/pi/arcsec/ground-config.json" + egseFlightConfig = "/home/pi/arcsec/flight-config.json" class Region: # Definition according to datasheet (which turned out to be partially faulty) @@ -195,10 +196,13 @@ def pack_star_tracker_commands( tc_queue.appendleft(command.pack_command_tuple()) if op_code == "15": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download image")) + path = input("Specify storage location (default - /mnt/sd0/startracker): ") + if not path: + path = ImagePathDefs.downloadPath command = ( object_id + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) - + bytearray(ImagePathDefs.downloadPath, "utf-8") + + bytearray(path, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=53, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -506,6 +510,18 @@ def pack_star_tracker_commands( bytearray(ImagePathDefs.jsonFile, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "52": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load ground config camera parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ + bytearray(ImagePathDefs.egseGroundConfig, 'utf-8') + command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "53": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load flight config camera parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ + bytearray(ImagePathDefs.egseFlightConfig, 'utf-8') + command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) def pack_write_command(object_id: bytearray) -> bytearray: From 6a78311239bdf78040e43ef217035fcaa2ab9f3b Mon Sep 17 00:00:00 2001 From: EIVE Cleanroom Date: Mon, 7 Feb 2022 13:28:18 +0100 Subject: [PATCH 10/14] tmtccmd update --- tmtccmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtccmd b/tmtccmd index c707918..49cf288 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit c7079184c9072ba4aec6d05de7627245d8c99303 +Subproject commit 49cf288831216c0680aedab88e31d684ba5b8da8 From cf7d25c206e8ae8480367e1fc2b1151a0ded2683 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 8 Feb 2022 16:17:34 +0100 Subject: [PATCH 11/14] egse camera parameter command --- config/hook_implementations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 38b09ec..f88a15e 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -539,8 +539,8 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), "50": ("Star Tracker: Request blob parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "52": ("Star Tracker: (EGSE only) Load image processor ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), - "53": ("Star Tracker: (EGSE only) Load image processor flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "52": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), + "53": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) From 5d8b9aac1fea707015bd991b865da7f3405859e8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Fri, 11 Feb 2022 08:46:48 +0100 Subject: [PATCH 12/14] request param commands --- config/hook_implementations.py | 22 +- pus_tc/star_tracker.py | 355 ++++++++++++++++++++++----------- 2 files changed, 259 insertions(+), 118 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index f88a15e..ea369ee 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -537,10 +537,24 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "47": ("Star Tracker: Unlock", {OpCodeDictKeys.TIMEOUT: 2.0}), "48": ("Star Tracker: Request camera parameter", {OpCodeDictKeys.TIMEOUT: 2.0}), "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), - "50": ("Star Tracker: Request blob parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "52": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), - "53": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "50": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "51": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), + "52": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "53": ("Star Tracker: Request log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "54": ("Star Tracker: Request mounting parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "55": ("Star Tracker: Request image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "56": ("Star Tracker: Request centroiding parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "57": ("Star Tracker: Request lisa parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "58": ("Star Tracker: Request matching parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "59": ("Star Tracker: Request tracking parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "60": ("Star Tracker: Request validation parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "61": ("Star Tracker: Request algo parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "62": ("Star Tracker: Request subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "63": ("Star Tracker: Request log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "64": ("Star Tracker: Request debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "65": ("Star Tracker: Set log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "66": ("Star Tracker: Set log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "67": ("Star Tracker: Set debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index db146a0..78660c6 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -12,6 +12,9 @@ from tmtccmd.config.definitions import QueueCommands from tmtccmd.tc.packer import TcQueueT from spacepackets.ecss.tc import PusTelecommand from pus_tc.service_200_mode import pack_mode_data +from tmtccmd.utility.logger import get_console_logger + +LOGGER = get_console_logger() class StarTrackerActionIds: @@ -28,7 +31,7 @@ class StarTrackerActionIds: UPLOAD_IMAGE = 10 DOWNLOAD_CENTROID = 16 UPLOAD_CENTROID = 17 - SUBSCRIBE_TO_TM = 18 + SUBSCRIPTION = 18 IMAGE_PROCESSOR = 19 REQ_SOLUTION = 24 REQ_TEMPERATURE = 25 @@ -62,7 +65,21 @@ class StarTrackerActionIds: FPGA_ACTION = 66 REQ_CAMERA_PARAMS = 67 REQ_LIMITS = 68 - REQ_BLOB_PARAMS = 69 + 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 class ImagePathDefs: @@ -78,6 +95,17 @@ class ImagePathDefs: uploadFpgaImageName = "/mnt/sd0/startracker/fpga-image.bin" egseGroundConfig = "/home/pi/arcsec/ground-config.json" egseFlightConfig = "/home/pi/arcsec/flight-config.json" + q7sGroundConfig = "/mnt/sd0/startracker/ground-config.json" + q7sFlightConfig = "/mnt/sd0/startracker/flight-config.json" + + +json_selection = { + "1": ["Q7S flight config", ImagePathDefs.q7sFlightConfig], + "2": ["Q7S ground config", ImagePathDefs.q7sGroundConfig], + "3": ["EGSE flight config", ImagePathDefs.egseFlightConfig], + "4": ["EGSE ground config", ImagePathDefs.egseGroundConfig] +} + class Region: # Definition according to datasheet (which turned out to be partially faulty) @@ -95,7 +123,7 @@ class PartitionSize: def pack_star_tracker_commands( - object_id: bytearray, tc_queue: TcQueueT, op_code: str + object_id: bytearray, tc_queue: TcQueueT, op_code: str ) -> TcQueueT: tc_queue.appendleft( ( @@ -160,13 +188,13 @@ def pack_star_tracker_commands( tc_queue.appendleft(command.pack_command_tuple()) if op_code == "10": tc_queue.appendleft( - (QueueCommands.PRINT, "Star tracker: Subscribe to telemetry") + (QueueCommands.PRINT, "Star tracker: Set subscription parameters") ) - tm_id = int(input("Specify Id of tm: ")) + jsonfile = get_config_file() command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SUBSCRIBE_TO_TM) - + struct.pack("B", tm_id) + object_id + + struct.pack("!I", StarTrackerActionIds.SUBSCRIPTION) + + bytearray(jsonfile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -188,9 +216,9 @@ def pack_star_tracker_commands( if op_code == "14": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload image")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE) - + bytearray(ImagePathDefs.uploadFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE) + + bytearray(ImagePathDefs.uploadFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -200,18 +228,18 @@ def pack_star_tracker_commands( if not path: path = ImagePathDefs.downloadPath command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) - + bytearray(path, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) + + bytearray(path, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=53, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "16": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set limits")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.LIMITS) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.LIMITS) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=42, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -220,81 +248,82 @@ def pack_star_tracker_commands( (QueueCommands.PRINT, "Star tracker: Set tracking parameters") ) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.TRACKING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.TRACKING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "18": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mounting")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.MOUNTING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.MOUNTING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "19": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Camera")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CAMERA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CAMERA) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "20": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Blob")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.BLOB) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.BLOB) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "21": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Centroiding")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CENTROIDING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CENTROIDING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=47, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "22": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: LISA")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.LISA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.LISA) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=48, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "23": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Matching")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.MATCHING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.MATCHING) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=49, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "24": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Validation")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.VALIDATION) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.VALIDATION) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=50, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "25": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Algo")) + jsonfile = get_config_file() command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.ALGO) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.ALGO) + + bytearray(jsonfile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=51, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -302,9 +331,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Take image")) actionid = int(input("Specify parameter ID (nominal - 4): ")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.TAKE_IMAGE) - + struct.pack("!B", actionid) + object_id + + struct.pack("!I", StarTrackerActionIds.TAKE_IMAGE) + + struct.pack("!B", actionid) ) command = PusTelecommand(service=8, subservice=128, ssc=52, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -324,9 +353,9 @@ def pack_star_tracker_commands( ) filename = input("Specify download image name: ") command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHANGE_DOWNLOAD_IMAGE) - + bytearray(filename, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CHANGE_DOWNLOAD_IMAGE) + + bytearray(filename, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -343,9 +372,9 @@ def pack_star_tracker_commands( if op_code == "32": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set json filename")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SET_JSON_FILE_NAME) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.SET_JSON_FILE_NAME) + + bytearray(ImagePathDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=57, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -363,9 +392,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set read filename")) filename = input("Specify filename: ") command = ( - object_id - + StarTrackerActionIds.SET_READ_FILENAME - + bytearray(filename, "utf-8") + object_id + + StarTrackerActionIds.SET_READ_FILENAME + + bytearray(filename, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=60, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -378,9 +407,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set time")) unix_time = 1640783543 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.SET_TIME) - + struct.pack("!Q", unix_time) + object_id + + struct.pack("!I", StarTrackerActionIds.SET_TIME) + + struct.pack("!Q", unix_time) ) command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -388,18 +417,18 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Centroid")) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_CENTROID) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_CENTROID) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=62, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "39": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload Centroid")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_CENTROID) - + bytearray(ImagePathDefs.uploadCentroidJson, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_CENTROID) + + bytearray(ImagePathDefs.uploadCentroidJson, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -409,9 +438,9 @@ def pack_star_tracker_commands( ) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_MATCHED_STAR) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_MATCHED_STAR) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=64, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -419,9 +448,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download DB Image")) id = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_DBIMAGE) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_DBIMAGE) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -430,10 +459,10 @@ def pack_star_tracker_commands( id = 0 type = 1 # 0 - normal, 1 - fast command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_BLOBPIXEL) - + struct.pack("!B", id) - + struct.pack("!B", type) + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_BLOBPIXEL) + + struct.pack("!B", id) + + struct.pack("!B", type) ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -442,11 +471,11 @@ def pack_star_tracker_commands( position = int(input("Start position: ")) length = int(input("Size to download: ")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) - + struct.pack("!I", position) - + struct.pack("!I", length) - + bytearray(ImagePathDefs.downloadFpgaImagePath, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) + + struct.pack("!I", position) + + struct.pack("!I", length) + + bytearray(ImagePathDefs.downloadFpgaImagePath, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=66, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -455,18 +484,18 @@ def pack_star_tracker_commands( (QueueCommands.PRINT, "Star tracker: Change donwload FPGA image file name") ) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) - + bytearray(ImagePathDefs.downloadFpgaImageName, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) + + bytearray(ImagePathDefs.downloadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=67, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "45": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload FPGA image")) command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.UPLOAD_FPGA_IMAGE) - + bytearray(ImagePathDefs.uploadFpgaImageName, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.UPLOAD_FPGA_IMAGE) + + bytearray(ImagePathDefs.uploadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=68, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -474,9 +503,9 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: FPGA action")) id = 3 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.FPGA_ACTION) - + struct.pack("!B", id) + object_id + + struct.pack("!I", StarTrackerActionIds.FPGA_ACTION) + + struct.pack("!B", id) ) command = PusTelecommand(service=8, subservice=128, ssc=69, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -498,41 +527,112 @@ def pack_star_tracker_commands( command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "50": - tc_queue.appendleft( - (QueueCommands.PRINT, "Star tracker: Request blob parameters") - ) - command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_BLOB_PARAMS) - command = PusTelecommand(service=8, subservice=128, ssc=73, app_data=command) - tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ bytearray(ImagePathDefs.jsonFile, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "52": + if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load ground config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(ImagePathDefs.egseGroundConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "53": + if op_code == "52": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load flight config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(ImagePathDefs.egseFlightConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "53": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log level parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_LEVEL) + command = PusTelecommand(service=8, subservice=128, ssc=74, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "54": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request mounting parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MOUNTING) + command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "55": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request image processor parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_IMAGE_PROCESSOR) + command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "56": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request centroiding parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_CENTROIDING) + command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "57": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request lisa parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LISA) + command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "58": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request matching parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MATCHING) + command = PusTelecommand(service=8, subservice=128, ssc=77, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "59": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request tracking parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_TRACKING) + command = PusTelecommand(service=8, subservice=128, ssc=78, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "60": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request validation parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_VALIDATION) + command = PusTelecommand(service=8, subservice=128, ssc=79, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "61": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request algo parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_ALGO) + command = PusTelecommand(service=8, subservice=128, ssc=80, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "62": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request subscription parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_SUBSCRIPTION) + command = PusTelecommand(service=8, subservice=128, ssc=81, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "63": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log subscription parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_SUBSCRIPTION) + command = PusTelecommand(service=8, subservice=128, ssc=82, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "64": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request debug camera parameters")) + command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_DEBUG_CAMERA) + command = PusTelecommand(service=8, subservice=128, ssc=83, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "65": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log level parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.LOGLEVEL) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=84, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "66": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log subscription parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.LOG_SUBSCRIPTION) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "67": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set debug camera parameters")) + jsonfile = get_config_file() + command = object_id + struct.pack('!I', StarTrackerActionIds.DEBUG_CAMERA) + bytearray(jsonfile, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) def pack_write_command(object_id: bytearray) -> bytearray: region = Region.FREE_1 address = 0 command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.WRITE) - + struct.pack("!B", region) - + struct.pack("!I", address) - + bytearray(ImagePathDefs.flashFile, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.WRITE) + + struct.pack("!B", region) + + struct.pack("!I", address) + + bytearray(ImagePathDefs.flashFile, "utf-8") ) return command @@ -542,12 +642,12 @@ def pack_read_command(object_id: bytearray) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.READ) - + struct.pack("!B", region) - + struct.pack("!I", address) - + struct.pack("!I", size) - + bytearray(ImagePathDefs.flashReadPath, "utf-8") + object_id + + struct.pack("!I", StarTrackerActionIds.READ) + + struct.pack("!B", region) + + struct.pack("!I", address) + + struct.pack("!I", size) + + bytearray(ImagePathDefs.flashReadPath, "utf-8") ) return command @@ -557,10 +657,37 @@ def pack_checksum_command(object_id: bytearray) -> bytearray: address = 0 size = PartitionSize.STAR_TRACKER_FIRMWARE command = ( - object_id - + struct.pack("!I", StarTrackerActionIds.CHECKSUM) - + struct.pack("!B", region) - + struct.pack("!I", address) - + struct.pack("!I", size) + object_id + + struct.pack("!I", StarTrackerActionIds.CHECKSUM) + + struct.pack("!B", region) + + struct.pack("!I", address) + + struct.pack("!I", size) ) return command + + +def get_config_file() -> str: + LOGGER.info("Specify json file to use") + key = get_json_file_key() + while key not in json_selection: + LOGGER.info("Invalid key specified, try again.") + key = get_json_file_key() + jsonfile = json_selection[key][1] + return jsonfile + + +def get_json_file_key(): + key_column_width = 10 + description_column_width = 50 + separator_width = key_column_width + description_column_width + 3 + separator_string = separator_width * "-" + key_string = "Key".ljust(key_column_width) + description_string = "Description".ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + LOGGER.info(separator_string) + for key in json_selection: + key_string = key.ljust(key_column_width) + description_string = json_selection[key][0].ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + key = input("Specify key: ") + return key From 0a8a2fb9c6833f2e1d89dabaf4c06bd79190fb50 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 14 Feb 2022 16:52:32 +0100 Subject: [PATCH 13/14] input helper to get user input --- config/hook_implementations.py | 1 + pus_tc/star_tracker.py | 102 +++++++++++++++++---------------- tmtccmd | 2 +- utility/input_helper.py | 49 ++++++++++++++++ 4 files changed, 104 insertions(+), 50 deletions(-) create mode 100644 utility/input_helper.py diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 3930ea9..5aafd7d 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -385,6 +385,7 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): "65": ("Star Tracker: Set log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), "66": ("Star Tracker: Set log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), "67": ("Star Tracker: Set debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "68": ("Star Tracker: Firmware update", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index 78660c6..8238242 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -13,6 +13,7 @@ from tmtccmd.tc.packer import TcQueueT from spacepackets.ecss.tc import PusTelecommand from pus_tc.service_200_mode import pack_mode_data from tmtccmd.utility.logger import get_console_logger +from utility.input_helper import InputHelper LOGGER = get_console_logger() @@ -80,9 +81,10 @@ class StarTrackerActionIds: LOGLEVEL = 81 LOG_SUBSCRIPTION = 82 DEBUG_CAMERA = 83 + FIRMWARE_UPDATE = 84 -class ImagePathDefs: +class FileDefs: uploadFile = "/mnt/sd0/startracker/gemma.bin" downloadFile = "test_image.bin" downloadPath = "/mnt/sd0/startracker" @@ -97,13 +99,20 @@ class ImagePathDefs: egseFlightConfig = "/home/pi/arcsec/flight-config.json" q7sGroundConfig = "/mnt/sd0/startracker/ground-config.json" q7sFlightConfig = "/mnt/sd0/startracker/flight-config.json" + firmware2_1 = "/home/pi/arcsec/firmware/sagitta2-1.bin" + firmware22_1 = "/home/pi/arcsec/firmware/sagitta-22.1.bin" -json_selection = { - "1": ["Q7S flight config", ImagePathDefs.q7sFlightConfig], - "2": ["Q7S ground config", ImagePathDefs.q7sGroundConfig], - "3": ["EGSE flight config", ImagePathDefs.egseFlightConfig], - "4": ["EGSE ground config", ImagePathDefs.egseGroundConfig] +json_dict = { + "1": ["Q7S flight config", FileDefs.q7sFlightConfig], + "2": ["Q7S ground config", FileDefs.q7sGroundConfig], + "3": ["EGSE flight config", FileDefs.egseFlightConfig], + "4": ["EGSE ground config", FileDefs.egseGroundConfig] +} + +firmware_dict = { + "1": ["Firmware Major = 2, Minor = 1", FileDefs.firmware2_1], + "2": ["Firmware Major = 22, Minor = 1", FileDefs.firmware22_1], } @@ -218,7 +227,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.UPLOAD_IMAGE) - + bytearray(ImagePathDefs.uploadFile, "utf-8") + + bytearray(FileDefs.uploadFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -226,7 +235,7 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download image")) path = input("Specify storage location (default - /mnt/sd0/startracker): ") if not path: - path = ImagePathDefs.downloadPath + path = FileDefs.downloadPath command = ( object_id + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_IMAGE) @@ -239,7 +248,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.LIMITS) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=42, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -250,7 +259,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.TRACKING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -259,7 +268,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.MOUNTING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -268,7 +277,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.CAMERA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -277,7 +286,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.BLOB) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -286,7 +295,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.CENTROIDING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=47, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -295,7 +304,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.LISA) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=48, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -304,7 +313,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.MATCHING) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=49, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -313,7 +322,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.VALIDATION) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=50, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -374,7 +383,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.SET_JSON_FILE_NAME) - + bytearray(ImagePathDefs.jsonFile, "utf-8") + + bytearray(FileDefs.jsonFile, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=57, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -428,7 +437,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.UPLOAD_CENTROID) - + bytearray(ImagePathDefs.uploadCentroidJson, "utf-8") + + bytearray(FileDefs.uploadCentroidJson, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -475,7 +484,7 @@ def pack_star_tracker_commands( + struct.pack("!I", StarTrackerActionIds.DOWNLOAD_FPGA_IMAGE) + struct.pack("!I", position) + struct.pack("!I", length) - + bytearray(ImagePathDefs.downloadFpgaImagePath, "utf-8") + + bytearray(FileDefs.downloadFpgaImagePath, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=66, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -486,7 +495,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.CHANGE_FPGA_DOWNLOAD_FILE) - + bytearray(ImagePathDefs.downloadFpgaImageName, "utf-8") + + bytearray(FileDefs.downloadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=67, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -495,7 +504,7 @@ def pack_star_tracker_commands( command = ( object_id + struct.pack("!I", StarTrackerActionIds.UPLOAD_FPGA_IMAGE) - + bytearray(ImagePathDefs.uploadFpgaImageName, "utf-8") + + bytearray(FileDefs.uploadFpgaImageName, "utf-8") ) command = PusTelecommand(service=8, subservice=128, ssc=68, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -529,19 +538,19 @@ def pack_star_tracker_commands( if op_code == "50": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ - bytearray(ImagePathDefs.jsonFile, 'utf-8') + bytearray(FileDefs.jsonFile, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load ground config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ - bytearray(ImagePathDefs.egseGroundConfig, 'utf-8') + bytearray(FileDefs.egseGroundConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "52": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load flight config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ - bytearray(ImagePathDefs.egseFlightConfig, 'utf-8') + bytearray(FileDefs.egseFlightConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "53": @@ -620,7 +629,13 @@ def pack_star_tracker_commands( tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set debug camera parameters")) jsonfile = get_config_file() command = object_id + struct.pack('!I', StarTrackerActionIds.DEBUG_CAMERA) + bytearray(jsonfile, "utf-8") - command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) + command = PusTelecommand(service=8, subservice=128, ssc=86, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "68": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Firmware update")) + firmware = get_firmware() + command = object_id + struct.pack('!I', StarTrackerActionIds.FIRMWARE_UPDATE) + bytearray(firmware, "utf-8") + command = PusTelecommand(service=8, subservice=128, ssc=87, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) @@ -632,7 +647,7 @@ def pack_write_command(object_id: bytearray) -> bytearray: + struct.pack("!I", StarTrackerActionIds.WRITE) + struct.pack("!B", region) + struct.pack("!I", address) - + bytearray(ImagePathDefs.flashFile, "utf-8") + + bytearray(FileDefs.flashFile, "utf-8") ) return command @@ -647,7 +662,7 @@ def pack_read_command(object_id: bytearray) -> bytearray: + struct.pack("!B", region) + struct.pack("!I", address) + struct.pack("!I", size) - + bytearray(ImagePathDefs.flashReadPath, "utf-8") + + bytearray(FileDefs.flashReadPath, "utf-8") ) return command @@ -667,27 +682,16 @@ def pack_checksum_command(object_id: bytearray) -> bytearray: def get_config_file() -> str: - LOGGER.info("Specify json file to use") - key = get_json_file_key() - while key not in json_selection: - LOGGER.info("Invalid key specified, try again.") - key = get_json_file_key() - jsonfile = json_selection[key][1] + LOGGER.info("Specify json file") + input_helper = InputHelper(json_dict) + key = input_helper.get_key() + jsonfile = json_dict[key][1] return jsonfile -def get_json_file_key(): - key_column_width = 10 - description_column_width = 50 - separator_width = key_column_width + description_column_width + 3 - separator_string = separator_width * "-" - key_string = "Key".ljust(key_column_width) - description_string = "Description".ljust(description_column_width) - LOGGER.info(f"{key_string} | {description_string}") - LOGGER.info(separator_string) - for key in json_selection: - key_string = key.ljust(key_column_width) - description_string = json_selection[key][0].ljust(description_column_width) - LOGGER.info(f"{key_string} | {description_string}") - key = input("Specify key: ") - return key +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 diff --git a/tmtccmd b/tmtccmd index 0fa5c5a..49cf288 160000 --- a/tmtccmd +++ b/tmtccmd @@ -1 +1 @@ -Subproject commit 0fa5c5a870cc5cd8ceb2199f775064ee07b332be +Subproject commit 49cf288831216c0680aedab88e31d684ba5b8da8 diff --git a/utility/input_helper.py b/utility/input_helper.py new file mode 100644 index 0000000..cd058ec --- /dev/null +++ b/utility/input_helper.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +""" +@file input_helper.py +@brief This class can be used to get user input. A dictionary must be provided which describes the input options. +@author J. Meier +@date 13.02.2021 +""" + +from tmtccmd.utility.logger import get_console_logger + +LOGGER = get_console_logger() + + +class InputHelper: + + def __init__(self, menu: dict): + """ + @brief Constructor + @param menu The describing the input options + """ + self.menu = menu + + def get_key(self) -> str: + """ + @brief Ask the user for input and returns the chosen key + """ + key = self.menu_handler() + while key not in self.menu: + LOGGER.info("Invalid key specified, try again.") + key = self.menu_handler() + return key + + def menu_handler(self) -> str: + key_column_width = 10 + description_column_width = 50 + separator_width = key_column_width + description_column_width + 3 + separator_string = separator_width * "-" + key_string = "Key".ljust(key_column_width) + description_string = "Description".ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + LOGGER.info(separator_string) + for key in self.menu: + key_string = key.ljust(key_column_width) + description_string = self.menu[key][0].ljust(description_column_width) + LOGGER.info(f"{key_string} | {description_string}") + key = input("Specify key: ") + return key + + From 14c6d7a5251d400f12b71a4444a374ca49802df8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 23 Feb 2022 18:16:10 +0100 Subject: [PATCH 14/14] star tracker firmware update --- config/hook_implementations.py | 139 ++++++++++++++-------------- pus_tc/star_tracker.py | 162 ++++++++++++++++++--------------- pus_tm/factory_hook.py | 3 + 3 files changed, 160 insertions(+), 144 deletions(-) diff --git a/config/hook_implementations.py b/config/hook_implementations.py index 5aafd7d..471355e 100644 --- a/config/hook_implementations.py +++ b/config/hook_implementations.py @@ -302,90 +302,91 @@ def get_eive_service_op_code_dict(service_op_code_dict: ServiceOpCodeDictT): service_ploc_updater_tuple = ("Ploc Updater", op_code_dict_srv_ploc_updater) op_code_dict_srv_star_tracker = { - "0": ("Star Tracker: Mode On", {OpCodeDictKeys.TIMEOUT: 2.0}), - "1": ("Star Tracker: Mode Normal", {OpCodeDictKeys.TIMEOUT: 2.0}), - "2": ("Star Tracker: Mode Off", {OpCodeDictKeys.TIMEOUT: 2.0}), - "3": ("Star Tracker: Mode Raw", {OpCodeDictKeys.TIMEOUT: 2.0}), - "4": ("Star Tracker: Ping", {OpCodeDictKeys.TIMEOUT: 2.0}), - "5": ( + "0": ("Star Tracker: Mode On, Submode Bootloader", {OpCodeDictKeys.TIMEOUT: 2.0}), + "1": ("Star Tracker: Mode On, Submode Firmware", {OpCodeDictKeys.TIMEOUT: 2.0}), + "2": ("Star Tracker: Mode Normal", {OpCodeDictKeys.TIMEOUT: 2.0}), + "3": ("Star Tracker: Mode Off", {OpCodeDictKeys.TIMEOUT: 2.0}), + "4": ("Star Tracker: Mode Raw", {OpCodeDictKeys.TIMEOUT: 2.0}), + "5": ("Star Tracker: Ping", {OpCodeDictKeys.TIMEOUT: 2.0}), + "6": ( "Star Tracker: Switch to bootloader program", {OpCodeDictKeys.TIMEOUT: 2.0}, ), - "6": ("Star Tracker: Request temperature", {OpCodeDictKeys.TIMEOUT: 2.0}), - "7": ("Star Tracker: Request version", {OpCodeDictKeys.TIMEOUT: 2.0}), - "8": ("Star Tracker: Request interface", {OpCodeDictKeys.TIMEOUT: 2.0}), - "9": ("Star Tracker: Request power", {OpCodeDictKeys.TIMEOUT: 2.0}), - "10": ("Star Tracker: Subscribe to telemetry", {OpCodeDictKeys.TIMEOUT: 2.0}), - "11": ( + "7": ("Star Tracker: Request temperature", {OpCodeDictKeys.TIMEOUT: 2.0}), + "8": ("Star Tracker: Request version", {OpCodeDictKeys.TIMEOUT: 2.0}), + "9": ("Star Tracker: Request interface", {OpCodeDictKeys.TIMEOUT: 2.0}), + "10": ("Star Tracker: Request power", {OpCodeDictKeys.TIMEOUT: 2.0}), + "11": ("Star Tracker: Subscribe to telemetry", {OpCodeDictKeys.TIMEOUT: 2.0}), + "12": ( "Star Tracker: Boot image (requires bootloader mode)", {OpCodeDictKeys.TIMEOUT: 2.0}, ), - "12": ("Star Tracker: Request time", {OpCodeDictKeys.TIMEOUT: 2.0}), - "13": ("Star Tracker: Request solution", {OpCodeDictKeys.TIMEOUT: 2.0}), - "14": ("Star Tracker: Upload image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "15": ("Star Tracker: Download image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "16": ("Star Tracker: Limits", {OpCodeDictKeys.TIMEOUT: 2.0}), - "17": ("Star Tracker: Tracking", {OpCodeDictKeys.TIMEOUT: 2.0}), - "18": ("Star Tracker: Mounting", {OpCodeDictKeys.TIMEOUT: 2.0}), - "19": ("Star Tracker: Camera", {OpCodeDictKeys.TIMEOUT: 2.0}), - "20": ("Star Tracker: Blob", {OpCodeDictKeys.TIMEOUT: 2.0}), - "21": ("Star Tracker: Centroiding", {OpCodeDictKeys.TIMEOUT: 2.0}), - "22": ("Star Tracker: LISA", {OpCodeDictKeys.TIMEOUT: 2.0}), - "23": ("Star Tracker: Matching", {OpCodeDictKeys.TIMEOUT: 2.0}), - "24": ("Star Tracker: Validation", {OpCodeDictKeys.TIMEOUT: 2.0}), - "25": ("Star Tracker: Algo", {OpCodeDictKeys.TIMEOUT: 2.0}), - "26": ("Star Tracker: Take image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "27": ("Star Tracker: Stop str helper", {OpCodeDictKeys.TIMEOUT: 2.0}), - "28": ("Star Tracker: Reset error signal", {OpCodeDictKeys.TIMEOUT: 2.0}), - "29": ( + "13": ("Star Tracker: Request time", {OpCodeDictKeys.TIMEOUT: 2.0}), + "14": ("Star Tracker: Request solution", {OpCodeDictKeys.TIMEOUT: 2.0}), + "15": ("Star Tracker: Upload image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "16": ("Star Tracker: Download image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "17": ("Star Tracker: Limits", {OpCodeDictKeys.TIMEOUT: 2.0}), + "18": ("Star Tracker: Tracking", {OpCodeDictKeys.TIMEOUT: 2.0}), + "19": ("Star Tracker: Mounting", {OpCodeDictKeys.TIMEOUT: 2.0}), + "20": ("Star Tracker: Camera", {OpCodeDictKeys.TIMEOUT: 2.0}), + "21": ("Star Tracker: Blob", {OpCodeDictKeys.TIMEOUT: 2.0}), + "22": ("Star Tracker: Centroiding", {OpCodeDictKeys.TIMEOUT: 2.0}), + "23": ("Star Tracker: LISA", {OpCodeDictKeys.TIMEOUT: 2.0}), + "24": ("Star Tracker: Matching", {OpCodeDictKeys.TIMEOUT: 2.0}), + "25": ("Star Tracker: Validation", {OpCodeDictKeys.TIMEOUT: 2.0}), + "26": ("Star Tracker: Algo", {OpCodeDictKeys.TIMEOUT: 2.0}), + "27": ("Star Tracker: Take image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "28": ("Star Tracker: Stop str helper", {OpCodeDictKeys.TIMEOUT: 2.0}), + "29": ("Star Tracker: Reset error signal", {OpCodeDictKeys.TIMEOUT: 2.0}), + "30": ( "Star Tracker: Set name of download image", {OpCodeDictKeys.TIMEOUT: 2.0}, ), - "30": ("Star Tracker: Request histogram", {OpCodeDictKeys.TIMEOUT: 2.0}), - "31": ("Star Tracker: Request contrast", {OpCodeDictKeys.TIMEOUT: 2.0}), - "32": ("Star Tracker: Set json filename", {OpCodeDictKeys.TIMEOUT: 2.0}), - "33": ("Star Tracker: Write", {OpCodeDictKeys.TIMEOUT: 2.0}), - "34": ("Star Tracker: Read", {OpCodeDictKeys.TIMEOUT: 2.0}), - "35": ("Star Tracker: Set Read filename", {OpCodeDictKeys.TIMEOUT: 2.0}), - "36": ("Star Tracker: Get checksum", {OpCodeDictKeys.TIMEOUT: 2.0}), - "37": ("Star Tracker: Set time", {OpCodeDictKeys.TIMEOUT: 2.0}), - "38": ("Star Tracker: Download centroid", {OpCodeDictKeys.TIMEOUT: 2.0}), - "39": ( + "31": ("Star Tracker: Request histogram", {OpCodeDictKeys.TIMEOUT: 2.0}), + "32": ("Star Tracker: Request contrast", {OpCodeDictKeys.TIMEOUT: 2.0}), + "33": ("Star Tracker: Set json filename", {OpCodeDictKeys.TIMEOUT: 2.0}), + "34": ("Star Tracker: Write", {OpCodeDictKeys.TIMEOUT: 2.0}), + "35": ("Star Tracker: Read", {OpCodeDictKeys.TIMEOUT: 2.0}), + "36": ("Star Tracker: Set Read filename", {OpCodeDictKeys.TIMEOUT: 2.0}), + "37": ("Star Tracker: Get checksum", {OpCodeDictKeys.TIMEOUT: 2.0}), + "38": ("Star Tracker: Set time", {OpCodeDictKeys.TIMEOUT: 2.0}), + "39": ("Star Tracker: Download centroid", {OpCodeDictKeys.TIMEOUT: 2.0}), + "40": ( "Star Tracker: Upload centroid (not implemented?)", {OpCodeDictKeys.TIMEOUT: 2.0}, ), - "40": ("Star Tracker: Download matched star", {OpCodeDictKeys.TIMEOUT: 2.0}), - "41": ("Star Tracker: Download DB Image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "42": ("Star Tracker: Download Blob Pixel", {OpCodeDictKeys.TIMEOUT: 2.0}), - "43": ("Star Tracker: Download FPGA Image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "44": ( + "41": ("Star Tracker: Download matched star", {OpCodeDictKeys.TIMEOUT: 2.0}), + "42": ("Star Tracker: Download DB Image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "43": ("Star Tracker: Download Blob Pixel", {OpCodeDictKeys.TIMEOUT: 2.0}), + "44": ("Star Tracker: Download FPGA Image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "45": ( "Star Tracker: Change download FPGA image name", {OpCodeDictKeys.TIMEOUT: 2.0}, ), - "45": ("Star Tracker: Upload FPGA image", {OpCodeDictKeys.TIMEOUT: 2.0}), - "46": ("Star Tracker: FPGA action", {OpCodeDictKeys.TIMEOUT: 2.0}), - "47": ("Star Tracker: Unlock", {OpCodeDictKeys.TIMEOUT: 2.0}), - "48": ("Star Tracker: Request camera parameter", {OpCodeDictKeys.TIMEOUT: 2.0}), - "49": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), - "50": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "51": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), - "52": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), - "53": ("Star Tracker: Request log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "54": ("Star Tracker: Request mounting parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "55": ("Star Tracker: Request image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "56": ("Star Tracker: Request centroiding parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "57": ("Star Tracker: Request lisa parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "58": ("Star Tracker: Request matching parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "59": ("Star Tracker: Request tracking parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "60": ("Star Tracker: Request validation parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "61": ("Star Tracker: Request algo parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "62": ("Star Tracker: Request subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "63": ("Star Tracker: Request log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "64": ("Star Tracker: Request debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "65": ("Star Tracker: Set log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "66": ("Star Tracker: Set log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "67": ("Star Tracker: Set debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), - "68": ("Star Tracker: Firmware update", {OpCodeDictKeys.TIMEOUT: 2.0}), + "46": ("Star Tracker: Upload FPGA image", {OpCodeDictKeys.TIMEOUT: 2.0}), + "47": ("Star Tracker: FPGA action", {OpCodeDictKeys.TIMEOUT: 2.0}), + "48": ("Star Tracker: Unlock", {OpCodeDictKeys.TIMEOUT: 2.0}), + "49": ("Star Tracker: Request camera parameter", {OpCodeDictKeys.TIMEOUT: 2.0}), + "50": ("Star Tracker: Request limits", {OpCodeDictKeys.TIMEOUT: 2.0}), + "51": ("Star Tracker: Set image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "52": ("Star Tracker: (EGSE only) Load camera ground config ", {OpCodeDictKeys.TIMEOUT: 2.0}), + "53": ("Star Tracker: (EGSE only) Load camera flight config", {OpCodeDictKeys.TIMEOUT: 2.0}), + "54": ("Star Tracker: Request log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "55": ("Star Tracker: Request mounting parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "56": ("Star Tracker: Request image processor parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "57": ("Star Tracker: Request centroiding parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "58": ("Star Tracker: Request lisa parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "59": ("Star Tracker: Request matching parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "60": ("Star Tracker: Request tracking parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "61": ("Star Tracker: Request validation parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "62": ("Star Tracker: Request algo parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "63": ("Star Tracker: Request subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "64": ("Star Tracker: Request log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "65": ("Star Tracker: Request debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "66": ("Star Tracker: Set log level parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "67": ("Star Tracker: Set log subscription parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "68": ("Star Tracker: Set debug camera parameters", {OpCodeDictKeys.TIMEOUT: 2.0}), + "69": ("Star Tracker: Firmware update", {OpCodeDictKeys.TIMEOUT: 2.0}), } service_star_tracker_tuple = ("Star tracker", op_code_dict_srv_star_tracker) diff --git a/pus_tc/star_tracker.py b/pus_tc/star_tracker.py index 8238242..e9e4d43 100644 --- a/pus_tc/star_tracker.py +++ b/pus_tc/star_tracker.py @@ -11,7 +11,7 @@ from tmtccmd.config.definitions import QueueCommands from tmtccmd.tc.packer import TcQueueT from spacepackets.ecss.tc import PusTelecommand -from pus_tc.service_200_mode import pack_mode_data +from tmtccmd.tc.service_200_mode import pack_mode_data, Modes from tmtccmd.utility.logger import get_console_logger from utility.input_helper import InputHelper @@ -101,6 +101,7 @@ class FileDefs: q7sFlightConfig = "/mnt/sd0/startracker/flight-config.json" firmware2_1 = "/home/pi/arcsec/firmware/sagitta2-1.bin" firmware22_1 = "/home/pi/arcsec/firmware/sagitta-22.1.bin" + firmware_origin = "/home/arcsec/21-921600/sagitta.bin" json_dict = { @@ -113,6 +114,7 @@ json_dict = { 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], } @@ -131,6 +133,11 @@ class PartitionSize: FREE_2 = 896000 +class Submode: + BOOTLOADER = 1 + FIRMWARE = 2 + + def pack_star_tracker_commands( object_id: bytearray, tc_queue: TcQueueT, op_code: str ) -> TcQueueT: @@ -142,31 +149,36 @@ def pack_star_tracker_commands( ) if op_code == "0": - tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode On")) - command = pack_mode_data(object_id, 1, 0) - command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command) + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode On, Submode Bootloader")) + command = pack_mode_data(object_id, Modes.ON, Submode.BOOTLOADER) + command = PusTelecommand(service=200, subservice=1, ssc=9, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "1": - tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode Normal")) - command = pack_mode_data(object_id, 2, 0) - command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=command) + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode On, Submode Firmware")) + command = pack_mode_data(object_id, Modes.ON, Submode.FIRMWARE) + command = PusTelecommand(service=200, subservice=1, ssc=10, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "2": - tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode Off")) - command = pack_mode_data(object_id, 0, 0) - command = PusTelecommand(service=200, subservice=1, ssc=12, app_data=command) + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode Normal")) + command = pack_mode_data(object_id, Modes.NORMAL, 0) + command = PusTelecommand(service=200, subservice=1, ssc=11, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) if op_code == "3": + tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode Off")) + command = pack_mode_data(object_id, Modes.OFF, 0) + command = PusTelecommand(service=200, subservice=1, ssc=12, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + if op_code == "4": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mode Raw")) command = pack_mode_data(object_id, 3, 0) command = PusTelecommand(service=200, subservice=1, ssc=13, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "4": + if op_code == "5": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Ping")) command = object_id + struct.pack("!I", StarTrackerActionIds.PING) command = PusTelecommand(service=8, subservice=128, ssc=30, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "5": + if op_code == "6": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Switch to bootloader program") ) @@ -175,27 +187,27 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=31, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "6": + if op_code == "7": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Temperature request")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_TEMPERATURE) command = PusTelecommand(service=8, subservice=128, ssc=32, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "7": + if op_code == "8": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request version")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_VERSION) command = PusTelecommand(service=8, subservice=128, ssc=33, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "8": + if op_code == "9": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request interface")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_INTERFACE) command = PusTelecommand(service=8, subservice=128, ssc=34, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "9": + if op_code == "10": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request power")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_POWER) command = PusTelecommand(service=8, subservice=128, ssc=35, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "10": + if op_code == "11": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Set subscription parameters") ) @@ -207,22 +219,22 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=36, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "11": + if op_code == "12": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Boot")) command = object_id + struct.pack("!I", StarTrackerActionIds.BOOT) command = PusTelecommand(service=8, subservice=128, ssc=37, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "12": + if op_code == "13": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request time")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_TIME) command = PusTelecommand(service=8, subservice=128, ssc=38, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "13": + if op_code == "14": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request solution")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_SOLUTION) command = PusTelecommand(service=8, subservice=128, ssc=39, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "14": + if op_code == "15": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload image")) command = ( object_id @@ -231,7 +243,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "15": + if op_code == "16": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download image")) path = input("Specify storage location (default - /mnt/sd0/startracker): ") if not path: @@ -243,7 +255,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=53, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "16": + if op_code == "17": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set limits")) command = ( object_id @@ -252,7 +264,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=42, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "17": + if op_code == "18": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Set tracking parameters") ) @@ -263,7 +275,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=43, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "18": + if op_code == "19": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Mounting")) command = ( object_id @@ -272,7 +284,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=44, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "19": + if op_code == "20": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Camera")) command = ( object_id @@ -281,7 +293,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=45, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "20": + if op_code == "21": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Blob")) command = ( object_id @@ -290,7 +302,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=46, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "21": + if op_code == "22": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Centroiding")) command = ( object_id @@ -299,7 +311,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=47, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "22": + if op_code == "23": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: LISA")) command = ( object_id @@ -308,7 +320,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=48, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "23": + if op_code == "24": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Matching")) command = ( object_id @@ -317,7 +329,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=49, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "24": + if op_code == "25": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Validation")) command = ( object_id @@ -326,7 +338,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=50, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "25": + if op_code == "26": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Algo")) jsonfile = get_config_file() command = ( @@ -336,7 +348,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=51, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "26": + if op_code == "27": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Take image")) actionid = int(input("Specify parameter ID (nominal - 4): ")) command = ( @@ -346,17 +358,17 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=52, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "27": + if op_code == "28": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Stop str helper")) command = object_id + struct.pack("!I", StarTrackerActionIds.STOP_STR_HELPER) command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "28": + if op_code == "29": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Reset error signal")) command = object_id + struct.pack("!I", StarTrackerActionIds.RESET_ERROR) command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "29": + if op_code == "30": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Set name of download image") ) @@ -368,17 +380,17 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=54, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "30": + if op_code == "31": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request histogram")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_HISTOGRAM) command = PusTelecommand(service=8, subservice=128, ssc=55, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "31": + if op_code == "32": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request contrast")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_CONTRAST) command = PusTelecommand(service=8, subservice=128, ssc=56, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "32": + if op_code == "33": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set json filename")) command = ( object_id @@ -387,17 +399,17 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=57, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "33": + if op_code == "34": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Write")) command = pack_write_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=58, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "34": + if op_code == "35": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Read")) command = pack_read_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=59, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "35": + if op_code == "36": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set read filename")) filename = input("Specify filename: ") command = ( @@ -407,12 +419,12 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=60, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "36": + if op_code == "37": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Get checksum")) command = pack_checksum_command(object_id) command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "37": + if op_code == "38": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set time")) unix_time = 1640783543 command = ( @@ -422,7 +434,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=61, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "38": + if op_code == "39": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Centroid")) id = 0 command = ( @@ -432,7 +444,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=62, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "39": + if op_code == "40": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload Centroid")) command = ( object_id @@ -441,7 +453,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=63, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "40": + if op_code == "41": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Download matched star") ) @@ -453,7 +465,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=64, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "41": + if op_code == "42": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download DB Image")) id = 0 command = ( @@ -463,7 +475,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "42": + if op_code == "43": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download Blob Pixel")) id = 0 type = 1 # 0 - normal, 1 - fast @@ -475,7 +487,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=65, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "43": + if op_code == "44": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Download FPGA Image")) position = int(input("Start position: ")) length = int(input("Size to download: ")) @@ -488,7 +500,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=66, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "44": + if op_code == "45": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Change donwload FPGA image file name") ) @@ -499,7 +511,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=67, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "45": + if op_code == "46": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Upload FPGA image")) command = ( object_id @@ -508,7 +520,7 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=68, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "46": + if op_code == "47": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: FPGA action")) id = 3 command = ( @@ -518,120 +530,120 @@ def pack_star_tracker_commands( ) command = PusTelecommand(service=8, subservice=128, ssc=69, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "47": + if op_code == "48": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Unlock")) command = object_id + struct.pack("!I", StarTrackerActionIds.UNLOCK) command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "48": + if op_code == "49": tc_queue.appendleft( (QueueCommands.PRINT, "Star tracker: Request camera parameters") ) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_CAMERA_PARAMS) command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "49": + if op_code == "50": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request limits")) command = object_id + struct.pack("!I", StarTrackerActionIds.REQ_LIMITS) command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "50": + if op_code == "51": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set image processor parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.IMAGE_PROCESSOR) + \ bytearray(FileDefs.jsonFile, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=70, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "51": + if op_code == "52": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load ground config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(FileDefs.egseGroundConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=71, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "52": + if op_code == "53": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: EGSE load flight config camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.CAMERA) + \ bytearray(FileDefs.egseFlightConfig, 'utf-8') command = PusTelecommand(service=8, subservice=128, ssc=72, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "53": + if op_code == "54": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log level parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_LEVEL) command = PusTelecommand(service=8, subservice=128, ssc=74, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "54": + if op_code == "55": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request mounting parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MOUNTING) command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "55": + if op_code == "56": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request image processor parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_IMAGE_PROCESSOR) command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "56": + if op_code == "57": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request centroiding parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_CENTROIDING) command = PusTelecommand(service=8, subservice=128, ssc=75, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "57": + if op_code == "58": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request lisa parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LISA) command = PusTelecommand(service=8, subservice=128, ssc=76, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "58": + if op_code == "59": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request matching parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_MATCHING) command = PusTelecommand(service=8, subservice=128, ssc=77, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "59": + if op_code == "60": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request tracking parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_TRACKING) command = PusTelecommand(service=8, subservice=128, ssc=78, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "60": + if op_code == "61": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request validation parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_VALIDATION) command = PusTelecommand(service=8, subservice=128, ssc=79, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "61": + if op_code == "62": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request algo parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_ALGO) command = PusTelecommand(service=8, subservice=128, ssc=80, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "62": + if op_code == "63": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request subscription parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_SUBSCRIPTION) command = PusTelecommand(service=8, subservice=128, ssc=81, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "63": + if op_code == "64": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request log subscription parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_LOG_SUBSCRIPTION) command = PusTelecommand(service=8, subservice=128, ssc=82, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "64": + if op_code == "65": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Request debug camera parameters")) command = object_id + struct.pack('!I', StarTrackerActionIds.REQ_DEBUG_CAMERA) command = PusTelecommand(service=8, subservice=128, ssc=83, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "65": + if op_code == "66": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log level parameters")) jsonfile = get_config_file() command = object_id + struct.pack('!I', StarTrackerActionIds.LOGLEVEL) + bytearray(jsonfile, "utf-8") command = PusTelecommand(service=8, subservice=128, ssc=84, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "66": + if op_code == "67": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set log subscription parameters")) jsonfile = get_config_file() command = object_id + struct.pack('!I', StarTrackerActionIds.LOG_SUBSCRIPTION) + bytearray(jsonfile, "utf-8") command = PusTelecommand(service=8, subservice=128, ssc=85, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "67": + if op_code == "68": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Set debug camera parameters")) jsonfile = get_config_file() command = object_id + struct.pack('!I', StarTrackerActionIds.DEBUG_CAMERA) + bytearray(jsonfile, "utf-8") command = PusTelecommand(service=8, subservice=128, ssc=86, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) - if op_code == "68": + if op_code == "69": tc_queue.appendleft((QueueCommands.PRINT, "Star tracker: Firmware update")) firmware = get_firmware() command = object_id + struct.pack('!I', StarTrackerActionIds.FIRMWARE_UPDATE) + bytearray(firmware, "utf-8") diff --git a/pus_tm/factory_hook.py b/pus_tm/factory_hook.py index 74d73dd..7826b66 100644 --- a/pus_tm/factory_hook.py +++ b/pus_tm/factory_hook.py @@ -11,6 +11,7 @@ from tmtccmd.pus.service_1_verification import Service1TMExtended from tmtccmd.pus.service_17_test import Service17TMExtended from tmtccmd.tm.service_3_housekeeping import Service3TM from tmtccmd.tm.service_5_event import Service5TM +from tmtccmd.tm.service_200_mode import Service200TM from tmtccmd.utility.tmtc_printer import TmTcPrinter, PrintFormats from config.definitions import PUS_APID @@ -44,6 +45,8 @@ def pus_factory_hook(raw_tm_packet: bytearray, tmtc_printer: TmTcPrinter): tm_packet = Service8TM.unpack(raw_telemetry=raw_tm_packet) if service_type == 17: tm_packet = Service17TMExtended.unpack(raw_telemetry=raw_tm_packet) + if service_type == 200: + tm_packet = Service200TM.unpack(raw_telemetry=raw_tm_packet) if tm_packet is None: LOGGER.info( f"The service {service_type} is not implemented in Telemetry Factory"