Index: NVDataMgmt.c =================================================================== diff -u -rf480c73cfca65442ee51d0189370f4d464f026e7 -r35a837869c3833e3c80aa7e68d5efcf46f82fdaf --- NVDataMgmt.c (.../NVDataMgmt.c) (revision f480c73cfca65442ee51d0189370f4d464f026e7) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 35a837869c3833e3c80aa7e68d5efcf46f82fdaf) @@ -528,6 +528,8 @@ static BOOL isDGAccelerometerSensorRecordValid( DG_ACCELEROMETER_SENSOR_CAL_RECORD_T* record ); #endif #ifdef _HD_ +static BOOL isHDSystemRecordValid( void ); +static BOOL isHDServiceRecordValid( void ); static BOOL isHDCalibrationRecordValid( void ); static BOOL isHDValveRecordValid( HD_VALVE_CAL_PAYLOAD_T* record ); static BOOL isHDPumpRecordValid( HD_PUMP_CAL_PAYLOAD_T* record ); @@ -1979,7 +1981,9 @@ hasServiceRecordPassed = isDGServiceRecordValid(); #endif #ifdef _HD_ - haveCalGroupsPassed = isHDCalibrationRecordValid(); + haveCalGroupsPassed = isHDCalibrationRecordValid(); + hasSystemRecordPassed = isHDSystemRecordValid(); + hasServiceRecordPassed = isHDServiceRecordValid(); #endif // If any of the records did not pass, they should be filled @@ -3104,6 +3108,8 @@ // Recalculate the CRC with the default values dgSystemGroup.dgSystemRecord.crc = crc16 ( (U08*)&dgSystemGroup.dgSystemRecord, sizeof( DG_SYSTEM_RECORD_T ) - sizeof( U16 ) ); + activateAlarmNoData( ALARM_ID_DG_INVALID_SYSTEM_RECORD ); + // Set the to FALSE since the record is not valid status = FALSE; } @@ -3133,6 +3139,8 @@ // Recalculate the CRC with the default values dgServiceGroup.dgServiceRecord.crc = crc16 ( (U08*)&dgServiceGroup.dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); + activateAlarmNoData( ALARM_ID_DG_INVALID_SERVICE_RECORD ); + // Set the to FALSE since the record is not valid status = FALSE; } @@ -3706,6 +3714,69 @@ #ifdef _HD_ /*********************************************************************//** * @brief + * The isHDSystemRecordValid function checks the validity of the HD system + * record. + * @details Inputs: hdSystemGroup.hdsystemRecord + * @details Outputs: none + * @return TRUE if the HD system record is valid otherwise FALSE + *************************************************************************/ +static BOOL isHDSystemRecordValid( void ) +{ + BOOL status = TRUE; + U16 calcCRC = crc16( (U08*)&hdSystemGroup.hdsystemRecord, sizeof( HD_SYSTEM_RECORD_T ) - sizeof( U16 ) ); + U16 recordCRC = hdSystemGroup.hdsystemRecord.crc; + + if ( calcCRC != recordCRC ) + { + // CRC did not pass so set all values to default + hdSystemGroup.hdsystemRecord.mfgDate = 0; + hdSystemGroup.hdsystemRecord.mfgLocation = 0; + memset( hdSystemGroup.hdsystemRecord.topLevelPN, RECORD_DEFAULT_CHARACTER, sizeof( hdSystemGroup.hdsystemRecord.topLevelPN ) ); + memset( hdSystemGroup.hdsystemRecord.topLevelPN, RECORD_DEFAULT_CHARACTER, sizeof( hdSystemGroup.hdsystemRecord.topLevelPN ) ); + // Recalculate the CRC with the default values + hdSystemGroup.hdsystemRecord.crc = crc16 ( (U08*)&hdSystemGroup.hdsystemRecord, sizeof( HD_SYSTEM_RECORD_T ) - sizeof( U16 ) ); + + activateAlarmNoData( ALARM_ID_HD_INVALID_SYSTEM_RECORD ); + + // Set the to FALSE since the record is not valid + status = FALSE; + } + + return status; +} + +/*********************************************************************//** + * @brief + * The isHDServiceRecordValid function checks the validity of the HD service + * record. + * @details Inputs: hdServiceGroup.hdServiceRecord + * @details Outputs: none + * @return TRUE if the HD service record is valid otherwise FALSE + *************************************************************************/ +static BOOL isHDServiceRecordValid( void ) +{ + BOOL status = TRUE; + U16 calcCRC = crc16( (U08*)&hdServiceGroup.hdServiceRecord, sizeof( HD_SERVICE_RECORD_T ) - sizeof( U16 ) ); + U16 recordCRC = hdServiceGroup.hdServiceRecord.crc; + + if ( calcCRC != recordCRC ) + { + // CRC did not pass so set all values to default + hdServiceGroup.hdServiceRecord.lastServiceEpochDate = 0; + hdServiceGroup.hdServiceRecord.serviceIntervalSeconds = RECORD_DEFAULT_SERVICE_INTERVAL_S; + // Recalculate the CRC with the default values + hdServiceGroup.hdServiceRecord.crc = crc16 ( (U08*)&hdServiceGroup.hdServiceRecord, sizeof( HD_SERVICE_RECORD_T ) - sizeof( U16 ) ); + + activateAlarmNoData( ALARM_ID_HD_INVALID_SERVICE_RECORD ); + + // Set the to FALSE since the record is not valid + status = FALSE; + } + + return status; +} +/*********************************************************************//** + * @brief * The isHDCalibrationRecordValid function checks whether HD calibration * record is valid or not. * @details Inputs: none Index: NVDataMgmtHDRecords.h =================================================================== diff -u -rf480c73cfca65442ee51d0189370f4d464f026e7 -r35a837869c3833e3c80aa7e68d5efcf46f82fdaf --- NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision f480c73cfca65442ee51d0189370f4d464f026e7) +++ NVDataMgmtHDRecords.h (.../NVDataMgmtHDRecords.h) (revision 35a837869c3833e3c80aa7e68d5efcf46f82fdaf) @@ -171,7 +171,8 @@ typedef struct { U08 serviceLoc; ///< HD service location. - U32 lastServiceDate; ///< HD last service date. + U32 lastServiceEpochDate; ///< HD last service date in epoch. + U32 serviceIntervalSeconds; ///< HD service interval in seconds. U16 crc; ///< CRC for the HD service record structure. } HD_SERVICE_RECORD_T;