HK Parsing and TC PROC Tests #76

Merged
muellerr merged 7 commits from mueller/hk-parsing into develop 2022-05-19 19:30:20 +02:00
13 changed files with 240 additions and 60 deletions

24
.run/tmtcloop.run.xml Normal file
View File

@ -0,0 +1,24 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="tmtcloop" type="PythonConfigurationType" factoryName="Python" nameIsGenerated="true">
<module name="tmtc" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/tmtcloop.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="true" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View File

@ -36,14 +36,14 @@ TMP_1075_2_HANDLER_ID = bytes([0x44, 0x42, 0x00, 0x05])
SYRLINKS_HANDLER_ID = bytes([0x44, 0x53, 0x00, 0xA3]) SYRLINKS_HANDLER_ID = bytes([0x44, 0x53, 0x00, 0xA3])
# ACS Object IDs # ACS Object IDs
MGM_0_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x06]) MGM_0_LIS3_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x06])
MGM_1_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x07]) MGM_1_RM3100_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x07])
MGM_2_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x08]) MGM_2_LIS3_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x08])
MGM_3_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x09]) MGM_3_RM3100_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x09])
GYRO_0_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10]) GYRO_0_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10])
GYRO_1_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11]) GYRO_1_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11])
GYRO_2_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12]) GYRO_2_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12])
GYRO_3_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13]) GYRO_3_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13])
GPS_HANDLER_0_ID = bytes([0x44, 0x13, 0x00, 0x45]) GPS_HANDLER_0_ID = bytes([0x44, 0x13, 0x00, 0x45])
GPS_HANDLER_1_ID = bytes([0x44, 0x13, 0x01, 0x46]) GPS_HANDLER_1_ID = bytes([0x44, 0x13, 0x01, 0x46])
RW1_ID = bytes([0x44, 0x12, 0x00, 0x47]) RW1_ID = bytes([0x44, 0x12, 0x00, 0x47])

View File

@ -948,10 +948,12 @@ def add_ploc_supv_cmds(cmd_dict: ServiceOpCodeDictT):
def add_proc_cmds(cmd_dict: ServiceOpCodeDictT): def add_proc_cmds(cmd_dict: ServiceOpCodeDictT):
from pus_tc.system.proc import OpCodes, Info from pus_tc.system.proc import OpCodes, KAI
op_code_dict = dict() op_code_dict = dict()
add_op_code_entry(op_code_dict=op_code_dict, keys=OpCodes.HEATER, info=Info.HEATER) add_op_code_entry(
op_code_dict=op_code_dict, keys=OpCodes.HEATER, info=KAI.HEATER[1]
)
add_service_op_code_entry( add_service_op_code_entry(
srv_op_code_dict=cmd_dict, srv_op_code_dict=cmd_dict,
name=CustomServiceList.PROCEDURE.value, name=CustomServiceList.PROCEDURE.value,
@ -959,7 +961,15 @@ def add_proc_cmds(cmd_dict: ServiceOpCodeDictT):
op_code_entry=op_code_dict, op_code_entry=op_code_dict,
) )
op_code_dict = dict() op_code_dict = dict()
add_op_code_entry(op_code_dict=op_code_dict, keys=OpCodes.BAT_FT, info=Info.BAT_FT) add_op_code_entry(
op_code_dict=op_code_dict, keys=OpCodes.BAT_FT, info=KAI.BAT_FT[1]
)
add_op_code_entry(
op_code_dict=op_code_dict, keys=OpCodes.PCDU_FT, info=KAI.PCDU_FT[1]
)
add_op_code_entry(
op_code_dict=op_code_dict, keys=OpCodes.CORE_FT, info=KAI.CORE_FT[1], options={}
)
add_service_op_code_entry( add_service_op_code_entry(
srv_op_code_dict=cmd_dict, srv_op_code_dict=cmd_dict,
name=CustomServiceList.PROCEDURE.value, name=CustomServiceList.PROCEDURE.value,

10
pus_tc/devs/gyros.py Normal file
View File

@ -0,0 +1,10 @@
import enum
class AdisGyroSetIds(enum.IntEnum):
CORE_HK = 0
CFG_HK = 1
class L3gGyroSetIds(enum.IntEnum):
CORE_HK = 0

9
pus_tc/devs/mgms.py Normal file
View File

@ -0,0 +1,9 @@
import enum
class MgmLis3SetIds(enum.IntEnum):
CORE_HK = 0
class MgmRm3100SetIds(enum.IntEnum):
CORE_HK = 0

View File

@ -7,55 +7,79 @@ from config.object_ids import (
PDU_1_HANDLER_ID, PDU_1_HANDLER_ID,
PDU_2_HANDLER_ID, PDU_2_HANDLER_ID,
ACU_HANDLER_ID, ACU_HANDLER_ID,
CORE_CONTROLLER_ID,
) )
import config.object_ids as oids
from pus_tc.devs.bpx_batt import BpxSetIds from pus_tc.devs.bpx_batt import BpxSetIds
from pus_tc.system.core import SetIds as CoreSetIds
from gomspace.gomspace_common import SetIds as GsSetIds from gomspace.gomspace_common import SetIds as GsSetIds
class OpCodes: class OpCodes:
HEATER = ["0", "heater"] HEATER = ["0", "heater"]
BAT_FT = ["bat-ft"] BAT_FT = ["bat-ft"]
CORE_FT = ["core-ft"]
PCDU_FT = ["pcdu-ft"] PCDU_FT = ["pcdu-ft"]
class Info: class KeyAndInfo:
HEATER = "heater procedure" HEATER = ["Heater", "heater procedure"]
BAT_FT = "battery functional test" BAT_FT = ["BPX Battery", "battery functional test"]
PCDU_FT = "pcdu functional test" PCDU_FT = ["PCDU", "PCDU functional test"]
CORE_FT = ["OBC", "OBC functional test"]
KAI = KeyAndInfo
PROC_INFO_DICT = {
KAI.BAT_FT[0]: [OpCodes.BAT_FT, KAI.BAT_FT[1], 120.0, 10.0],
KAI.PCDU_FT[0]: [OpCodes.PCDU_FT, KeyAndInfo.PCDU_FT[1], 120.0, 10.0],
KAI.CORE_FT[0]: [OpCodes.CORE_FT, KeyAndInfo.CORE_FT[1], 120.0, 10.0],
}
def generic_print(tc_queue: TcQueueT, key: str):
info = PROC_INFO_DICT[key]
tc_queue.appendleft(
(QueueCommands.PRINT, f"Executing {info[0]} Procedure (OpCodes: {info[1]})")
)
def pack_generic_hk_listening_cmds(
tc_queue: TcQueueT, proc_key: str, sid: bytes, diag: bool
):
generic_print(tc_queue=tc_queue, key=proc_key)
listen_to_hk_for_x_seconds(
diag=diag,
tc_queue=tc_queue,
device=proc_key,
sid=sid,
interval_seconds=10.0,
collection_time=120.0,
)
def pack_proc_commands(tc_queue: TcQueueT, op_code: str): def pack_proc_commands(tc_queue: TcQueueT, op_code: str):
if op_code in OpCodes.BAT_FT: if op_code in OpCodes.BAT_FT:
device = Info.BAT_FT.split()[0] key = KAI.BAT_FT[0]
tc_queue.appendleft(
(QueueCommands.PRINT, f"Executing {device} Procedure ({device})")
)
sid = make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET) sid = make_sid(BPX_HANDLER_ID, BpxSetIds.GET_HK_SET)
pack_generic_hk_listening_cmds(
listen_to_hk_for_x_seconds( tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
diag=False,
device=device,
sid=sid,
interval_seconds=10.0,
collection_time=120.0,
) )
if op_code in OpCodes.PCDU_FT: if op_code in OpCodes.PCDU_FT:
device = Info.PCDU_FT.split()[0] key = KAI.PCDU_FT[0]
tc_queue.appendleft(
(QueueCommands.PRINT, f"Executing {device} Procedure ({device})")
)
sid = make_sid(P60_DOCK_HANDLER, GsSetIds.P60_CORE) sid = make_sid(P60_DOCK_HANDLER, GsSetIds.P60_CORE)
pack_generic_hk_listening_cmds(
listen_to_hk_for_x_seconds( tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
diag=False,
device=device,
sid=sid,
interval_seconds=10.0,
collection_time=120.0,
) )
pass if op_code in OpCodes.CORE_FT:
key = KAI.CORE_FT[0]
sid = make_sid(oids.CORE_CONTROLLER_ID, CoreSetIds.HK)
pack_generic_hk_listening_cmds(
tc_queue=tc_queue, proc_key=key, sid=sid, diag=False
)
def listen_to_hk_for_x_seconds( def listen_to_hk_for_x_seconds(

View File

@ -1,8 +1,75 @@
import struct
from pus_tm.defs import PrintWrapper
from tmtccmd.utility import ObjectId from tmtccmd.utility import ObjectId
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
from pus_tc.devs.gyros import L3gGyroSetIds, AdisGyroSetIds
import config.object_ids as obj_ids
def handle_gyros_hk_data( def handle_gyros_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
pass if object_id.as_bytes in [
obj_ids.GYRO_0_ADIS_HANDLER_ID,
obj_ids.GYRO_2_ADIS_HANDLER_ID,
]:
handle_adis_gyro_hk(
object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data
)
elif object_id.as_bytes in [
obj_ids.GYRO_1_L3G_HANDLER_ID,
obj_ids.GYRO_3_L3G_HANDLER_ID,
]:
handle_l3g_gyro_hk(
object_id=object_id, printer=printer, set_id=set_id, hk_data=hk_data
)
def handle_adis_gyro_hk(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
if set_id == AdisGyroSetIds.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = "!ddddddf"
inc_len = struct.calcsize(fmt_str)
(angVelocX, angVelocY, angVelocZ, accelX, accelY, accelZ, temp) = struct.unpack(
fmt_str, hk_data[0 : 0 + inc_len]
)
pw.dlog(f"Received ADIS1650X Gyro HK data from object {object_id}")
pw.dlog(
f"Angular Velocities (degrees per second): X {angVelocX} | "
f"Y {angVelocY} | Z {angVelocZ}"
)
pw.dlog(f"Acceleration (m/s^2): X {accelX} | Y {accelY} | Z {accelZ}")
pw.dlog(f"Temperature {temp} C")
if set_id == AdisGyroSetIds.CFG_HK:
pw = PrintWrapper(printer)
fmt_str = "!HBHH"
inc_len = struct.calcsize(fmt_str)
(diag_stat_reg, filter_setting, msc_ctrl_reg, dec_rate_reg) = struct.unpack(
fmt_str, hk_data[0 : 0 + inc_len]
)
pw.dlog(f"Diagnostic Status Register {diag_stat_reg:#018b}")
pw.dlog(f"Filter Settings {filter_setting:#010b}")
pw.dlog(f"Miscellaneous Control Register {msc_ctrl_reg:#018b}")
pw.dlog(f"Decimation Rate {dec_rate_reg:#06x}")
def handle_l3g_gyro_hk(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
if set_id == L3gGyroSetIds:
pw = PrintWrapper(printer)
fmt_str = "!ffff"
inc_len = struct.calcsize(fmt_str)
(angVelocX, angVelocY, angVelocZ, temp) = struct.unpack(
fmt_str, hk_data[0 : 0 + inc_len]
)
pw.dlog(f"Received L3GD20H Gyro HK data from object {object_id}")
pw.dlog(
f"Angular Velocities (degrees per second): X {angVelocX} | "
f"Y {angVelocY} | Z {angVelocZ}"
)
pw.dlog(f"Temperature {temp} C")

View File

@ -1,8 +1,46 @@
import struct
from pus_tm.defs import PrintWrapper
from pus_tc.devs.mgms import MgmRm3100SetIds, MgmLis3SetIds
from tmtccmd.utility import ObjectId from tmtccmd.utility import ObjectId
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
import config.object_ids as obj_ids
def handle_mgm_hk_data( def handle_mgm_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):
if object_id in [obj_ids.MGM_0_LIS3_HANDLER_ID, obj_ids.MGM_2_LIS3_HANDLER_ID]:
handle_mgm_lis3_hk_data(object_id, printer, set_id, hk_data)
pass pass
def handle_mgm_lis3_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
if set_id == MgmLis3SetIds.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = "!ffff"
inc_len = struct.calcsize(fmt_str)
(field_x, field_y, field_z, temp) = struct.unpack(
fmt_str, hk_data[0 : 0 + inc_len]
)
pw.dlog(f"Received MGM LIS3 from object {object_id}")
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)
pw.dlog(f"Temperature {temp} C")
def handle_mgm_rm3100_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
):
if set_id == MgmRm3100SetIds.CORE_HK:
pw = PrintWrapper(printer)
fmt_str = f"!fff"
inc_len = struct.calcsize(fmt_str)
(field_x, field_y, field_z) = struct.unpack(fmt_str, hk_data[0 : 0 + inc_len])
pw.dlog(f"Received MGM LIS3 from object {object_id}")
pw.dlog(
f"Field strengths in micro Tesla X {field_x} | Y {field_y} | Z {field_z}"
)

View File

@ -1,7 +1,7 @@
"""HK Handling for EIVE OBSW""" """HK Handling for EIVE OBSW"""
import struct import struct
from pus_tm.system.tcs import handle_thermal_controller_hk_data from pus_tm.system.tcs import handle_thermal_controller_hk_data, TM_TCP_SERVER
from tmtccmd.config.definitions import HkReplyUnpacked from tmtccmd.config.definitions import HkReplyUnpacked
from tmtccmd.tm.pus_3_fsfw_hk import ( from tmtccmd.tm.pus_3_fsfw_hk import (
Service3Base, Service3Base,
@ -24,13 +24,9 @@ from pus_tm.system.core import handle_core_hk_data
from pus_tm.devs.mgms import handle_mgm_hk_data from pus_tm.devs.mgms import handle_mgm_hk_data
import config.object_ids as obj_ids import config.object_ids as obj_ids
from pus_tm.tm_tcp_server import TmTcpServer
LOGGER = get_console_logger() LOGGER = get_console_logger()
TM_TCP_SERVER = TmTcpServer.getInstance()
def handle_hk_packet( def handle_hk_packet(
raw_tm: bytes, raw_tm: bytes,
@ -103,19 +99,19 @@ def handle_regular_hk_print(
if objb == obj_ids.P60_DOCK_HANDLER: if objb == obj_ids.P60_DOCK_HANDLER:
handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data)
if objb in [ if objb in [
obj_ids.GYRO_0_HANDLER_ID, obj_ids.GYRO_0_ADIS_HANDLER_ID,
obj_ids.GYRO_1_HANDLER_ID, obj_ids.GYRO_1_L3G_HANDLER_ID,
obj_ids.GYRO_2_HANDLER_ID, obj_ids.GYRO_2_ADIS_HANDLER_ID,
obj_ids.GYRO_3_HANDLER_ID, obj_ids.GYRO_3_L3G_HANDLER_ID,
]: ]:
handle_gyros_hk_data( handle_gyros_hk_data(
object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id
) )
if objb in [ if objb in [
obj_ids.MGM_0_HANDLER_ID, obj_ids.MGM_0_LIS3_HANDLER_ID,
obj_ids.MGM_1_HANDLER_ID, obj_ids.MGM_1_RM3100_HANDLER_ID,
obj_ids.MGM_2_HANDLER_ID, obj_ids.MGM_2_LIS3_HANDLER_ID,
obj_ids.MGM_3_HANDLER_ID, obj_ids.MGM_3_RM3100_HANDLER_ID,
]: ]:
handle_mgm_hk_data( handle_mgm_hk_data(
object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id

View File

@ -18,4 +18,4 @@ def handle_core_hk_data(printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes):
f"PL Voltage [mV] {pl_voltage}" f"PL Voltage [mV] {pl_voltage}"
) )
pw.dlog(printout) pw.dlog(printout)
printer.print_validity_buffer(validity_buffer=hk_data[inc_len:], num_vars=4) printer.print_validity_buffer(validity_buffer=hk_data[inc_len:], num_vars=3)

View File

@ -1,11 +1,14 @@
import struct import struct
from pus_tm.defs import PrintWrapper from pus_tm.defs import PrintWrapper
from pus_tm.hk_handling import TM_TCP_SERVER from pus_tm.tm_tcp_server import TmTcpServer
from tmtccmd.utility import ObjectId from tmtccmd.utility import ObjectId
from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter from tmtccmd.utility.tmtc_printer import FsfwTmTcPrinter
TM_TCP_SERVER = TmTcpServer.getInstance()
def handle_thermal_controller_hk_data( def handle_thermal_controller_hk_data(
object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes object_id: ObjectId, printer: FsfwTmTcPrinter, set_id: int, hk_data: bytes
): ):

@ -1 +1 @@
Subproject commit 443328422a03395bd51d072d3360de3397e1d88b Subproject commit 163ed8c5d5295a511bfee72f4a62864aa67e59be

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""EIVE TMTC Commander""" """EIVE TMTC Commander"""
from distutils.log import debug
import sys import sys
import traceback import traceback
@ -63,11 +62,11 @@ def main():
tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE)
get_console_logger().info("Disabling console logger for continuous operation") # get_console_logger().info("Disabling console logger for continuous operation")
get_console_logger().setLevel("ERROR") # get_console_logger().setLevel("ERROR")
tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend) tmtccmd.init_and_start_daemons(tmtc_backend=tmtc_backend)
tmtccmd.performOperation(tmtc_backend=tmtc_backend) tmtc_backend.perform_operation()
# remove cmdline args so that we can reuse code # remove cmdline args so that we can reuse code
sys.argv = sys.argv[:1] sys.argv = sys.argv[:1]
@ -81,7 +80,7 @@ def main():
tmtc_backend.set_opcode(args.op_code) tmtc_backend.set_opcode(args.op_code)
tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE) tmtc_backend.set_mode(CoreModeList.CONTINUOUS_MODE)
tmtccmd.performOperation(tmtc_backend=tmtc_backend) tmtc_backend.perform_operation()
if __name__ == "__main__": if __name__ == "__main__":