From 730acf5ebe97142a8760127170e9df9f68ff83d3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 19 May 2022 13:58:43 +0200 Subject: [PATCH] added gyros hk handling --- config/object_ids.py | 16 +++++----- pus_tc/devs/gyros.py | 10 +++++++ pus_tc/devs/mgms.py | 9 ++++++ pus_tm/devs/gyros.py | 69 ++++++++++++++++++++++++++++++++++++++++++- pus_tm/hk_handling.py | 16 +++++----- 5 files changed, 103 insertions(+), 17 deletions(-) create mode 100644 pus_tc/devs/gyros.py create mode 100644 pus_tc/devs/mgms.py diff --git a/config/object_ids.py b/config/object_ids.py index b7c605c..b2b3aaf 100644 --- a/config/object_ids.py +++ b/config/object_ids.py @@ -36,14 +36,14 @@ TMP_1075_2_HANDLER_ID = bytes([0x44, 0x42, 0x00, 0x05]) SYRLINKS_HANDLER_ID = bytes([0x44, 0x53, 0x00, 0xA3]) # ACS Object IDs -MGM_0_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x06]) -MGM_1_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x07]) -MGM_2_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x08]) -MGM_3_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x09]) -GYRO_0_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10]) -GYRO_1_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11]) -GYRO_2_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12]) -GYRO_3_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13]) +MGM_0_LIS3_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x06]) +MGM_1_RM3100_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x07]) +MGM_2_LIS3_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x08]) +MGM_3_RM3100_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x09]) +GYRO_0_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x00, 0x10]) +GYRO_1_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x01, 0x11]) +GYRO_2_ADIS_HANDLER_ID = bytes([0x44, 0x12, 0x02, 0x12]) +GYRO_3_L3G_HANDLER_ID = bytes([0x44, 0x12, 0x03, 0x13]) GPS_HANDLER_0_ID = bytes([0x44, 0x13, 0x00, 0x45]) GPS_HANDLER_1_ID = bytes([0x44, 0x13, 0x01, 0x46]) RW1_ID = bytes([0x44, 0x12, 0x00, 0x47]) diff --git a/pus_tc/devs/gyros.py b/pus_tc/devs/gyros.py new file mode 100644 index 0000000..6cdc775 --- /dev/null +++ b/pus_tc/devs/gyros.py @@ -0,0 +1,10 @@ +import enum + + +class AdisGyroSetIds(enum.IntEnum): + CORE_HK = 0 + CFG_HK = 1 + + +class L3gGyroSetIds(enum.IntEnum): + CORE_HK = 0 diff --git a/pus_tc/devs/mgms.py b/pus_tc/devs/mgms.py new file mode 100644 index 0000000..9bd6199 --- /dev/null +++ b/pus_tc/devs/mgms.py @@ -0,0 +1,9 @@ +import enum + + +class MgmLis3SetIds(enum.IntEnum): + CORE_HK = 0 + + +class MgmRm3100SetIds(enum.IntEnum): + CORE_HK = 0 diff --git a/pus_tm/devs/gyros.py b/pus_tm/devs/gyros.py index 9646368..ff56abf 100644 --- a/pus_tm/devs/gyros.py +++ b/pus_tm/devs/gyros.py @@ -1,8 +1,75 @@ +import struct + +from pus_tm.defs import PrintWrapper from tmtccmd.utility import ObjectId 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( 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") diff --git a/pus_tm/hk_handling.py b/pus_tm/hk_handling.py index 4d04a5d..f0959fc 100644 --- a/pus_tm/hk_handling.py +++ b/pus_tm/hk_handling.py @@ -103,19 +103,19 @@ def handle_regular_hk_print( if objb == obj_ids.P60_DOCK_HANDLER: handle_p60_hk_data(printer=printer, set_id=set_id, hk_data=hk_data) if objb in [ - obj_ids.GYRO_0_HANDLER_ID, - obj_ids.GYRO_1_HANDLER_ID, - obj_ids.GYRO_2_HANDLER_ID, - obj_ids.GYRO_3_HANDLER_ID, + obj_ids.GYRO_0_ADIS_HANDLER_ID, + obj_ids.GYRO_1_L3G_HANDLER_ID, + obj_ids.GYRO_2_ADIS_HANDLER_ID, + obj_ids.GYRO_3_L3G_HANDLER_ID, ]: handle_gyros_hk_data( object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id ) if objb in [ - obj_ids.MGM_0_HANDLER_ID, - obj_ids.MGM_1_HANDLER_ID, - obj_ids.MGM_2_HANDLER_ID, - obj_ids.MGM_3_HANDLER_ID, + obj_ids.MGM_0_LIS3_HANDLER_ID, + obj_ids.MGM_1_RM3100_HANDLER_ID, + obj_ids.MGM_2_LIS3_HANDLER_ID, + obj_ids.MGM_3_RM3100_HANDLER_ID, ]: handle_mgm_hk_data( object_id=object_id, hk_data=hk_data, printer=printer, set_id=set_id