diff --git a/config/obsw_config.py b/config/obsw_config.py index e1de03e49c799122a5f23ed51651fb6e88ddec91..b5d51e3adcebd694f5671bb40b873d30a23c2feb 100644 --- a/config/obsw_config.py +++ b/config/obsw_config.py @@ -23,6 +23,9 @@ Mission/Device specific information. GPS0_DEVICE_ID = bytearray([0x44, 0x10, 0x1F, 0x00]) GPS1_DEVICE_ID = bytearray([0x44, 0x20, 0x20, 0x00]) DUMMY_DEVICE_ID = bytearray([0x44, 0x00, 0xAF, 0xFE]) +THERMAL_SENSOR_DEVICE_ID = bytearray([0x44, 0x11, 0x54, 0x00]) +GYRO_DEVICE_ID = bytearray([0x44, 0x11, 0x55, 0x00]) +TEST_TASK_ID = bytearray([0x42, 0x69, 0x42, 0x69]) SD_CARD_HANDLER_ID = bytearray([0x4D, 0x00, 0x73, 0xAD]) # Commands @@ -32,7 +35,7 @@ DUMMY_COMMAND_2_PARAM_1 = bytearray([0xBA, 0xB0]) DUMMY_COMMAND_2_PARAM_2 = bytearray([0x00, 0x00, 0x00, 0x52, 0x4F, 0x42, 0x49, 0x4E]) DUMMY_COMMAND_3 = bytearray([0xBA, 0xDE, 0xAF, 0xFE]) -# SIDs +# SIDs (obsolete..) GPS0_SID = bytearray([0x00, 0x00, 0x1f, 0x00]) GPS1_SID = bytearray([0x00, 0x00, 0x2f, 0x00]) TEST_SID = bytearray([0x00, 0x00, 0x43, 0x00]) diff --git a/obsw_tmtc_client.py b/obsw_tmtc_client.py index eb88c13e5af5464114aec43dc843ea018a4b6e4b..61fe3e3c5c6fa60212a25d06b70272811a8a646c 100755 --- a/obsw_tmtc_client.py +++ b/obsw_tmtc_client.py @@ -215,8 +215,14 @@ class TmTcHandler: g.G_TMTC_PRINTER = self.tmtc_printer LOGGER.info("Performing module tests") # noinspection PyTypeChecker - suite = unittest.TestLoader().loadTestsFromModule(obsw_pus_service_test) + suite = unittest.TestLoader().loadTestsFromName("TestService17", obsw_pus_service_test) unittest.TextTestRunner(verbosity=2).run(suite) + # noinspection PyTypeChecker + suite = unittest.TestLoader().loadTestsFromName("TestService5", obsw_pus_service_test) + unittest.TextTestRunner(verbosity=2).run(suite) + # noinspection PyTypeChecker + # suite = unittest.TestLoader().loadTestsFromName("TestService2", obsw_pus_service_test) + # unittest.TextTestRunner(verbosity=2).run(suite) else: logging.error("Unknown Mode, Configuration error !") diff --git a/tc/obsw_tc_service3.py b/tc/obsw_tc_service3.py index 774ee2f4864d78ce23684b469c7e019a33c61629..2eaa501cf42187f9a245dff390071739d6ce4690 100644 --- a/tc/obsw_tc_service3.py +++ b/tc/obsw_tc_service3.py @@ -15,7 +15,7 @@ sid_test = g.TEST_SID sid_custom = g.CUSTOM_SID sid_gps = g.GPS0_SID collection_interval_hk = struct.pack('>f', 3) -collection_interval_diag = struct.pack('>f',0.8) +collection_interval_diag = struct.pack('>f', 0.8) number_of_parameters = struct.pack('>B', 5) p1 = g.TEST_ID_1 p2 = g.TEST_ID_2 diff --git a/test/obsw_module_test.py b/test/obsw_module_test.py index 38c8797555511d5f695cebd135f99415c3cf7e36..dc7b1c45c22d859f07fa79156a562f05def5f9f0 100644 --- a/test/obsw_module_test.py +++ b/test/obsw_module_test.py @@ -241,7 +241,8 @@ class TestService(unittest.TestCase): self.scan_for_respective_tc(current_tm_info) # Here, the desired event Id or RID can be specified elif current_tm_info[TmDictionaryKeys.SERVICE] == 5: - if (current_tm_info[TmDictionaryKeys.EVENT_ID] == 8200 and + # TODO: hardcoded values.. should be in config file + if (current_tm_info[TmDictionaryKeys.EVENT_ID] == 8300 and current_tm_info[TmDictionaryKeys.REPORTER_ID] == 0x51001700): self.event_counter = self.event_counter + 1 elif current_tm_info[TmDictionaryKeys.SERVICE] == 17: diff --git a/tm/obsw_tm_service_3.py b/tm/obsw_tm_service_3.py index a88e79972f43f662aeb86ee9deaba2c620250b9b..3fe2014cbde5dd611c8ca9896f41dcdc05bf49e1 100644 --- a/tm/obsw_tm_service_3.py +++ b/tm/obsw_tm_service_3.py @@ -10,6 +10,7 @@ from tmtc_core.tm.obsw_pus_tm_base import PusTelemetry from typing import Type from tmtc_core.utility.obsw_logger import get_logger import struct +import config.obsw_config as g LOGGER = get_logger() @@ -18,7 +19,9 @@ class Service3TM(PusTelemetry): def __init__(self, byte_array: bytearray): super().__init__(byte_array) # print("Length of TM data: " + str(len(self._tm_data))) - self.sid = struct.unpack('>I', self._tm_data[0:4])[0] + self.objectId = struct.unpack('!I', self._tm_data[0:4])[0] + self.objectIdRaw = self._tm_data[0:4] + self.setId = struct.unpack('!I', self._tm_data[4:8])[0] self.hkHeader = [] self.hkContent = [] self.hkDefinitionHeader = [] @@ -34,16 +37,19 @@ class Service3TM(PusTelemetry): def append_telemetry_content(self, array): super().append_telemetry_content(array) - array.append(hex(self.sid)) + array.append(hex(self.objectId)) + array.append(hex(self.setId)) array.append(int(self.paramLength)) def append_telemetry_column_headers(self, array): super().append_telemetry_column_headers(array) - array.append("SID") + array.append("Object ID") + array.append("Set ID") array.append("HK Data Size") def handle_filling_definition_arrays(self): - self.hkHeader = ["SID", "Report Status", "Collection Interval", "Number Of IDs"] + self.hkHeader = ["Object ID", "Set ID", "Report Status", + "Collection Interval", "Number Of IDs"] reporting_enabled = self._tm_data[4] collection_interval = struct.unpack('>f', self._tm_data[5:9])[0] number_of_params = self._tm_data[9] @@ -58,15 +64,20 @@ class Service3TM(PusTelemetry): status_string = "On" else: status_string = "Off" - self.hkContent = [hex(self.sid), status_string, collection_interval, number_of_params] + self.hkContent = [hex(self.objectId), self.setId, status_string, + collection_interval, number_of_params] self.hkContent.extend(parameters) def handle_filling_hk_arrays(self): - self.paramLength = len(self._tm_data) - 4 + self.paramLength = len(self._tm_data) - 8 # TODO: This can be automated by using the MIB parser pool names and pool datatypes - if self.sid == 0x1f00 or self.sid == 0x2f00: + if self.objectIdRaw == g.THERMAL_SENSOR_DEVICE_ID: + self.handle_thermal_sensor_hk_data() + elif self.objectIdRaw == g.GYRO_DEVICE_ID: + self.handle_gyro_hk_data() + elif self.objectIdRaw == g.GPS0_DEVICE_ID or self.objectId == g.GPS1_DEVICE_ID: self.handle_gps_hk_data() - elif self.sid == 0x4300 or self.sid == 0x4400: + elif self.objectIdRaw == g.TEST_TASK_ID: self.handle_test_hk_data() else: LOGGER.info("Service 3 TM: Parsing for this SID has not been implemented.") @@ -77,21 +88,21 @@ class Service3TM(PusTelemetry): self.hkHeader = ["Fix Mode", "SV in Fix", "GNSS Week", "Time of Week", "Latitude", "Longitude", "Mean Sea Altitude", "Position X", "Position Y", "Position Z", "Velocity X", "Velocity Y", "Velocity Z"] - fixMode = self._tm_data[4] - svInFix = self._tm_data[5] - gnssWeek = struct.unpack('>H', self._tm_data[6:8])[0] - timeOfWeek = struct.unpack('>I', self._tm_data[8:12])[0] + fix_mode = self._tm_data[4] + sv_in_fix = self._tm_data[5] + gnss_week = struct.unpack('>H', self._tm_data[6:8])[0] + time_of_week = struct.unpack('>I', self._tm_data[8:12])[0] latitude = struct.unpack('>I', self._tm_data[12:16])[0] longitude = struct.unpack('>I', self._tm_data[16:20])[0] msa = struct.unpack('>I', self._tm_data[20:24])[0] - positionX = struct.unpack('>d', self._tm_data[24:32])[0] - positionY = struct.unpack('>d', self._tm_data[32:40])[0] - positionZ = struct.unpack('>d', self._tm_data[40:48])[0] + position_x = struct.unpack('>d', self._tm_data[24:32])[0] + position_y = struct.unpack('>d', self._tm_data[32:40])[0] + position_z = struct.unpack('>d', self._tm_data[40:48])[0] vx = struct.unpack('>d', self._tm_data[48:56])[0] vy = struct.unpack('>d', self._tm_data[56:64])[0] vz = struct.unpack('>d', self._tm_data[64:72])[0] - self.hkContent = [fixMode, svInFix, gnssWeek, timeOfWeek, latitude, longitude, msa, positionX, positionY, - positionZ, vx, vy, vz] + self.hkContent = [fix_mode, sv_in_fix, gnss_week, time_of_week, latitude, longitude, msa, + position_x, position_y, position_z, vx, vy, vz] self.validity_buffer = self._tm_data[72:] # print(self.validityBuffer) # print(str(format(self.validityBuffer[0], '#010b'))) @@ -101,17 +112,42 @@ class Service3TM(PusTelemetry): def handle_test_hk_data(self): self.numberOfParameters = 6 self.hkHeader = ["Bool", "UINT8", "UINT16", "UINT32", "FLOAT1", "FLOAT2"] - testBool = self._tm_data[4] - testUint8 = self._tm_data[5] - testUint16 = (self._tm_data[6] << 8) | self._tm_data[7] - testUint32 = struct.unpack('>I', self._tm_data[8:12])[0] - floatVector1 = struct.unpack('>f', self._tm_data[12:16])[0] - floatVector2 = struct.unpack('>f', self._tm_data[16:20])[0] - self.hkContent = [testBool, testUint8, testUint16, testUint32, floatVector1, floatVector2] + test_bool = self._tm_data[4] + test_uint8 = self._tm_data[5] + test_uint16 = (self._tm_data[6] << 8) | self._tm_data[7] + test_uint32 = struct.unpack('>I', self._tm_data[8:12])[0] + float_vector1 = struct.unpack('>f', self._tm_data[12:16])[0] + float_vector2 = struct.unpack('>f', self._tm_data[16:20])[0] + self.hkContent = [test_bool, test_uint8, test_uint16, test_uint32, float_vector1, float_vector2] self.validity_buffer = self._tm_data[20:] # print(self.validityBuffer) # print(str(format(self.validityBuffer[0], '#010b'))) # print("Validity Buffer Length: " + str(len(self.validityBuffer))) + def handle_thermal_sensor_hk_data(self): + self.numberOfParameters = 2 + if len(self._tm_data) < 13: + LOGGER.error("Format of thermal sensor HK data might be invalid!") + return + + self.hkHeader = ["Temperature", "Error Byte"] + temperature_celcius = struct.unpack('!f', self._tm_data[8:12])[0] + error_byte = self._tm_data[12] + self.hkContent = [temperature_celcius, error_byte] + self.validity_buffer = self._tm_data[13:] + + def handle_gyro_hk_data(self): + self.numberOfParameters = 3 + if len(self._tm_data) < 21: + LOGGER.error("Format of thermal sensor HK data might be invalid!") + return + + self.hkHeader = ["AngVel X", "Ang Vel Y", "AngVel Z"] + angular_velocity_x = struct.unpack('!f', self._tm_data[8:12])[0] + angular_velocity_y = struct.unpack('!f', self._tm_data[12:16])[0] + angular_velocity_z = struct.unpack('!f', self._tm_data[16:20])[0] + self.hkContent = [angular_velocity_x, angular_velocity_y, angular_velocity_z] + self.validity_buffer = self._tm_data[20:] + Service3TM: Type[PusTelemetry] diff --git a/tmtc_core b/tmtc_core index ad05406ced84ed4df0979f2cbc28fde206ff031b..7ebc8d7467226515056dc5b4345bba0350de8062 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit ad05406ced84ed4df0979f2cbc28fde206ff031b +Subproject commit 7ebc8d7467226515056dc5b4345bba0350de8062