Index: NVDataMgmt.c =================================================================== diff -u -rd7aa99f9c6ad48eaff310ad489786733d87600cf -rb5a078a245783d10796592bd7e96ff36a5fb5a03 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision d7aa99f9c6ad48eaff310ad489786733d87600cf) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision b5a078a245783d10796592bd7e96ff36a5fb5a03) @@ -191,7 +191,9 @@ NVDATAMGMT_CALIBRATION_RECORD = 0, ///< NVDataMgmt process write calibration record. NVDATAMGMT_SYSTEM_RECORD, ///< NVDataMgmt process write system record. NVDATAMGMT_SERVICE_RECORD, ///< NVDATAMgmt process service record. +#ifdef _DG_ NVDATAMGMT_SCHEDULED_RUNS_RECORD, ///< NVDataMgmt process scheduled runs record. +#endif NUM_OF_NVDATMGMT_RECORDS_JOBS ///< Number of NVDataMgmt records jobs. } RECORD_JOBS_STATE_T; @@ -449,7 +451,9 @@ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadCalibrationRecord( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadSystemRecord( void ); static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadServiceRecord( void ); +#ifdef _DG static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadScheduledRunsRecord( void ); +#endif #ifdef _HD_ static NVDATAMGMT_SELF_TEST_STATE_T handleSelfTestReadHDTreatmentTime( void ); #endif @@ -499,7 +503,9 @@ // Record check helper functions static BOOL areRecordsValid( void ); static BOOL isPolynomialRecordValid( POLYNOMIAL_CAL_PAYLOAD_T* record ); +#ifdef _DG static void setRsrvdCalibrationRecordsToZero( void ); +#endif #ifdef _DG_ static BOOL isDGCalibrationRecordValid( void ); @@ -663,7 +669,9 @@ break; case NVDATAMGMT_SELF_TEST_STATE_READ_SCHEDULED_RUNS_RECORD: +#ifdef _DG nvDataMgmtSelfTestState = handleSelfTestReadScheduledRunsRecord(); +#endif break; case NVDATAMGMT_SELF_TEST_STATE_READ_LOG_RECORD: @@ -797,7 +805,7 @@ BOOL status = TRUE; // If the calibration message number is the first message number and receive exec state is idle, switch to idle - if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && ( nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_IDLE ) ) + if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && ( NVDATAMGMT_RECEIVE_RECORD_IDLE == nvDataMgmtExecReceiveRecordState ) ) { nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_RECEIVE; recordReceiveStartTime = getMSTimerCount(); @@ -806,7 +814,7 @@ } // Check if there is still a message left to be received - if ( ( nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_RECEIVE ) && ( currentMessage <= totalMessages ) ) + if ( ( NVDATAMGMT_RECEIVE_RECORD_RECEIVE == nvDataMgmtExecReceiveRecordState ) && ( currentMessage <= totalMessages ) ) { // Check if the current message is different from the previous message by 1 if ( RECORD_DATA_MAX_MESSAGE_DFFIRENCE == ( currentMessage - previousCalMessageNum ) ) @@ -911,7 +919,7 @@ BOOL status = TRUE; // If the calibration message number is the first message number and receive exec state is idle, switch to idle - if ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage && nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_IDLE ) + if ( ( RECORD_DATA_FIRST_RECEIVING_MSG_NUM == currentMessage ) && ( NVDATAMGMT_RECEIVE_RECORD_IDLE == nvDataMgmtExecReceiveRecordState ) ) { nvDataMgmtExecReceiveRecordState = NVDATAMGMT_RECEIVE_RECORD_RECEIVE; recordReceiveStartTime = getMSTimerCount(); @@ -920,7 +928,7 @@ } // Check if there is still a message left to be received - if ( nvDataMgmtExecReceiveRecordState == NVDATAMGMT_RECEIVE_RECORD_RECEIVE && currentMessage <= totalMessages ) + if ( ( NVDATAMGMT_RECEIVE_RECORD_RECEIVE == nvDataMgmtExecReceiveRecordState ) && ( currentMessage <= totalMessages ) ) { // Check if the current message is different from the previous message by 1 if ( RECORD_DATA_MAX_MESSAGE_DFFIRENCE == ( currentMessage - previousCalMessageNum ) ) @@ -986,7 +994,7 @@ BOOL status = FALSE; // Check if the state machine is in idle state and then set the request - if ( nvDataMgmtExecProcessRecordState == NVDATAMGMT_PROCESS_RECORD_STATE_IDLE ) + if ( NVDATAMGMT_PROCESS_RECORD_STATE_IDLE == nvDataMgmtExecProcessRecordState ) { hasPublishRecordBeenRequested = TRUE; recordToPublish = NVDATAMGMT_SERVICE_RECORD; @@ -1078,6 +1086,7 @@ return status; } +#ifdef _DG_ /*********************************************************************//** * @brief * The getScheduledRunsRecord function sets the system state machine @@ -1183,6 +1192,7 @@ return status; } +#endif /*********************************************************************//** * @brief @@ -1633,7 +1643,7 @@ hdUsageInfoGroup.hdUsageInfo.treatmentTime = hours; hdUsageInfoGroup.crc = crc16 ( (U08*)&hdUsageInfoGroup.hdUsageInfo.treatmentTime, sizeof(U32) ); - if ( !isQueueFull() ) + if ( FALSE == isQueueFull() ) { enqueue( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, HD_TREATMENT_TIME_ADDRESS, (U08*)&hdUsageInfoGroup, 0, sizeof(HD_USAGE_INFO_RECORD_T) ); @@ -1820,6 +1830,7 @@ return state; } +#ifdef _DG_ /*********************************************************************//** * @brief * The handleSelfTestReadScheduledRunsRecord reads the scheduled runs @@ -1846,6 +1857,7 @@ return state; } +#endif #ifdef _HD_ /*********************************************************************//** * @brief @@ -1961,6 +1973,10 @@ haveCalGroupsPassed = isHDCalibrationRecordValid(); #endif +#ifdef DISABLE_CAL_CHECK + haveCalGroupsPassed = TRUE; +#endif + // If any of the records did not pass, they should be filled // with benign values. After that, schedule a write to sector 0 // to re-write the records with the benign values @@ -2541,13 +2557,13 @@ #endif break; - case NVDATAMGMT_SCHEDULED_RUNS_RECORD: #ifdef _DG_ + case NVDATAMGMT_SCHEDULED_RUNS_RECORD: // Pass the information to the CAN bus sendDGScheduledRunsRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); -#endif // There are no scheduled runs for HD right now. break; +#endif default: //Ignore @@ -2989,21 +3005,24 @@ record->secondOrderCoeff = RECORD_SECOND_ORDER_COEFF; record->gain = RECORD_DEFAULT_GAIN; record->offset = RECORD_DEFAULT_OFFSET; -#ifndef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; -#else - record->calibrationTime = getRTCTimestamp(); -#endif // Recalculate the CRC with the default values record->crc = crc16 ( (U08*)record, sizeof(POLYNOMIAL_CAL_PAYLOAD_T) - sizeof(U16) ); // Set the to FALSE since the record is not valid status = FALSE; } +#ifdef IGNORE_CAL_TIMESTAMP + if ( 0 == record->calibrationTime ) + { + record->calibrationTime = getRTCTimestamp(); + } +#endif + return status; } - +#ifdef _DG_ /*********************************************************************//** * @brief * The setRsrvdCalibrationRecordsToZero function sets the calibration @@ -3017,7 +3036,6 @@ { U32 i; POLYNOMIAL_CAL_PAYLOAD_T* record; - // NOTE: the size of the reserved spaces in each calibration record do not have #define // because they are based on assumptions and they may be reduced. @@ -3053,6 +3071,7 @@ DG_PRE_RO_PURGE_VOLUME_T* preROPurge = &dgCalibrationRecord.dgCalibrationGroups.preROPurgeVolumeRecord; memset( preROPurge, 0x0, sizeof( DG_PRE_RO_PURGE_VOLUME_T ) ); } +#endif #ifdef _DG_ /*********************************************************************//** @@ -3222,7 +3241,7 @@ { // CRC did not pass so set all values to default record->stepSpeed2FlowRatio = RECORD_DEFAULT_RATIO; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3256,7 +3275,7 @@ // CRC did not pass so set all values to default record->stepSpeed2FlowRatio = RECORD_DEFAULT_RATIO; record->voltage2SpeedRatio = RECORD_DEFAULT_RATIO; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3291,7 +3310,7 @@ record->gain1Ratio = RECORD_DEFAULT_RATIO; record->gain2Ratio = RECORD_DEFAULT_RATIO; record->gain3Ratio = RECORD_DEFAULT_RATIO; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3325,7 +3344,7 @@ // CRC did not pass so set all values to default record->pressure2FlowRatio = RECORD_DEFAULT_RATIO; record->volume = RECORD_DEFAULT_CONST; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3358,7 +3377,7 @@ { // CRC did not pass so set all values to default record->volume = FLUSH_LINES_DEFAULT_VOLUME_L; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3394,7 +3413,7 @@ record->normalFillVolume = RECORD_DEFAULT_CONST; record->rsrvrUnfilledWeight = RECORD_DEFAULT_CONST; record->rsrvrVolume = RECORD_DEFAULT_CONST; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3427,7 +3446,7 @@ { // CRC did not pass so set all values to default record->volume = RECORD_DEFAULT_CONST; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3462,7 +3481,7 @@ record->startVolume = RECORD_DEFAULT_CONST; record->reserverdSpace = RECORD_DEFAULT_CONST; record->acidConcMixRatio = ACID_CONC_DEFAULT_MIXING_RATIO; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3497,7 +3516,7 @@ record->startVolume = RECORD_DEFAULT_CONST; record->reservedSpace = RECORD_DEFAULT_CONST; record->bicarbConcMixRatio = BICARB_CONC_DEFAULT_MIXING_RATIO; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3535,7 +3554,7 @@ record->reservedSpace1 = RECORD_DEFAULT_CONST; record->reservedSpace2 = RECORD_DEFAULT_CONST; record->reservedSpace3 = RECORD_DEFAULT_CONST; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3569,7 +3588,7 @@ // CRC did not pass so set all values to default record->reservedSpace1 = RECORD_DEFAULT_CONST; record->reservedSpace2 = RECORD_DEFAULT_CONST; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3604,7 +3623,7 @@ record->accelXOffset = RECORD_DEFAULT_OFFSET; record->accelYOffset = RECORD_DEFAULT_OFFSET; record->accelZOffset = RECORD_DEFAULT_OFFSET; -#ifndef IGNORE_CAL_TIMESTAMP +#ifdef IGNORE_CAL_TIMESTAMP record->calibrationTime = RECORD_DEFAULT_TIME; #else record->calibrationTime = getRTCTimestamp(); @@ -3728,6 +3747,13 @@ status = FALSE; } +#ifdef IGNORE_CAL_TIMESTAMP + if ( 0 == record->calibrationTime ) + { + record->calibrationTime = getRTCTimestamp(); + } +#endif + return status; } @@ -3757,6 +3783,13 @@ status = FALSE; } +#ifdef IGNORE_CAL_TIMESTAMP + if ( 0 == record->calibrationTime ) + { + record->calibrationTime = getRTCTimestamp(); + } +#endif + return status; } @@ -3788,6 +3821,13 @@ status = FALSE; } +#ifdef IGNORE_CAL_TIMESTAMP + if ( 0 == record->calibrationTime ) + { + record->calibrationTime = getRTCTimestamp(); + } +#endif + return status; } #endif