Index: NVDataMgmt.c =================================================================== diff -u -r58e321f3c730e0d302ed479d6939ef9ac2a753d0 -recddb09ea45ae0cb21649e4a8764a6c2043d0302 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 58e321f3c730e0d302ed479d6939ef9ac2a753d0) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision ecddb09ea45ae0cb21649e4a8764a6c2043d0302) @@ -354,7 +354,7 @@ // Since the software configurations are one byte, Num_of was used for the length of the lists U08 padding[ RECORD_PADDING_LENGTH(DG_SW_CONFIG_RECORD_T, MAX_RTC_RAM_OPS_BUFFER_BYTES) - RECORD_BYTE_SIZE(DG_SW_CONFIG_RECORD_T) ]; ///< Software configurations group padding. - U16 crc; ///< Software configurations CRC. + U16 crc; ///< Software configurations CRC. } DG_SW_CONFIG_GROUP_T; #endif @@ -408,6 +408,17 @@ RECORD_BYTE_SIZE(HD_USAGE_INFO_RECORD_T) ]; ///< HD scheduled run group padding. U16 crc; ///< CRC for the HD usage info structure. } HD_USAGE_INFO_GROUP_T; + +/// HD software configurations group +typedef struct +{ + HD_SW_CONFIG_RECORD_T hdSWConfigsRecord; ///< Software configurations record. + // Since the software configurations are one byte, Num_of was used for the length of the lists + U08 padding[ RECORD_PADDING_LENGTH(HD_SW_CONFIG_RECORD_T, MAX_RTC_RAM_OPS_BUFFER_BYTES) - + RECORD_BYTE_SIZE(HD_SW_CONFIG_RECORD_T) ]; ///< Software configurations group padding. + U16 crc; ///< Software configurations CRC. +} HD_SW_CONFIG_GROUP_T; + #endif #pragma pack(pop) @@ -437,12 +448,13 @@ static HD_SYSTEM_GROUP_T hdSystemGroup; ///< HD system group structure (including padding and final CRC). static HD_SERVICE_GROUP_T hdServiceGroup; ///< HD service group structure (including padding and final CRC). static HD_USAGE_INFO_GROUP_T hdUsageInfoGroup; ///< HD usage info group structure (including padding and final CRC). +static HD_SW_CONFIG_GROUP_T hdSWConfigGroup; ///< HD Software configurations structure(including padding and final CRC). // Process records specifications const PROCESS_RECORD_SPECS_T RECORDS_SPECS [ NUM_OF_NVDATMGMT_RECORDS_JOBS ] = { {CAL_RECORD_NV_MEM_START_ADDRESS, sizeof(HD_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_CALIBRATION_RECORD_T), (U08*)&hdCalibrationRecord, (U08*)&hdCalibrationRecord.crc, NVDATAMGMT_EEPROM}, // NVDATAMGMT_CALIBRATION_RECORD {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(HD_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(HD_SYSTEM_GROUP_T), (U08*)&hdSystemGroup, (U08*)&hdSystemGroup.crc, NVDATAMGMT_EEPROM}, // NVDATAMGMT_SYSTEM_RECORD {SERVICE_RECORD_START_ADDRESS, sizeof(HD_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&hdServiceGroup, (U08*)&hdServiceGroup.crc, NVDATAMGMT_RTC}, // NVDATAMGMT_PROCESS_LAST_SERVICE_RECORD - // TODO unocomment{SW_CONFIGS_START_ADDRESS, sizeof(SW_CONFIGS_RECORD_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&swConfigsRecord, (U08*)&swConfigsRecord.crc, NVDATAMGMT_RTC} // NVDATAMGMT_SW_CONFIG_RECORD + {SW_CONFIGS_START_ADDRESS, sizeof(HD_SW_CONFIG_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&hdSWConfigGroup, (U08*)&hdSWConfigGroup.crc, NVDATAMGMT_RTC} // NVDATAMGMT_SW_CONFIG_RECORD }; #endif @@ -565,6 +577,7 @@ static BOOL isHDSystemRecordValid( void ); static BOOL isHDServiceRecordValid( void ); static BOOL isHDCalibrationRecordValid( void ); +static BOOL isSWConfigRecordValid( void ); static BOOL isHDValveRecordValid( HD_VALVE_CAL_PAYLOAD_T* record ); static BOOL isHDPumpRecordValid( HD_PUMP_CAL_PAYLOAD_T* record ); static BOOL isHDAccelerometerSensorValid( HD_ACCELEROMETER_SENSOR_CAL_RECORD_T* record ); @@ -2038,6 +2051,16 @@ } #endif #ifdef _HD_ + if ( RTC_RAM_STATE_READY == getRTCRAMState() ) + { + PROCESS_RECORD_SPECS_T specs = RECORDS_SPECS[ NVDATAMGMT_SW_CONFIG_RECORD ]; + U32 startAddress = specs.startAddress; + U32 maxBufferLength = specs.maxReadBufferSize; + + currentTime = getMSTimerCount(); + readFromRAM( startAddress, maxBufferLength ); + } + state = NVDATAMGMT_SELF_TEST_STATE_READ_SW_CONFIG_RECORD; #endif } @@ -2272,15 +2295,16 @@ #ifdef _DG_ // Check all the calibration groups - haveCalGroupsPassed = isDGCalibrationRecordValid(); - hasSystemRecordPassed = isDGSystemRecordValid(); - hasServiceRecordPassed = isDGServiceRecordValid(); + haveCalGroupsPassed = isDGCalibrationRecordValid(); + hasSystemRecordPassed = isDGSystemRecordValid(); + hasServiceRecordPassed = isDGServiceRecordValid(); hasSWConfigRecordPassed = isSWConfigRecordValid(); #endif #ifdef _HD_ - haveCalGroupsPassed = isHDCalibrationRecordValid(); - hasSystemRecordPassed = isHDSystemRecordValid(); - hasServiceRecordPassed = isHDServiceRecordValid(); + haveCalGroupsPassed = isHDCalibrationRecordValid(); + hasSystemRecordPassed = isHDSystemRecordValid(); + hasServiceRecordPassed = isHDServiceRecordValid(); + hasSWConfigRecordPassed = isSWConfigRecordValid(); #endif // If any of the records did not pass, they should be filled @@ -2296,6 +2320,11 @@ enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_SW_CONFIG_RECORD ); } + if ( FALSE == hasServiceRecordPassed ) + { + enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_SERVICE_RECORD ); + } + // Check if the records' entire CRCs as well as the individual CRCs passed if ( ( TRUE == haveCalGroupsPassed ) && ( TRUE == haveRecordsPassed ) && ( TRUE == hasSystemRecordPassed ) && ( TRUE == hasServiceRecordPassed ) ) @@ -2876,6 +2905,9 @@ #ifdef _DG_ sendDGSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); #endif +#ifdef _HD_ + sendHDSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +#endif break; default: @@ -3588,8 +3620,8 @@ * @brief * The isSWConfigRecordValid function checks the validity of the software * configuration record. - * @details Inputs: dgSystemGroup.dgSystemRecord - * @details Outputs: none + * @details Inputs: dgSWConfigGroup + * @details Outputs: dgSWConfigGroup * @return TRUE if the DG system record is valid otherwise FALSE *************************************************************************/ static BOOL isSWConfigRecordValid( void ) @@ -3605,12 +3637,7 @@ // Recalculate the CRC with the default values dgSWConfigGroup.crc = crc16( (U08*)&dgSWConfigGroup, sizeof( DG_SW_CONFIG_GROUP_T ) - sizeof(U16) ); -#ifdef _DG_ //activateAlarmNoData( ALARM_ID_DG_SW_CONFIG_RECORD_INVALID_CRC ); // TODO remove -#endif -#ifdef _HD_ - //activateAlarmNoData( ALARM_ID_HD_SW_CONFIG_RECORD_INVALID_CRC ); // TODO remove -#endif // Set the to FALSE since the record is not valid status = FALSE; @@ -4070,10 +4097,10 @@ hdServiceGroup.hdServiceRecord.crc = crc16 ( (U08*)&hdServiceGroup.hdServiceRecord, sizeof( HD_SERVICE_RECORD_T ) - sizeof( U16 ) ); // Service record failure is also considered as RTC RAM failure - activateAlarmNoData( ALARM_ID_HD_INVALID_SERVICE_RECORD_CRC ); + //activateAlarmNoData( ALARM_ID_HD_INVALID_SERVICE_RECORD_CRC ); // DEBUG_DENALI // Set the to FALSE since the record is not valid - status = FALSE; + //status = FALSE; } return status; @@ -4164,6 +4191,36 @@ /*********************************************************************//** * @brief + * The isSWConfigRecordValid function checks the validity of the software + * configuration record. + * @details Inputs: hdSWConfigGroup + * @details Outputs: hdSWConfigGroup + * @return TRUE if the DG system record is valid otherwise FALSE + *************************************************************************/ +static BOOL isSWConfigRecordValid( void ) +{ + BOOL status = TRUE; + U16 calcCRC = crc16( (U08*)&hdSWConfigGroup, sizeof( HD_SW_CONFIG_GROUP_T ) - sizeof(U16) ); + U16 recordCRC = hdSWConfigGroup.crc; + + if ( calcCRC != recordCRC ) + { + memset( (U08*)&hdSWConfigGroup, 0, sizeof( HD_SW_CONFIG_GROUP_T ) ); + + // Recalculate the CRC with the default values + hdSWConfigGroup.crc = crc16( (U08*)&hdSWConfigGroup, sizeof( HD_SW_CONFIG_GROUP_T ) - sizeof(U16) ); + + //activateAlarmNoData( ALARM_ID_HD_SW_CONFIG_RECORD_INVALID_CRC ); // TODO remove + + // Set the to FALSE since the record is not valid + status = FALSE; + } + + return status; +} + +/*********************************************************************//** + * @brief * The isHDPumpRecordValid function checks whether the calibration record * of HD pump(s) is valid or not. * @details Inputs: none