Index: dialin/dg/service_record.py =================================================================== diff -u -r43e8345862c72340680c045e53b310aa291513a6 -ra3be707a0f11b8f01ff32199b60b6162238b6e64 --- dialin/dg/service_record.py (.../service_record.py) (revision 43e8345862c72340680c045e53b310aa291513a6) +++ dialin/dg/service_record.py (.../service_record.py) (revision a3be707a0f11b8f01ff32199b60b6162238b6e64) @@ -7,6 +7,7 @@ from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import (DenaliMessage, DenaliChannels) from ..utils.base import _AbstractSubSystem, DialinEnum +from ..utils.utils import Utils from logging import Logger from enum import unique @@ -27,10 +28,10 @@ SERVICE_RECORD_SPECS_BYTES = 12 SERVICE_RECORDS_SPECS_BYTE_ARRAY = 3 - DEFAULT_SERVICE_LOCATION = ServiceLocation.SERVICE_LOCATION_FACTORY.value + _DEFAULT_SERVICE_LOCATION = ServiceLocation.SERVICE_LOCATION_FACTORY.value DEFAULT_MFG_DATE = 0 - DEFAULT_SERVICE_DATE_VALUE = 0 - DEFAULT_SERVICE_CRC_VALUE = 0 + _DEFAULT_DATE_VALUE = 0 + _DEFAULT_CRC_VALUE = 0 DEFAULT_SYS_PADDING_VALUE = 0 CURRENT_MESSAGE_NUM_INDEX = 0 @@ -44,15 +45,13 @@ TARGET_BYTES_TO_SEND_TO_FW = 150 MIN_PAYLOAD_BYTES_SPACE = 4 - RTC_RAM_MAX_BYTES_TO_WRITE = 64 + _RTC_RAM_MAX_BYTES_TO_WRITE = 64 + _PAYLOAD_TRANSFER_DELAY = 0.2 PAYLOAD_CURRENT_MSG_INDEX = 0 PAYLOAD_TOTAL_MSG_INDEX = 1 PAYLOAD_SERVICE_BYTES_INDEX = 2 - # DG system main record as an ordered dictionary - DG_SERVICE_RECORD = OrderedDict() - def __init__(self, can_interface, logger: Logger): """ @@ -61,13 +60,16 @@ super().__init__() + self.utilities = Utils() self.can_interface = can_interface self.logger = logger self.current_message = 0 self.total_messages = 0 self.length = 0 self.cal_data = 0 self.raw_service_record = [] + # DG system main record as an ordered dictionary + self.dg_service_record = OrderedDict() if self.can_interface is not None: @@ -206,191 +208,43 @@ """ groups_byte_size = 0 service_records = OrderedDict({'service_record': - {'service_location': [' self.MIN_PAYLOAD_BYTES_SPACE: - current_payload_length += data_type_bytes - temp_buffer[self.PAYLOAD_TOTAL_MSG_INDEX] = struct.pack(' self.MIN_PAYLOAD_BYTES_SPACE: - current_payload_length += data_type_bytes - # Insert a 4-byte 0 to the index of the total messages. This is a place holder and it will - # be updated with the right value later. - temp_buffer[self.PAYLOAD_TOTAL_MSG_INDEX] = struct.pack(' self._MIN_PAYLOAD_BYTES_SPACE: + current_payload_length += data_type_bytes + temp_buffer[self._PAYLOAD_TOTAL_MSG_INDEX] = struct.pack(' self._MIN_PAYLOAD_BYTES_SPACE: + current_payload_length += data_type_bytes + # Insert a 4-byte 0 to the index of the total messages. This is a place holder and it will + # be updated with the right value later. + temp_buffer[self._PAYLOAD_TOTAL_MSG_INDEX] = struct.pack('