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/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/tm/obsw_tm_service_3.py b/tm/obsw_tm_service_3.py index a88e79972f43f662aeb86ee9deaba2c620250b9b..10b4874da18e90226e261fbdfddf443d0917f3d7 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,10 @@ 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.print_source_data() + 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 +38,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 +65,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 +89,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 +113,29 @@ 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 + 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:] + print(self.validity_buffer) + + def handle_gyro_hk_data(self): + pass + Service3TM: Type[PusTelemetry] diff --git a/tmtc_core b/tmtc_core index 66da7ab3912f96494b6011f22738d1750149cd44..fc827894676abd7fd464a15eea6d2aa510b7694b 160000 --- a/tmtc_core +++ b/tmtc_core @@ -1 +1 @@ -Subproject commit 66da7ab3912f96494b6011f22738d1750149cd44 +Subproject commit fc827894676abd7fd464a15eea6d2aa510b7694b