Index: dialin/dg/calibration_record.py =================================================================== diff -u -r6895b99c133b8d5820df5610c3b12ac55a521998 -r20659ffd56482b0596253aa0f1f1a7eda1221945 --- dialin/dg/calibration_record.py (.../calibration_record.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) +++ dialin/dg/calibration_record.py (.../calibration_record.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) @@ -47,7 +47,6 @@ self.logger = logger self.current_message = 0 self.total_messages = 0 - self.received_msg_length = 0 self._is_getting_cal_in_progress = False self.cal_data = 0 self._raw_cal_record = [] @@ -108,26 +107,25 @@ self.current_message = curr self.total_messages = total - self.received_msg_length = length # The end of calibration_record record payload is from the start index + 12 bytes for the current message +total # messages + the length of calibration_record. The rest is the CAN messaging CRC that is not needed # to be kept - end_of_data_index = self._RECORD_START_INDEX + self._RECORD_SPECS_BYTES + self.received_msg_length + end_of_data_index = self._RECORD_START_INDEX + self._RECORD_SPECS_BYTES + length # Get the calibration_record data only self.cal_data = message['message'][self._RECORD_START_INDEX:end_of_data_index] # Continue getting calibration_record records until the all the calibration_record messages are received. # Concatenate the calibration_record records to each other. - if self.current_message < self.total_messages: + if self.current_message <= self.total_messages: self._raw_cal_record += (message['message'][self._RECORD_START_INDEX + self._RECORD_SPECS_BYTES:end_of_data_index]) - elif self.current_message == self.total_messages: - # Done with getting all the calibration data. - self._is_getting_cal_in_progress = False - # If all the messages have been received, call another function to process the raw data - self._utilities.process_received_record_from_fw(self.dg_calibration_record, self._raw_cal_record) - self._handler_received_complete_dg_calibration_record() + if self.current_message == self.total_messages: + # Done with getting all the calibration data. + self._is_getting_cal_in_progress = False + # If all the messages have been received, call another function to process the raw data + self._utilities.process_received_record_from_fw(self.dg_calibration_record, self._raw_cal_record) + self._handler_received_complete_dg_calibration_record() @_publish(["dg_calibration_record"]) def _handler_received_complete_dg_calibration_record(self): Index: dialin/hd/buttons.py =================================================================== diff -u -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 -r20659ffd56482b0596253aa0f1f1a7eda1221945 --- dialin/hd/buttons.py (.../buttons.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) +++ dialin/hd/buttons.py (.../buttons.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) @@ -17,7 +17,7 @@ DenaliCanMessenger, DenaliChannels) from ..utils.conversions import integer_to_bytearray -from ..common.msg_defs import MsgIds +from ..common.msg_defs import MsgIds, MsgFieldPositions from .constants import RESET, NO_RESET from ..utils.base import _AbstractSubSystem, _publish from logging import Logger @@ -83,7 +83,7 @@ return mode = struct.unpack('h', bytearray( - message['message'][self.START_POS_POWEROFF:self.END_POS_POWEROFF_STATUS])) + message["message"][MsgFieldPositions.START_POS_FIELD_1: MsgFieldPositions.START_POS_FIELD_1 + 2])) if len(mode) > 0: self.poweroff_timeout_expired = bool(mode[0]) Index: dialin/protocols/CAN.py =================================================================== diff -u -r6895b99c133b8d5820df5610c3b12ac55a521998 -r20659ffd56482b0596253aa0f1f1a7eda1221945 --- dialin/protocols/CAN.py (.../CAN.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) +++ dialin/protocols/CAN.py (.../CAN.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) @@ -520,7 +520,7 @@ else: # no new packets in receive buffer # We have received nothing, let's sleep 1 msec and let's check again - sleep(0.00025) + sleep(0.001) def handle_messages(self): """ @@ -531,7 +531,7 @@ while True: if not self.message_queue: - sleep(0.00025) + sleep(0.001) else: message: dict = self.message_queue.popleft() Index: tests/set_RTCs.py =================================================================== diff -u -rdd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37 -r20659ffd56482b0596253aa0f1f1a7eda1221945 --- tests/set_RTCs.py (.../set_RTCs.py) (revision dd42e4d9cfe821b0a755ccc86cc1a4a2a3dd2f37) +++ tests/set_RTCs.py (.../set_RTCs.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) @@ -18,25 +18,23 @@ sys.path.append("..") from dialin.hd.hemodialysis_device import HD from dialin.dg.dialysate_generator import DG -from time import sleep from time import time from time import localtime if __name__ == "__main__": # create an HD object called hd - hd = HD() - # create a DG object called hd - dg = DG() - sleep(2) + hd = HD(log_level="DEBUG") - current_time_stamp = time() - current_time = localtime(current_time_stamp) - print(current_time) + if hd.cmd_log_in_to_hd(): + current_time_stamp = time() + current_time = localtime(current_time_stamp) + print(current_time) - hd.rtc.cmd_set_rtc_time_and_date(current_time.tm_sec, - current_time.tm_min, - current_time.tm_hour, - current_time.tm_mday, - current_time.tm_mon, - current_time.tm_year) - #TODO - set DG clock when supported + hd.rtc.cmd_set_rtc_time_and_date(current_time.tm_sec, + current_time.tm_min, + current_time.tm_hour, + current_time.tm_mday, + current_time.tm_mon, + current_time.tm_year) + print("Successfully set HD rtc") + #TODO - set DG clock when supported Index: tests/test_calibration.py =================================================================== diff -u -r6895b99c133b8d5820df5610c3b12ac55a521998 -r20659ffd56482b0596253aa0f1f1a7eda1221945 --- tests/test_calibration.py (.../test_calibration.py) (revision 6895b99c133b8d5820df5610c3b12ac55a521998) +++ tests/test_calibration.py (.../test_calibration.py) (revision 20659ffd56482b0596253aa0f1f1a7eda1221945) @@ -205,14 +205,14 @@ if __name__ == "__main__": - # test_dg_calibration_record() + test_dg_calibration_record() # test_dg_service_record() # test_dg_system_record() # test_dg_scheduled_runs_record() # test_hd_calibration_record() # test_hd_service_record() - test_hd_system_record() + # test_hd_system_record()