Index: leahi_dialin/fp/filtration_purification.py =================================================================== diff -u -rcf5e82faaf502b2828ffb6e43c2a64b71f6e31f2 -r4c6191b3a68f1167a0e443c975c51f3cb00b8000 --- leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision cf5e82faaf502b2828ffb6e43c2a64b71f6e31f2) +++ leahi_dialin/fp/filtration_purification.py (.../filtration_purification.py) (revision 4c6191b3a68f1167a0e443c975c51f3cb00b8000) @@ -29,7 +29,7 @@ from .proxies.dd_proxy import DDProxy -from ..common.msg_defs import MsgIds, MsgFieldPositions +from ..common.msg_defs import MsgIds, MsgFieldPositions, MsgFieldPositionsFWVersions from ..common.fp_defs import FPOpModes from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager @@ -50,18 +50,6 @@ # FP login password FP_LOGIN_PASSWORD = '123' - # UI version message field positions - START_POS_MAJOR = DenaliMessage.PAYLOAD_START_INDEX - END_POS_MAJOR = START_POS_MAJOR + 1 - START_POS_MINOR = END_POS_MAJOR - END_POS_MINOR = START_POS_MINOR + 1 - START_POS_MICRO = END_POS_MINOR - END_POS_MICRO = START_POS_MICRO + 1 - START_POS_BUILD = END_POS_MICRO - END_POS_BUILD = START_POS_BUILD + 2 - START_POS_COMPATIBILITY_REV = END_POS_BUILD - END_POS_COMPATIBILITY_REV = START_POS_COMPATIBILITY_REV + 4 - def __init__(self, can_interface="can0", log_level=None): """ FP object provides test/service commands for the FP sub-system. @@ -93,18 +81,23 @@ self._handler_fp_op_mode_sync) self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_FP_VERSION_REPONSE.value, + self._handler_fp_version_response_sync) + + self.can_interface.register_receiving_publication_function(channel_id, MsgIds.MSG_ID_FP_DEBUG_EVENT.value, self._handler_fp_debug_event_sync) # create properties self.fp_op_mode_timestamp = 0.0 self.fp_debug_events_timestamp = 0.0 - self.ui_version_info_response_timestamp = 0.0 + self.fp_version_response_timestamp = 0.0 self.fp_operation_mode = FPOpModes.MODE_INIT.value self.fp_operation_sub_mode = 0 self.fp_logged_in = False self.fp_set_logged_in_status(False) - self.ui_version = None + self.fp_version = None + self.fp_fpga_version = None self.fp_debug_events = [''] * self._FP_DEBUG_EVENT_LIST_COUNT self.fp_debug_event_index = 0 self.fp_last_debug_event = '' @@ -120,7 +113,6 @@ self.ro_pump = FPROPump(self.can_interface, self.logger) self.temperatures = FPTemperatureSensors(self.can_interface, self.logger) self.valves = FPValves(self.can_interface, self.logger) - self.dd_proxy = DDProxy(self.can_interface, self.logger) @publish(["fp_debug_events_timestamp","fp_debug_events"]) @@ -159,6 +151,44 @@ """ self.fp_logged_in = logged_in + @publish(["fp_version, fp_fpga_version"]) + def _handler_fp_version_response_sync(self,message, timestamp = 0.0): + """ + Handler for response from FP regarding its version. + + @param message: version response message from FP.\n + + @return: None if not successful, the version string if unpacked successfully + """ + major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): + self.fp_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" + self.logger.debug(f"FP VERSION: {self.fp_version}") + + if all([len(each) > 0 for each in [fpga_id, fpga_major, fpga_minor, fpga_lab]]): + self.fp_fpga_version = f"v{fpga_id[0]}.{fpga_major[0]}.{fpga_minor[0]}-{fpga_lab[0]}" + self.logger.debug(f"FP FPGA VERSION: {self.fp_fpga_version}") + + self.fp_version_response_timestamp = timestamp + @publish(["fp_op_mode_timestamp","fp_operation_mode", "fp_operation_sub_mode"]) def _handler_fp_op_mode_sync(self, message, timestamp = 0.0): """