diff --git a/config/obsw_config.py b/config/obsw_config.py index 68de043a5d15993de1352ff2790d2977cf657204..1b5467ccc59bac50631f8555061c0fc65fd18756 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -29,6 +29,7 @@ DUMMY_DEVICE_ID = bytearray([0x44, 0x00, 0xAF, 0xFE]) THERMAL_SENSOR_DEVICE_ID = bytearray([0x44, 0x11, 0x54, 0x00]) GYRO_DEVICE_ID = bytearray([0x44, 0x11, 0x55, 0x00]) TEST_TASK_ID = bytearray([0x42, 0x69, 0x42, 0x69]) +LED_TASK_ID = bytearray([0x62, 0x00, 0x00, 0x01]) SD_CARD_HANDLER_ID = bytearray([0x4D, 0x00, 0x73, 0xAD]) INTERNAL_ERROR_REPORTER_ID = bytearray([0x53, 0x04, 0x00, 0x00]) diff --git a/tc/obsw_image_handler.py b/tc/obsw_image_handler.py index be5fd0b174ac405a9acc625997dd6f74273cc038..6f3216861781687d30e6180c43cdb21eed8379a7 100644 --- a/tc/obsw_image_handler.py +++ b/tc/obsw_image_handler.py @@ -1,3 +1,5 @@ +from typing import Union + from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand, Deque from tc.obsw_tc_service8 import make_action_id from tc.obsw_tc_service20 import pack_boolean_parameter_setting @@ -30,7 +32,7 @@ def generate_param_packet_hamming_from_sdcard(enable: bool, ssc: int, parameter=enable, ssc=ssc) -def generate_img_handler_packet(service_queue: Deque, op_code: int): +def generate_img_handler_packet(service_queue: Deque, op_code: Union[int, str]): # Action ID 4 (Copy SDC to Flash, Software Update Image) if op_code == "A4U": service_queue.appendleft(("print", "Generating command to copy SDC OBSW to flash.")) diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index 52152688dad6933afa6fa76d717a9be147d9f736..77fc692d736ac9ad830a234d7e13fd91453db6d2 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -16,6 +16,7 @@ from tc.obsw_tc_service8 import pack_service8_test_into from tc.obsw_tc_service9 import pack_service9_test_into from tc.obsw_tc_service23_sdcard import pack_service23_commands_into from tc.obsw_tc_service20 import pack_service20_test_into +from tc.obsw_tc_utility import pack_utility_command from tc.obsw_tc_service200 import pack_mode_data, pack_service200_test_into from tc.obsw_tc_service5_17 import pack_service5_test_into, pack_service17_test_into from tc.obsw_image_handler import generate_img_handler_packet @@ -60,6 +61,8 @@ class ServiceQueuePacker: return generate_img_handler_packet(service_queue, op_code) if service.lower() == "core": return pack_core_command(service_queue, op_code) + if service.lower() == "led": + return pack_utility_command(service_queue, op_code) if service.lower() == "gps0": # Object ID: GPS Device object_id = g.GPS0_DEVICE_ID diff --git a/tc/obsw_tc_service8.py b/tc/obsw_tc_service8.py index 9166214399eed0fa485d9d471cf1d6ee358da9bb..6449fcf45f5599368fc0b30061cc7d68ef0ce8ea 100644 --- a/tc/obsw_tc_service8.py +++ b/tc/obsw_tc_service8.py @@ -65,5 +65,12 @@ def pack_service8_test_into(tc_queue: Deque, called_externally: bool = False) -> return tc_queue +def generate_action_command(object_id: bytearray, action_id: int, data: bytearray = bytearray([]), + ssc: int = 0): + data_to_pack = bytearray(object_id) + data_to_pack += make_action_id(action_id) + data + return PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=data_to_pack) + + def make_action_id(action_id: int) -> bytearray: return bytearray(struct.pack('!I', action_id)) diff --git a/tc/obsw_tc_utility.py b/tc/obsw_tc_utility.py new file mode 100644 index 0000000000000000000000000000000000000000..9f21283dc0bdfdc34194b3e135432540233b7d13 --- /dev/null +++ b/tc/obsw_tc_utility.py @@ -0,0 +1,13 @@ +from typing import Union + +from tmtc_core.tc.obsw_pus_tc_base import TcQueueT +from tc.obsw_tc_service8 import generate_action_command +from config.obsw_config import LED_TASK_ID + + +def pack_utility_command(service_queue: TcQueueT, op_code: Union[str, int]): + if op_code == "A0": + service_queue.appendleft(generate_action_command(LED_TASK_ID, 0x00).pack_command_tuple()) + elif op_code == "A1": + service_queue.appendleft(generate_action_command(LED_TASK_ID, 0x01).pack_command_tuple()) +