From c50ef12729309f9851d91621e2f289d574735ab8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Sat, 29 Jan 2022 18:37:28 +0100 Subject: [PATCH 1/2] 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 2/2] 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())