add init command

This commit is contained in:
Martin Zietz 2021-06-28 14:08:04 +02:00
parent 19b76d961c
commit 10ea97ff0b

View File

@ -5,6 +5,7 @@
@author J. Meier @author J. Meier
@date 25.03.2021 @date 25.03.2021
""" """
import struct
from tmtccmd.config.definitions import QueueCommands from tmtccmd.config.definitions import QueueCommands
from tmtccmd.pus_tc.packer import TcQueueT from tmtccmd.pus_tc.packer import TcQueueT
@ -21,6 +22,7 @@ class RwCommandIds:
RESET_MCU = bytearray([0x0, 0x0, 0x0, 0x01]) RESET_MCU = bytearray([0x0, 0x0, 0x0, 0x01])
# Reads status information from reaction wheel into dataset with id 4 # Reads status information from reaction wheel into dataset with id 4
GET_RW_STATUS = bytearray([0x0, 0x0, 0x0, 0x04]) GET_RW_STATUS = bytearray([0x0, 0x0, 0x0, 0x04])
INIT_RW_CONTROLLER = bytearray([0x0, 0x0, 0x0, 0x05])
SET_SPEED = bytearray([0x0, 0x0, 0x0, 0x06]) SET_SPEED = bytearray([0x0, 0x0, 0x0, 0x06])
# Reads temperature from reaction wheel into dataset with id 8 # Reads temperature from reaction wheel into dataset with id 8
GET_TEMPERATURE = bytearray([0x0, 0x0, 0x0, 0x08]) 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": if op_code == "0" or op_code == "1":
tc_queue.appendleft((QueueCommands.PRINT, "Reaction Wheel: Set speed")) 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) command = PusTelecommand(service=8, subservice=128, ssc=40, app_data=command)
tc_queue.appendleft(command.pack_command_tuple()) 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 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_id = RwCommandIds.SET_SPEED
command = bytearray() command = bytearray()
command = object_id + command_id 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') command = command + ramp_time.to_bytes(length=2, byteorder='big')
return command return command