diff --git a/pus_tc/reaction_wheels.py b/pus_tc/reaction_wheels.py index 24d764e..b407976 100644 --- a/pus_tc/reaction_wheels.py +++ b/pus_tc/reaction_wheels.py @@ -5,6 +5,7 @@ @author J. Meier @date 25.03.2021 """ +import struct from tmtccmd.config.definitions import QueueCommands from tmtccmd.pus_tc.packer import TcQueueT @@ -21,6 +22,7 @@ class RwCommandIds: RESET_MCU = bytearray([0x0, 0x0, 0x0, 0x01]) # Reads status information from reaction wheel into dataset with id 4 GET_RW_STATUS = bytearray([0x0, 0x0, 0x0, 0x04]) + INIT_RW_CONTROLLER = bytearray([0x0, 0x0, 0x0, 0x05]) SET_SPEED = bytearray([0x0, 0x0, 0x0, 0x06]) # Reads temperature from reaction wheel into dataset with id 8 GET_TEMPERATURE = bytearray([0x0, 0x0, 0x0, 0x08]) @@ -43,10 +45,15 @@ def pack_single_rw_test_into(object_id: bytearray, tc_queue: TcQueueT, op_code: if op_code == "0" or op_code == "1": tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Set speed")) - command = pack_set_speed_command(object_id, 10000, 1000) + command = pack_set_speed_command(object_id, -2000, 100) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command) tc_queue.appendleft(command.pack_command_tuple()) + tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Init reaction wheel controller")) + command = object_id + RwCommandIds.INIT_RW_CONTROLLER + command = PusTelecommand(service=8, subservice=128, ssc=41, app_data=command) + tc_queue.appendleft(command.pack_command_tuple()) + return tc_queue @@ -60,6 +67,6 @@ def pack_set_speed_command(object_id: bytearray, speed: int, ramp_time: int) -> command_id = RwCommandIds.SET_SPEED command = bytearray() command = object_id + command_id - command = command + speed.to_bytes(length=4, byteorder='big') + command = command + struct.pack('!i', speed) command = command + ramp_time.to_bytes(length=2, byteorder='big') return command