Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -radae506afce35a0063c6c2baf7e8580986f3bee7 -r1d0f0c1edb80ffa492f076bd5ead0729a64e17b1 --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision adae506afce35a0063c6c2baf7e8580986f3bee7) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 1d0f0c1edb80ffa492f076bd5ead0729a64e17b1) @@ -60,6 +60,20 @@ # HD login password HD_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): """ HD object provides test/service commands for the HD sub-system. @@ -91,13 +105,19 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_op_mode_sync) + self.can_interface.register_receiving_publication_function(DenaliChannels.ui_to_hd_ch_id, + MsgIds.MSG_ID_HD_UI_VERSION_INFO_RESPONSE.value, + self._handler_ui_version_response_sync) + # create properties self.hd_operation_mode = HDOpModes.MODE_INIT.value self.hd_operation_sub_mode = 0 self.hd_logged_in = False self.hd_set_logged_in_status(False) self.hd_no_transmit_msg_list = [0,0,0,0,0,0,0,0] + self.ui_version = None + # Create command groups self.accel = HDAccelerometer(self.can_interface, self.logger) self.air_bubbles = HDAirBubbles(self.can_interface, self.logger) @@ -181,6 +201,34 @@ self.hd_operation_mode = mode[0] self.hd_operation_sub_mode = smode[0] + def _handler_ui_version_response_sync(self,message): + """ + Handler for response from HD regarding its version. + + @param message: response message from HD regarding valid treatment parameter ranges.\n + U08 Major \n + U08 Minor \n + U08 Micro \n + U16 Build \n + U32 Compatibility revision + + @return: None if not successful, the version string if unpacked successfully + """ + major = struct.unpack(' 0 for each in [major, minor, micro, build, compatibility]]): + self.ui_version = f"v{major[0]}.{minor[0]}.{micro[0]}-{build[0]}.{compatibility[0]}" + self.logger.debug(f"UI VERSION: {self.ui_version}") + def cmd_log_in_to_hd(self, resend: bool = False) -> int: """ Constructs and sends a login command via CAN bus. Login required before \n @@ -606,3 +654,18 @@ else: self.logger.debug("Timeout!!!!") return False + + def cmd_request_ui_version(self) -> None: + """ + Constructs and sends a ui set standby submode to wait for disinfect + + @return: none + """ + + message = DenaliMessage.build_message(channel_id=DenaliChannels.hd_to_ui_ch_id, + message_id=MsgIds.MSG_ID_HD_UI_VERSION_INFO_REQUEST.value) + + self.logger.debug("Sending setting standby submode to wait for disinfect to HD.") + self.can_interface.send(message, 0) + +