some restructuring
This commit is contained in:
parent
0ddb9587ba
commit
968db5ce51
@ -27,11 +27,10 @@ from tmtc.power.p60dock import pack_p60dock_cmds
|
||||
from tmtc.power.pdu2 import pack_pdu2_commands
|
||||
from tmtc.power.pdu1 import pack_pdu1_commands
|
||||
from tmtc.power.acu import pack_acu_commands
|
||||
from tmtc.solar_array_deployment import pack_solar_array_deployment_test_into
|
||||
from pus_tc.devs.imtq import pack_imtq_test_into
|
||||
from pus_tc.devs.tmp1075 import pack_tmp1075_test_into
|
||||
from pus_tc.devs.heater import pack_heater_cmds
|
||||
from pus_tc.devs.reaction_wheels import pack_single_rw_test_into, pack_rw_ass_cmds
|
||||
from tmtc.reaction_wheels import pack_single_rw_test_into, pack_rw_ass_cmds
|
||||
from pus_tc.devs.rad_sensor import pack_rad_sensor_test_into
|
||||
from tmtc.ploc_memory_dumper import pack_ploc_memory_dumper_cmd
|
||||
from pus_tc.devs.ccsds_handler import pack_ccsds_handler_test
|
||||
@ -65,7 +64,6 @@ from config.object_ids import (
|
||||
PDEC_HANDLER_ID,
|
||||
STR_IMG_HELPER_ID,
|
||||
SYRLINKS_HANDLER_ID,
|
||||
SOLAR_ARRAY_DEPLOYMENT_ID,
|
||||
RW_ASSEMBLY,
|
||||
get_object_ids,
|
||||
)
|
||||
|
@ -33,12 +33,12 @@ from pus_tc.devs.gps import SetIds as GpsSetIds
|
||||
from pus_tc.devs.imtq import ImtqSetIds
|
||||
from pus_tc.devs.sus import SetIds
|
||||
from pus_tc.devs.star_tracker import SetIds as StrSetIds
|
||||
from pus_tc.devs.reaction_wheels import RwSetIds
|
||||
from tmtc.reaction_wheels import RwSetIds, rw_speed_up_cmd_consec
|
||||
from pus_tc.system.controllers import pack_cmd_ctrl_to_off, pack_cmd_ctrl_to_nml
|
||||
from pus_tc.system.acs import pack_acs_command, pack_sus_cmds
|
||||
from pus_tc.devs.imtq import pack_imtq_test_into, pack_dipole_command
|
||||
from pus_tc.devs.star_tracker import pack_star_tracker_commands
|
||||
from pus_tc.devs.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command
|
||||
from tmtc.reaction_wheels import pack_rw_ass_cmds, pack_set_speed_command
|
||||
|
||||
|
||||
class OpCodes:
|
||||
@ -825,24 +825,6 @@ def rw_speed_cmd_single(
|
||||
q.add_pus_tc(pack_set_speed_command(object_id=oid, speed=0, ramp_time_ms=ramp_time))
|
||||
|
||||
|
||||
def rw_speed_up_cmd_consec(
|
||||
q: DefaultPusQueueHelper, obids: List[bytes], speed: int, ramp_time: int
|
||||
):
|
||||
for oid in obids:
|
||||
q.add_pus_tc(
|
||||
pack_set_speed_command(object_id=oid, speed=speed, ramp_time_ms=ramp_time)
|
||||
)
|
||||
|
||||
|
||||
def rw_speed_down_cmd_consec(
|
||||
q: DefaultPusQueueHelper, obids: List[bytes], ramp_time: int
|
||||
):
|
||||
for oid in obids:
|
||||
q.add_pus_tc(
|
||||
pack_set_speed_command(object_id=oid, speed=0, ramp_time_ms=ramp_time)
|
||||
)
|
||||
|
||||
|
||||
def activate_all_rws_in_sequence(
|
||||
q: DefaultPusQueueHelper, init_ssc: int, test_speed: int, test_ramp_time: int
|
||||
):
|
||||
|
@ -1,124 +0,0 @@
|
||||
import struct
|
||||
|
||||
from pus_tm.defs import PrintWrapper, FsfwTmTcPrinter
|
||||
from tmtccmd.util.obj_id import ObjectIdU32
|
||||
|
||||
|
||||
def handle_rw_hk_data(
|
||||
printer: FsfwTmTcPrinter, object_id: ObjectIdU32, set_id: int, hk_data: bytes
|
||||
):
|
||||
from pus_tc.devs.reaction_wheels import RwSetIds
|
||||
|
||||
pw = PrintWrapper(printer)
|
||||
current_idx = 0
|
||||
if set_id == RwSetIds.STATUS_SET_ID:
|
||||
pw.dlog(
|
||||
f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}"
|
||||
)
|
||||
fmt_str = "!IiiBB"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(temp, speed, ref_speed, state, clc_mode) = struct.unpack(
|
||||
fmt_str, hk_data[current_idx : current_idx + inc_len]
|
||||
)
|
||||
current_idx += inc_len
|
||||
speed_rpm = speed / 10.0
|
||||
ref_speed_rpm = ref_speed / 10.0
|
||||
pw.dlog(
|
||||
f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed {ref_speed_rpm} rpm"
|
||||
)
|
||||
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:
|
||||
pw.dlog(
|
||||
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}"
|
||||
)
|
||||
fmt_str = "!BB"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(last_not_cleared_reset_status, current_reset_status) = struct.unpack(
|
||||
fmt_str, hk_data[current_idx : current_idx + inc_len]
|
||||
)
|
||||
current_idx += inc_len
|
||||
pw.dlog(
|
||||
f"Last Non-Cleared (Cached) Reset Status {last_not_cleared_reset_status} | "
|
||||
f"Current Reset Status {current_reset_status}"
|
||||
)
|
||||
if set_id == RwSetIds.TM_SET:
|
||||
pw.dlog(f"Received TM HK (ID {set_id}) from Reaction Wheel {object_id.name}")
|
||||
fmt_str = "!BiffBBiiIIIIIIIIIIIIIIII"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(
|
||||
last_reset_status,
|
||||
mcu_temp,
|
||||
pressure_sens_temp,
|
||||
pressure,
|
||||
state,
|
||||
clc_mode,
|
||||
current_speed,
|
||||
ref_speed,
|
||||
num_invalid_crc_packets,
|
||||
num_invalid_len_packets,
|
||||
num_invalid_cmd_packets,
|
||||
num_of_cmd_executed_requests,
|
||||
num_of_cmd_replies,
|
||||
uart_num_of_bytes_written,
|
||||
uart_num_of_bytes_read,
|
||||
uart_num_parity_errors,
|
||||
uart_num_noise_errors,
|
||||
uart_num_frame_errors,
|
||||
uart_num_reg_overrun_errors,
|
||||
uart_total_num_errors,
|
||||
spi_num_bytes_written,
|
||||
spi_num_bytes_read,
|
||||
spi_num_reg_overrun_errors,
|
||||
spi_total_num_errors,
|
||||
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
|
||||
|
||||
pw.dlog(
|
||||
f"MCU Temperature {mcu_temp} | Pressure Sensore Temperature {pressure_sens_temp} C"
|
||||
)
|
||||
pw.dlog(f"Last Reset Status {last_reset_status}")
|
||||
pw.dlog(
|
||||
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
|
||||
f"1: High Current Mode (0.6 A)"
|
||||
)
|
||||
pw.dlog(f"Speed {current_speed} rpm | Reference Speed {ref_speed} rpm")
|
||||
pw.dlog(
|
||||
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
|
||||
f"4: Running, speed changing"
|
||||
)
|
||||
pw.dlog(f"Number Of Invalid Packets:")
|
||||
pw.dlog("CRC | Length | CMD")
|
||||
pw.dlog(
|
||||
f"{num_invalid_crc_packets} | {num_invalid_len_packets} | {num_invalid_cmd_packets}"
|
||||
)
|
||||
pw.dlog(
|
||||
f"Num Of CMD Executed Requests {num_of_cmd_executed_requests} | "
|
||||
f"Num of CMD Replies {num_of_cmd_replies}"
|
||||
)
|
||||
pw.dlog("UART COM information:")
|
||||
pw.dlog(
|
||||
f"NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | "
|
||||
f"RegOverrunErrs | TotalErrs"
|
||||
)
|
||||
pw.dlog(
|
||||
f"{uart_num_of_bytes_written} | {uart_num_of_bytes_read} | {uart_num_parity_errors} | "
|
||||
f"{uart_num_noise_errors} | {uart_num_frame_errors} | {uart_num_reg_overrun_errors} | "
|
||||
f"{uart_total_num_errors}"
|
||||
)
|
||||
pw.dlog("SPI COM Info:")
|
||||
pw.dlog(f"NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs")
|
||||
pw.dlog(
|
||||
f"{spi_num_bytes_written} | {spi_num_bytes_read} | {spi_num_reg_overrun_errors} | "
|
||||
f"{spi_total_num_errors}"
|
||||
)
|
||||
if current_idx > 0:
|
||||
printer.print_validity_buffer(
|
||||
validity_buffer=hk_data[current_idx:], num_vars=27
|
||||
)
|
@ -6,6 +6,7 @@ from pus_tm.devs.rad_sensor import handle_rad_sensor_data
|
||||
from pus_tm.devs.sus import handle_sus_hk
|
||||
from pus_tm.system.tcs import handle_thermal_controller_hk_data
|
||||
from tmtc.ploc_supervisor import handle_supv_hk_data
|
||||
from tmtc.reaction_wheels import handle_rw_hk_data
|
||||
from tmtccmd.tm.pus_3_fsfw_hk import (
|
||||
Service3Base,
|
||||
HkContentType,
|
||||
@ -26,7 +27,6 @@ from pus_tm.devs.imtq_mgt import (
|
||||
from tmtc.power.tm import handle_pdu_data, handle_p60_hk_data, handle_acu_hk_data
|
||||
from pus_tm.devs.syrlinks import handle_syrlinks_hk_data
|
||||
from pus_tc.devs.imtq import ImtqSetIds
|
||||
from pus_tm.devs.reaction_wheels import handle_rw_hk_data
|
||||
from pus_tm.defs import FsfwTmTcPrinter
|
||||
from pus_tm.system.core import handle_core_hk_data
|
||||
from pus_tm.devs.mgms import handle_mgm_hk_data
|
||||
|
@ -5,7 +5,9 @@
|
||||
@date 20.06.2021
|
||||
"""
|
||||
import struct
|
||||
from typing import List
|
||||
|
||||
from pus_tm.defs import PrintWrapper
|
||||
from tmtccmd.config import TmtcDefinitionWrapper, OpCodeEntry
|
||||
from tmtccmd.config.tmtc import tmtc_definitions_provider
|
||||
from tmtccmd.tc import DefaultPusQueueHelper
|
||||
@ -17,6 +19,8 @@ from tmtccmd.tc.pus_3_fsfw_hk import (
|
||||
from spacepackets.ecss.tc import PusTelecommand
|
||||
from tmtccmd.tc.pus_200_fsfw_modes import pack_mode_data, Modes, Subservices
|
||||
from config.definitions import CustomServiceList
|
||||
from tmtccmd.util import ObjectIdU32
|
||||
from tmtccmd.util.tmtc_printer import FsfwTmTcPrinter
|
||||
|
||||
|
||||
class OpCodesDevs:
|
||||
@ -217,3 +221,140 @@ def pack_set_speed_command(
|
||||
command = command + ramp_time_ms.to_bytes(length=2, byteorder="big")
|
||||
command = PusTelecommand(service=8, subservice=128, app_data=command)
|
||||
return command
|
||||
|
||||
|
||||
def handle_rw_hk_data(
|
||||
printer: FsfwTmTcPrinter, object_id: ObjectIdU32, set_id: int, hk_data: bytes
|
||||
):
|
||||
|
||||
pw = PrintWrapper(printer)
|
||||
current_idx = 0
|
||||
if set_id == RwSetIds.STATUS_SET_ID:
|
||||
pw.dlog(
|
||||
f"Received Status HK (ID {set_id}) from Reaction Wheel {object_id.name}"
|
||||
)
|
||||
fmt_str = "!IiiBB"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(temp, speed, ref_speed, state, clc_mode) = struct.unpack(
|
||||
fmt_str, hk_data[current_idx : current_idx + inc_len]
|
||||
)
|
||||
current_idx += inc_len
|
||||
speed_rpm = speed / 10.0
|
||||
ref_speed_rpm = ref_speed / 10.0
|
||||
pw.dlog(
|
||||
f"Temperature {temp} C | Speed {speed_rpm} rpm | Reference Speed {ref_speed_rpm} rpm"
|
||||
)
|
||||
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:
|
||||
pw.dlog(
|
||||
f"Received Last Reset HK (ID {set_id}) from Reaction Wheel {object_id.name}"
|
||||
)
|
||||
fmt_str = "!BB"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(last_not_cleared_reset_status, current_reset_status) = struct.unpack(
|
||||
fmt_str, hk_data[current_idx : current_idx + inc_len]
|
||||
)
|
||||
current_idx += inc_len
|
||||
pw.dlog(
|
||||
f"Last Non-Cleared (Cached) Reset Status {last_not_cleared_reset_status} | "
|
||||
f"Current Reset Status {current_reset_status}"
|
||||
)
|
||||
if set_id == RwSetIds.TM_SET:
|
||||
pw.dlog(f"Received TM HK (ID {set_id}) from Reaction Wheel {object_id.name}")
|
||||
fmt_str = "!BiffBBiiIIIIIIIIIIIIIIII"
|
||||
inc_len = struct.calcsize(fmt_str)
|
||||
(
|
||||
last_reset_status,
|
||||
mcu_temp,
|
||||
pressure_sens_temp,
|
||||
pressure,
|
||||
state,
|
||||
clc_mode,
|
||||
current_speed,
|
||||
ref_speed,
|
||||
num_invalid_crc_packets,
|
||||
num_invalid_len_packets,
|
||||
num_invalid_cmd_packets,
|
||||
num_of_cmd_executed_requests,
|
||||
num_of_cmd_replies,
|
||||
uart_num_of_bytes_written,
|
||||
uart_num_of_bytes_read,
|
||||
uart_num_parity_errors,
|
||||
uart_num_noise_errors,
|
||||
uart_num_frame_errors,
|
||||
uart_num_reg_overrun_errors,
|
||||
uart_total_num_errors,
|
||||
spi_num_bytes_written,
|
||||
spi_num_bytes_read,
|
||||
spi_num_reg_overrun_errors,
|
||||
spi_total_num_errors,
|
||||
) = struct.unpack(fmt_str, hk_data[current_idx : current_idx + inc_len])
|
||||
|
||||
pw.dlog(
|
||||
f"MCU Temperature {mcu_temp} | Pressure Sensore Temperature {pressure_sens_temp} C"
|
||||
)
|
||||
pw.dlog(f"Last Reset Status {last_reset_status}")
|
||||
pw.dlog(
|
||||
f"Current Limit Control mode {clc_mode}. 0: Low Current Mode (0.3 A), "
|
||||
f"1: High Current Mode (0.6 A)"
|
||||
)
|
||||
pw.dlog(f"Speed {current_speed} rpm | Reference Speed {ref_speed} rpm")
|
||||
pw.dlog(
|
||||
f"State {state}. 0: Error, 1: Idle, 2: Coasting, 3: Running, speed stable, "
|
||||
f"4: Running, speed changing"
|
||||
)
|
||||
pw.dlog(f"Number Of Invalid Packets:")
|
||||
pw.dlog("CRC | Length | CMD")
|
||||
pw.dlog(
|
||||
f"{num_invalid_crc_packets} | {num_invalid_len_packets} | {num_invalid_cmd_packets}"
|
||||
)
|
||||
pw.dlog(
|
||||
f"Num Of CMD Executed Requests {num_of_cmd_executed_requests} | "
|
||||
f"Num of CMD Replies {num_of_cmd_replies}"
|
||||
)
|
||||
pw.dlog("UART COM information:")
|
||||
pw.dlog(
|
||||
f"NumBytesWritten | NumBytesRead | ParityErrs | NoiseErrs | FrameErrs | "
|
||||
f"RegOverrunErrs | TotalErrs"
|
||||
)
|
||||
pw.dlog(
|
||||
f"{uart_num_of_bytes_written} | {uart_num_of_bytes_read} | {uart_num_parity_errors} | "
|
||||
f"{uart_num_noise_errors} | {uart_num_frame_errors} | {uart_num_reg_overrun_errors} | "
|
||||
f"{uart_total_num_errors}"
|
||||
)
|
||||
pw.dlog("SPI COM Info:")
|
||||
pw.dlog(f"NumBytesWritten | NumBytesRead | RegOverrunErrs | TotalErrs")
|
||||
pw.dlog(
|
||||
f"{spi_num_bytes_written} | {spi_num_bytes_read} | {spi_num_reg_overrun_errors} | "
|
||||
f"{spi_total_num_errors}"
|
||||
)
|
||||
if current_idx > 0:
|
||||
printer.print_validity_buffer(
|
||||
validity_buffer=hk_data[current_idx:], num_vars=27
|
||||
)
|
||||
|
||||
|
||||
def rw_speed_up_cmd_consec(
|
||||
q: DefaultPusQueueHelper, obids: List[bytes], speed: int, ramp_time: int
|
||||
):
|
||||
for oid in obids:
|
||||
q.add_pus_tc(
|
||||
pack_set_speed_command(object_id=oid, speed=speed, ramp_time_ms=ramp_time)
|
||||
)
|
||||
|
||||
|
||||
def rw_speed_down_cmd_consec(
|
||||
q: DefaultPusQueueHelper, obids: List[bytes], ramp_time: int
|
||||
):
|
||||
for oid in obids:
|
||||
q.add_pus_tc(
|
||||
pack_set_speed_command(object_id=oid, speed=0, ramp_time_ms=ramp_time)
|
||||
)
|
Loading…
Reference in New Issue
Block a user