diff --git a/config/obsw_config.py b/config/obsw_config.py index a92d079c6598ab5bcc6df18cc4d2b694e0d69a72..68de043a5d15993de1352ff2790d2977cf657204 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -20,6 +20,8 @@ Mission/Device specific information. # TODO: Automate / Autofill this file with the MIB parser # Object IDs +CORE_CONTROLLER_ID = bytearray([0x40, 0x00, 0x10, 0x00]) +SW_IMAGE_HANDLER_ID = bytearray([0x4D, 0x00, 0x90, 0x00]) PUS_SERVICE_17 = bytearray([0x53, 0x00, 0x00, 0x17]) GPS0_DEVICE_ID = bytearray([0x44, 0x10, 0x1F, 0x00]) GPS1_DEVICE_ID = bytearray([0x44, 0x20, 0x20, 0x00]) @@ -28,7 +30,6 @@ 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]) SD_CARD_HANDLER_ID = bytearray([0x4D, 0x00, 0x73, 0xAD]) -SW_IMAGE_HANDLER_ID = bytearray([0x4D, 0x00, 0x90, 0x00]) INTERNAL_ERROR_REPORTER_ID = bytearray([0x53, 0x04, 0x00, 0x00]) # Commands diff --git a/tc/obsw_pus_tc_packer.py b/tc/obsw_pus_tc_packer.py index a6f2597fa6ec74e0d635dc70a08c4586efe25b1f..943a52c4b3039f300c5c09023d22524d88fca6ac 100644 --- a/tc/obsw_pus_tc_packer.py +++ b/tc/obsw_pus_tc_packer.py @@ -20,6 +20,7 @@ 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 from tc.obsw_tc_gps import pack_gps_test_into +from tc.obsw_tc_core import pack_core_command from tmtc_core.utility.obsw_logger import get_logger import config.obsw_config as g @@ -48,23 +49,25 @@ class ServiceQueuePacker: return pack_service17_test_into(service_queue) if service == 20: return pack_service20_test_into(service_queue) - if service == 23 or service == "SD": + if service == 23 or service.lower() == "sd": return pack_service23_commands_into(service_queue, op_code) if service == 200: return pack_service200_test_into(service_queue) - if service == "Dummy": + if service.lower() == "dummy": return pack_dummy_device_test_into(service_queue) - if service == "Img": + if service.lower() == "img": return generate_img_handler_packet(service_queue, op_code) - if service == "GPS0": + if service.lower() == "core": + return pack_core_command(service_queue, op_code) + if service.lower() == "gps0": # Object ID: GPS Device object_id = g.GPS0_DEVICE_ID return pack_gps_test_into(object_id, service_queue) - if service == "GPS1": + if service.lower() == "gps1": # Object ID: GPS Device object_id = g.GPS1_DEVICE_ID return pack_gps_test_into(object_id, service_queue) - if service == "Error": + if service.lower() == "Error": return pack_error_testing_into(service_queue) LOGGER.warning("Invalid Service !") diff --git a/tc/obsw_tc_core.py b/tc/obsw_tc_core.py new file mode 100644 index 0000000000000000000000000000000000000000..700a5a2f889d431adc647271b407ecb8806e53df --- /dev/null +++ b/tc/obsw_tc_core.py @@ -0,0 +1,18 @@ +from typing import Deque + +from config.obsw_config import CORE_CONTROLLER_ID +from tc.obsw_tc_service8 import make_action_id +from tmtc_core.tc.obsw_pus_tc_base import PusTelecommand + + +def pack_core_command(tc_queue: Deque, op_code: int, ssc: int = 0): + if op_code == 10: + tc_queue.appendleft(("print", "Resetting OBC.")) + command = generate_reset_obc_command(ssc=ssc) + tc_queue.appendleft(command.pack_command_tuple()) + + +def generate_reset_obc_command(ssc: int, object_id: bytearray = CORE_CONTROLLER_ID): + app_data = bytearray(object_id) + app_data += make_action_id(10) + return PusTelecommand(service=8, subservice=128, ssc=ssc, app_data=app_data)