Index: dialin/hd/fans.py =================================================================== diff -u -rb956f5ac0f308216ec903078e681eea8f7b6c677 -r4180ef16e74251c6eb83501a396aaa9a0a892b6b --- dialin/hd/fans.py (.../fans.py) (revision b956f5ac0f308216ec903078e681eea8f7b6c677) +++ dialin/hd/fans.py (.../fans.py) (revision 4180ef16e74251c6eb83501a396aaa9a0a892b6b) @@ -168,7 +168,7 @@ # Send message received_message = self.can_interface.send(message) - # If there is no content... + # If there is content... if received_message is not None: self.logger.debug("RPM alarm start time offset set to: " + Index: dialin/hd/hemodialysis_device.py =================================================================== diff -u -reee8d5cd603ee99c3bc823d014aaaa2069ce524c -r4180ef16e74251c6eb83501a396aaa9a0a892b6b --- dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision eee8d5cd603ee99c3bc823d014aaaa2069ce524c) +++ dialin/hd/hemodialysis_device.py (.../hemodialysis_device.py) (revision 4180ef16e74251c6eb83501a396aaa9a0a892b6b) @@ -52,14 +52,18 @@ from ..protocols.CAN import DenaliMessage, DenaliCanMessenger, DenaliChannels from ..utils.base import AbstractSubSystem, publish, LogManager from ..utils.checks import check_broadcast_interval_override_ms -from ..utils.conversions import integer_to_bytearray, unsigned_short_to_bytearray +from ..utils.conversions import integer_to_bytearray, unsigned_short_to_bytearray, bytearray_to_integer, \ + bytearray_to_byte class HD(AbstractSubSystem): """ Hemodialysis Device (HD) Dialin object API. It provides the basic interface to communicate with the HD firmware. """ + # HD debug event max count + _HD_DEBUG_EVENT_LIST_COUNT = 10 + _HD_DEBUG_EVENT_MSG_LEN_INDEX = 5 # HD login password HD_LOGIN_PASSWORD = '123' @@ -107,6 +111,10 @@ self.can_interface.register_receiving_publication_function(channel_id, msg_id, self._handler_hd_op_mode_sync) + self.can_interface.register_receiving_publication_function(channel_id, + MsgIds.MSG_ID_HD_DEBUG_EVENT.value, + self._handler_hd_debug_event_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) @@ -116,10 +124,11 @@ 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.hd_no_transmit_msg_list = [0, 0, 0, 0, 0, 0, 0, 0] self.ui_version = None + self.hd_debug_events = [''] * self._HD_DEBUG_EVENT_LIST_COUNT + self._hd_debug_event_index = 0 - # Create command groups self.accel = HDAccelerometer(self.can_interface, self.logger) self.air_bubbles = HDAirBubbles(self.can_interface, self.logger) @@ -189,6 +198,28 @@ """ return self.ui_version + @publish(["hd_debug_events"]) + def _handler_hd_debug_event_sync(self, message): + + payload = message['message'] + message_length = payload[self._HD_DEBUG_EVENT_MSG_LEN_INDEX] + temp_message = '' + + index = MsgFieldPositions.START_POS_FIELD_1 + + for i in range(0, message_length): + # Loop through the length and get the + char, char_index = bytearray_to_byte(payload, index + i, False) + temp_message += chr(char) + + self._hd_debug_event_index = 0 if self._hd_debug_event_index == self._HD_DEBUG_EVENT_LIST_COUNT - 1 else \ + self._hd_debug_event_index + + self.hd_debug_events.insert(self._hd_debug_event_index, temp_message) + + # Print the latest received message from the debug event to the console + #print(temp_message) + @publish(["hd_logged_in"]) def hd_set_logged_in_status(self, logged_in: bool = False): """ Index: tests/dg_tests.py =================================================================== diff -u -r41ce85a8c857a07df740da0e83b28a63bc150e15 -r4180ef16e74251c6eb83501a396aaa9a0a892b6b --- tests/dg_tests.py (.../dg_tests.py) (revision 41ce85a8c857a07df740da0e83b28a63bc150e15) +++ tests/dg_tests.py (.../dg_tests.py) (revision 4180ef16e74251c6eb83501a396aaa9a0a892b6b) @@ -40,6 +40,7 @@ from dialin.dg.pressures import DGPressures from dialin.dg.conductivity_sensors import ConductivitySensorsEnum from dialin.dg.voltages import DGMonitoredVoltages +from dialin.hd.valves import HDValves from time import sleep from datetime import datetime import sys @@ -637,7 +638,8 @@ # test_dg_fans_alarms() while True: - print(get_hd_fans_info()) + # print(get_hd_fans_info()) + print(hd.hd_debug_events) sleep(1) #dg.ro_pump.cmd_ro_pump_measured_flow_rate_override(0.0, reset=1) Index: tests/hd_nvm_scripts.py =================================================================== diff -u -r41ce85a8c857a07df740da0e83b28a63bc150e15 -r4180ef16e74251c6eb83501a396aaa9a0a892b6b --- tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision 41ce85a8c857a07df740da0e83b28a63bc150e15) +++ tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision 4180ef16e74251c6eb83501a396aaa9a0a892b6b) @@ -54,10 +54,10 @@ # Use cmd_set_hd_calibration_excel_to_fw() set the changes back to firmware # This function requires an address for the excel report. Use the absolute address of your excel report like the # example below - #hd.calibration_record.cmd_set_hd_calibration_excel_to_fw('/home/fw/projects/HD_NV_Records/2022-02-21-HD-Record.xlsx') + hd.calibration_record.cmd_set_hd_calibration_excel_to_fw('/home/fw/projects/HD_NV_Records/2022-05-17-HD-Record.xlsx') # For resetting the calibration record to benign values, use the function below - hd.calibration_record.cmd_reset_hd_calibration_record() + #hd.calibration_record.cmd_reset_hd_calibration_record() if __name__ == "__main__":