some fixes for rw ass commanding

This commit is contained in:
Robin Müller 2022-05-10 18:34:15 +02:00
parent 8891908afa
commit a648b7f76f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 48 additions and 23 deletions

View File

@ -6,7 +6,11 @@
""" """
import struct import struct
from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT from tmtccmd.config.definitions import QueueCommands, ServiceOpCodeDictT
from tmtccmd.tc.pus_3_fsfw_hk import generate_one_hk_command, make_sid from tmtccmd.tc.pus_3_fsfw_hk import (
generate_one_hk_command,
generate_one_diag_command,
make_sid,
)
from tmtccmd.config.globals import add_op_code_entry, add_service_op_code_entry from tmtccmd.config.globals import add_op_code_entry, add_service_op_code_entry
from tmtccmd.tc.packer import TcQueueT from tmtccmd.tc.packer import TcQueueT
from spacepackets.ecss.tc import PusTelecommand from spacepackets.ecss.tc import PusTelecommand
@ -19,7 +23,8 @@ class OpCodesDevs:
ON = ["1", "on"] ON = ["1", "on"]
NML = ["2", "nml"] NML = ["2", "nml"]
OFF = ["3", "off"] OFF = ["3", "off"]
GET_TM = ["4", "tm"] GET_STATUS = ["4", "status"]
GET_TM = ["5", "tm"]
class InfoDevs: class InfoDevs:
@ -27,6 +32,7 @@ class InfoDevs:
ON = "Set On" ON = "Set On"
NML = "Set Normal" NML = "Set Normal"
OFF = "Set Off" OFF = "Set Off"
GET_STATUS = "Get Status HK"
GET_TM = "Get TM HK" GET_TM = "Get TM HK"
@ -81,10 +87,12 @@ def add_rw_cmds(cmd_dict: ServiceOpCodeDictT):
add_op_code_entry( add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.NML, keys=OpCodesDevs.NML op_code_dict=op_code_dict, info=InfoDevs.NML, keys=OpCodesDevs.NML
) )
add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.GET_STATUS, keys=OpCodesDevs.GET_STATUS
)
add_op_code_entry( add_op_code_entry(
op_code_dict=op_code_dict, info=InfoDevs.GET_TM, keys=OpCodesDevs.GET_TM op_code_dict=op_code_dict, info=InfoDevs.GET_TM, keys=OpCodesDevs.GET_TM
) )
add_service_op_code_entry( add_service_op_code_entry(
srv_op_code_dict=cmd_dict, srv_op_code_dict=cmd_dict,
name=CustomServiceList.REACTION_WHEEL_1.value, name=CustomServiceList.REACTION_WHEEL_1.value,
@ -156,21 +164,35 @@ def pack_single_rw_test_into(
sid=make_sid(object_id=object_id, set_id=RwSetIds.TM_SET), ssc=0 sid=make_sid(object_id=object_id, set_id=RwSetIds.TM_SET), ssc=0
) )
tc_queue.appendleft(command.pack_command_tuple()) tc_queue.appendleft(command.pack_command_tuple())
if op_code in OpCodesDevs.GET_STATUS:
tc_queue.appendleft(
(QueueCommands.PRINT, f"RW {rw_idx}: {InfoDevs.GET_STATUS}")
)
command = generate_one_diag_command(
sid=make_sid(object_id=object_id, set_id=RwSetIds.STATUS_SET_ID), ssc=0
)
tc_queue.appendleft(command.pack_command_tuple())
return tc_queue return tc_queue
def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str): def pack_rw_ass_cmds(tc_queue: TcQueueT, object_id: bytes, op_code: str):
if op_code in OpCodesAss.OFF: if op_code in OpCodesAss.OFF:
data = pack_mode_data(object_id=object_id, mode=Modes.OFF, submode=0) data = pack_mode_data(object_id=object_id, mode=Modes.OFF, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data) cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple()) tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in OpCodesAss.ON: if op_code in OpCodesAss.ON:
data = pack_mode_data(object_id=object_id, mode=Modes.ON, submode=0) data = pack_mode_data(object_id=object_id, mode=Modes.ON, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data) cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple()) tc_queue.appendleft(cmd.pack_command_tuple())
if op_code in OpCodesAss.NML: if op_code in OpCodesAss.NML:
data = pack_mode_data(object_id=object_id, mode=Modes.NORMAL, submode=0) data = pack_mode_data(object_id=object_id, mode=Modes.NORMAL, submode=0)
cmd = PusTelecommand(service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data) cmd = PusTelecommand(
service=200, subservice=Subservices.TC_MODE_COMMAND, app_data=data
)
tc_queue.appendleft(cmd.pack_command_tuple()) tc_queue.appendleft(cmd.pack_command_tuple())

View File

@ -232,7 +232,7 @@ def pack_service_queue_user(
return pack_tcs_sys_commands(tc_queue=service_queue, op_code=op_code) return pack_tcs_sys_commands(tc_queue=service_queue, op_code=op_code)
if service == CustomServiceList.TIME.value: if service == CustomServiceList.TIME.value:
return pack_set_current_time_ascii_command(tc_queue=service_queue, ssc=0) return pack_set_current_time_ascii_command(tc_queue=service_queue, ssc=0)
if service == CustomServiceList.RW_ASSEMBLY: if service == CustomServiceList.RW_ASSEMBLY.value:
return pack_rw_ass_cmds( return pack_rw_ass_cmds(
tc_queue=service_queue, object_id=RW_ASSEMBLY, op_code=op_code tc_queue=service_queue, object_id=RW_ASSEMBLY, op_code=op_code
) )

View File

@ -11,27 +11,30 @@ def handle_rw_hk_data(
pw = PrintWrapper(printer) pw = PrintWrapper(printer)
current_idx = 0 current_idx = 0
if set_id == RwSetIds.TEMPERATURE_SET_ID:
pw.dlog(
f"Received Temperature HK (ID {set_id}) from Reaction Wheel {object_id.name}"
)
temp = struct.unpack("!I", hk_data[0:4])
pw.dlog(f"Temperature {temp}")
current_idx += 4
if set_id == RwSetIds.STATUS_SET_ID: if set_id == RwSetIds.STATUS_SET_ID:
pw.dlog( pw.dlog(
f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}" f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}"
) )
fmt_str = "!iiBB" fmt_str = "!IiiBB"
inc_len = struct.calcsize(fmt_str) inc_len = struct.calcsize(fmt_str)
(speed, ref_speed, state, clc_mode) = struct.unpack( (temp, speed, ref_speed, state, clc_mode) = struct.unpack(
fmt_str, hk_data[current_idx : current_idx + inc_len] fmt_str, hk_data[current_idx : current_idx + inc_len]
) )
current_idx += inc_len current_idx += inc_len
speed_rpm = speed / 10.0
ref_speed_rpm = ref_speed / 10.0
pw.dlog( pw.dlog(
f"Speed {speed} rpm | Reference Speed {ref_speed} rpm | State {state} | " f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed {ref_speed_rpm} rpm"
f"CLC Mode {clc_mode}"
) )
pw.dlog(
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
f"4: Running, speed changing"
)
pw.dlog(
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
f"1: High Current Mode (0.6 A)"
)
printer.print_validity_buffer(hk_data[current_idx:], 5)
if set_id == RwSetIds.LAST_RESET: if set_id == RwSetIds.LAST_RESET:
pw.dlog( pw.dlog(
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}" f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}"

View File

@ -19,7 +19,7 @@ from tmtccmd.utility.obj_id import ObjectId, ObjectIdDictT
import config.object_ids as obj_ids import config.object_ids as obj_ids
from pus_tm.devs.reaction_wheels import handle_rw_hk_data from pus_tm.devs.reaction_wheels import handle_rw_hk_data
from pus_tm.defs import PrintWrapper, FsfwTmTcPrinter from pus_tm.defs import PrintWrapper, FsfwTmTcPrinter, log_to_both
LOGGER = get_console_logger() LOGGER = get_console_logger()