Index: NVDataMgmt.c =================================================================== diff -u -r2f7217131cfe6d5c53a7df934a6f202b00177811 -ra32bba33291b3c17704d5c1589a899ce7b13aa02 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 2f7217131cfe6d5c53a7df934a6f202b00177811) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision a32bba33291b3c17704d5c1589a899ce7b13aa02) @@ -1165,10 +1165,15 @@ break; case GET_SRR_RECORD: - nvDataStartPtr = (U08*)&dgScheduledRunsGroup; + nvDataStartPtr = (U08*)&dgScheduledRunsGroup.dgScheduledRun; nvDataLength = sizeof( dgScheduledRunsGroup.dgScheduledRun ); break; + case GET_USAGE_RECORD: + nvDataStartPtr = (U08*)&dgUsageInfoGroup.dgUsageInfo; + nvDataLength = sizeof( dgUsageInfoGroup.dgUsageInfo ); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_NV_RECORD_SELECTED, nvData ); break; @@ -1655,7 +1660,7 @@ if ( powerOffIsImminent != TRUE ) { // Check if the service record has to be updated - //updateServiceRecord(); // TODO what is this doing here? un-comment in DEN-13834 + updateServiceRecord(); // If the record processing queue is not empty, process the queues if ( ( FALSE == isRecordQueueEmpty() ) && ( TRUE == areResourcesAvailableForNextJob() ) ) @@ -2577,7 +2582,7 @@ *************************************************************************/ static void updateServiceRecord( void ) { - // If a new calibration is available and the service record has not been updated, updated the service record + // If a new calibration is available and the service record has not been updated, update the service record // Right now, the last service date is updated once a new calibration record is received by the service personnel if ( ( TRUE == isNewCalAvailable ) && ( FALSE == hasServiceRecordBeenUpdated ) ) { @@ -2593,6 +2598,18 @@ hasServiceRecordBeenUpdated = TRUE; } #endif +#ifdef _DG_ + dgServiceGroup.dgServiceRecord.lastServiceEpochDate = getRTCTimestamp(); + dgServiceGroup.dgServiceRecord.serviceLoc = 0; + dgServiceGroup.dgServiceRecord.crc = crc16( (U08*)&dgServiceGroup.dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); + dgServiceGroup.crc = crc16( (U08*)&dgServiceGroup, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); + + if ( FALSE == isQueueFull() ) + { + enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, SERVICE_RECORD_NV_MEM_START_ADDRESS, (U08*)&dgServiceGroup, 0, sizeof( DG_SERVICE_RECORD_T ) ); + hasServiceRecordBeenUpdated = TRUE; + } +#endif } } @@ -2720,22 +2737,20 @@ static BOOL isDGServiceRecordValid( void ) { BOOL status = TRUE; - U16 calcCRC = crc16( (U08*)&dgServiceGroup.dgServiceRecord, sizeof(DG_SERVICE_RECORD_T) - sizeof(U16) ); + U16 calcCRC = crc16( (U08*)&dgServiceGroup.dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); U16 recordCRC = dgServiceGroup.dgServiceRecord.crc; if ( calcCRC != recordCRC ) { // CRC did not pass so set all values to default dgServiceGroup.dgServiceRecord.lastServiceEpochDate = 0; dgServiceGroup.dgServiceRecord.serviceIntervalSeconds = RECORD_DEFAULT_SERVICE_INTERVAL_S; - // Recalculate the CRC with the default values - dgServiceGroup.dgServiceRecord.crc = crc16 ( (U08*)&dgServiceGroup.dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); + dgServiceGroup.dgServiceRecord.lastResetTimeEpoch = getRTCTimestamp(); + dgServiceGroup.dgServiceRecord.crc = crc16 ( (U08*)&dgServiceGroup.dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ) - sizeof( U16 ) ); + status = FALSE; // Service record failure is also considered as RTC RAM failure activateAlarmNoData( ALARM_ID_DG_INVALID_SERVICE_RECORD_CRC ); - - // Set the to FALSE since the record is not valid - status = FALSE; } return status; @@ -2763,9 +2778,10 @@ dgUsageInfoGroup.dgUsageInfo.roWaterGenSinceLastServiceL = 0.0; dgUsageInfoGroup.dgUsageInfo.roWaterGenTotalL = 0.0; dgUsageInfoGroup.dgUsageInfo.lastResetTimeEpoch = getRTCTimestamp(); + dgUsageInfoGroup.dgUsageInfo.crc = crc16( (U08*)&dgUsageInfoGroup, sizeof( DG_USAGE_INFO_GROUP_T ) - sizeof( U16 ) ); status = FALSE; - //activateAlarmNoData( ALARM_ID_DG_INVALID_USAGE_RECORD ); // TODO remove when dialin is implemented + //activateAlarmNoData( ALARM_ID_DG_INVALID_USAGE_RECORD_CRC ); // TODO remove when dialin is implemented } return status;