Index: dialin/dg/system_record.py =================================================================== diff -u -r5eb006b08eb1d7b641b22fff20072ab7b685cfec -r9d477b8958653efb24fc7b1f5fc55f622922d6d8 --- dialin/dg/system_record.py (.../system_record.py) (revision 5eb006b08eb1d7b641b22fff20072ab7b685cfec) +++ dialin/dg/system_record.py (.../system_record.py) (revision 9d477b8958653efb24fc7b1f5fc55f622922d6d8) @@ -40,7 +40,7 @@ _RECORD_SPECS_BYTES = 12 _DEFAULT_MFG_LOCATION = MFGLocation.MFG_LOCATION_FACTORY.value _MAX_PN_BYTES = 10 - _MAX_SN_BYTES = 15 + _MAX_SN_BYTES = 20 _DEFAULT_TIME_VALUE = 0 _DEFAULT_CRC_VALUE = 0 @@ -256,7 +256,7 @@ self.logger.debug("Timeout!!!!") return False - self.logger.debug("Finished sending DG service record.") + self.logger.debug("Finished sending DG system record.") return True def _prepare_dg_system_record(self): @@ -266,7 +266,6 @@ @return: (OrderedDict) the assembled dg system record """ result = OrderedDict() - groups_byte_size = 0 # create a list of the functions of the sub dictionaries functions = [self._prepare_system_record()] Index: dialin/hd/system_record.py =================================================================== diff -u -r3a70bfb451b74106348c064c34f19934aadd9119 -r9d477b8958653efb24fc7b1f5fc55f622922d6d8 --- dialin/hd/system_record.py (.../system_record.py) (revision 3a70bfb451b74106348c064c34f19934aadd9119) +++ dialin/hd/system_record.py (.../system_record.py) (revision 9d477b8958653efb24fc7b1f5fc55f622922d6d8) @@ -18,11 +18,12 @@ from collections import OrderedDict from enum import unique from logging import Logger +from time import sleep from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliMessage, DenaliChannels -from ..utils.base import AbstractSubSystem, publish, DialinEnum -from ..utils.nv_ops_utils import NVOpsUtils +from ..utils.base import AbstractSubSystem, DialinEnum, publish +from ..utils.nv_ops_utils import NVOpsUtils, NVUtilsObserver @unique @@ -39,7 +40,7 @@ _RECORD_SPECS_BYTES = 12 _DEFAULT_MFG_LOCATION = MFGLocation.MFG_LOCATION_FACTORY.value _MAX_PN_BYTES = 10 - _MAX_SN_BYTES = 15 + _MAX_SN_BYTES = 20 _DEFAULT_TIME_VALUE = 0 _DEFAULT_CRC_VALUE = 0 @@ -51,6 +52,8 @@ _PAYLOAD_TRANSFER_DELAY_S = 0.2 _DIALIN_RECORD_UPDATE_DELAY_S = 0.2 + _FIRMWARE_STACK_NAME = 'HD' + def __init__(self, can_interface, logger: Logger): """ @@ -64,8 +67,7 @@ self.current_message = 0 self.total_messages = 0 self.received_msg_length = 0 - self._is_getting_system_in_progress = False - self._write_fw_data_to_excel = True + self._is_getting_sys_in_progress = False self.sys_data = 0 self._raw_system_record = [] self._utilities = NVOpsUtils(logger=self.logger) @@ -99,14 +101,39 @@ """ return self.hd_system_record['system_record'] + def cmd_get_hd_system_record_report(self, report_destination: str = None): + """ + Handles getting HD system_record record from firmware and writing it to excel. + + @param report_destination: (str) the destination that the report should be written to + + @return: none + """ + # Prepare the excel report + self._utilities.prepare_excel_report(self._FIRMWARE_STACK_NAME, self._utilities.SYSTEM_RECORD_TAB_NAME, + report_destination, protect_sheet=True) + + observer = NVUtilsObserver("hd_system_record") + # Attach the observer to the list + self.attach(observer) + + # Request the HD system record and set and observer class to callback when the system record is read back + self.cmd_request_hd_system_record() + + while not observer.received: + sleep(0.1) + # Pass the HD system record to the function to write the excel + self._utilities.write_fw_record_to_excel(self.hd_system_record) + def cmd_request_hd_system_record(self) -> int: """ Handles getting HD calibration_record data from firmware. @return: 1 upon success, False otherwise """ - if self._is_getting_system_in_progress is not True: - self._is_getting_system_in_progress = True + if self._is_getting_sys_in_progress is not True: + # Receiving the system record is in progress + self._is_getting_sys_in_progress = True # Clear the list for the next call self._raw_system_record.clear() @@ -162,7 +189,7 @@ self._RECORD_SPECS_BYTES:end_of_data_index]) if self.current_message == self.total_messages: # Done with receiving the messages - self._is_getting_system_in_progress = False + self._is_getting_sys_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.hd_system_record, self._raw_system_record) self._handler_received_complete_hd_system_record() @@ -176,6 +203,28 @@ """ self.logger.debug("Received a complete hd system record.") + def cmd_set_hd_system_record_excel_to_fw(self, report_address: str): + """ + Handles setting the system data that is in an excel report to the firmware. + + @param report_address: (str) the address in which its data must be written from excel + + @return: none + """ + + # Request the DG calibration record and set and observer class to callback when the calibration record is read + # back + self.cmd_request_hd_system_record() + observer = NVUtilsObserver("hd_system_record") + # Attach the observer to the list + self.attach(observer) + while not observer.received: + sleep(0.1) + self._utilities.write_excel_record_to_fw_record(self.hd_system_record, report_address, + self._utilities.SYSTEM_RECORD_TAB_NAME) + + self.cmd_set_hd_system_record(self.hd_system_record) + def cmd_set_hd_system_record(self, hd_system_record: OrderedDict) -> bool: """ Handles updating the HD system and sends it to FW. @@ -256,10 +305,8 @@ {'system_record': {'top_level_pn': ['