Index: firmware/App/Controllers/ConcentratePumps.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rbe4507c7fef6c9d987eba9e34369402e989e962e --- firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/ConcentratePumps.c (.../ConcentratePumps.c) (revision be4507c7fef6c9d987eba9e34369402e989e962e) @@ -244,10 +244,10 @@ BOOL calStatus = FALSE; calStatus |= getNVRecord2Driver( GET_CAL_ACID_CONCENTREATES, (U08*)&acidConcentrateCalRecord, sizeof( acidConcentrateCalRecord ), - ( CAL_DATA_ACID_CONCENTRATE_1 + 1 ), ALARM_ID_DG_ACID_CONCENTRATE_INVALID_CAL_RECORD ); + NUMBER_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_ACID_CONCENTRATE_INVALID_CAL_RECORD ); calStatus |= getNVRecord2Driver( GET_CAL_BICARB_CONCENTRATES, (U08*)&bicarbConcentrateCalRecord, sizeof( bicarbConcentrateCalRecord ), - ( CAL_DATA_BICARB_CONCENTRATE_1 + 1 ), ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); + NUMBER_OF_ACID_AND_BICARB_NV_DATA_TO_CHECK, ALARM_ID_DG_BICARB_CONCENTRATE_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rbe4507c7fef6c9d987eba9e34369402e989e962e --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision be4507c7fef6c9d987eba9e34369402e989e962e) @@ -18,8 +18,9 @@ #include "ConductivitySensors.h" #include "FPGA.h" -#include "PersistentAlarm.h" +#include "NVDataMgmt.h" #include "MessageSupport.h" +#include "PersistentAlarm.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TaskPriority.h" @@ -109,7 +110,6 @@ static U32 prefixStrToSIFactor( U08 prefix ); static void processMeasurementDataPackage( U32 sensorId ); static void processCD1CD2SensorRead( U16 fpgaReadCount, U08 fpgaErrorCount ); -static BOOL processCalibrationData( void ); static F32 getCalibrationAppliedConductivityValue( U32 sensorId, F32 compensatedValue ); /*********************************************************************//** @@ -158,8 +158,8 @@ // Check if a new calibration is available if ( TRUE == isNewCalibrationRecordAvailable() ) { - // Get the new calibration data and check its validity - processCalibrationData(); + getNVRecord2Driver( GET_CAL_CONDUCTIVITY_SENSORS, (U08*)&condSensorsCalRecord, sizeof( condSensorsCalRecord ), + NUM_OF_CAL_DATA_COND_SENSORS, ALARM_ID_DG_COND_SENSORS_INVALID_CAL_RECORD ); } processCPiCPoSensorRead( CONDUCTIVITYSENSORS_CPI_SENSOR, getFPGACPi(), getFPGACPiReadCount(), getFPGACPiErrorCount(), getFPGACPiFault() ); @@ -195,7 +195,8 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_CONDUCTIVITY_SENSORS, (U08*)&condSensorsCalRecord, sizeof( condSensorsCalRecord ), + NUM_OF_CAL_DATA_COND_SENSORS, ALARM_ID_DG_COND_SENSORS_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -502,47 +503,6 @@ /*********************************************************************//** * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: condSensorsCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - U32 sensor; - - // Get the calibration record from NVDataMgmt - DG_COND_SENSORS_CAL_RECORD_T calData = getDGConducitivitySensorsCalibrationRecord(); - - for ( sensor = 0; sensor < NUM_OF_CAL_DATA_COND_SENSORS; sensor++ ) - { -#ifndef SKIP_CAL_CHECK - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.condSensors[ sensor ].calibrationTime ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_COND_SENSORS_INVALID_CAL_RECORD, (U32)sensor ); - status = FALSE; - } -#endif - - // The calibration data was valid, update the local copy - condSensorsCalRecord.condSensors[ sensor ].fourthOrderCoeff = calData.condSensors[ sensor ].fourthOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].thirdOrderCoeff = calData.condSensors[ sensor ].thirdOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].secondOrderCoeff = calData.condSensors[ sensor ].secondOrderCoeff; - condSensorsCalRecord.condSensors[ sensor ].gain = calData.condSensors[ sensor ].gain; - condSensorsCalRecord.condSensors[ sensor ].offset = calData.condSensors[ sensor ].offset; - } - - return status; -} - -/*********************************************************************//** - * @brief * The getCalibrationAppliedConductivityValue function gets the temperature * compensated conductivity value and applies calibration to it. * @details Inputs: condSensorsCalRecord Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rbe4507c7fef6c9d987eba9e34369402e989e962e --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision be4507c7fef6c9d987eba9e34369402e989e962e) @@ -100,10 +100,6 @@ /// Conversion of reservoir tau in C/min to C/ms. static const F32 RESERVOIR_TAU_C_PER_MS = RESERVOIR_TEMPERATURE_TAU_C_PER_MIN / ( SEC_PER_MIN * MS_PER_SECOND ); -// ********** private function prototypes ********** - -static BOOL processCalibrationData( void ); - /*********************************************************************//** * @brief * The initReservoirs function initializes the Reservoirs module. @@ -134,7 +130,8 @@ if ( TRUE == isNewCalibrationRecordAvailable() ) { // Get the new calibration data and check its validity - processCalibrationData(); + getNVRecord2Driver( GET_CAL_RSRVRS_VOL_RECORD, (U08*)&reservoirsCalRecord, sizeof( reservoirsCalRecord ), + NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_RESERVOIRS_INVALID_CAL_RECORD ); } // publish active reservoir, fill/drain volume targets at 1 Hz. @@ -171,7 +168,8 @@ { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - BOOL calStatus = processCalibrationData(); + BOOL calStatus = getNVRecord2Driver( GET_CAL_RSRVRS_VOL_RECORD, (U08*)&reservoirsCalRecord, sizeof( reservoirsCalRecord ), + NUM_OF_CAL_DATA_RSRVRS, ALARM_ID_DG_RESERVOIRS_INVALID_CAL_RECORD ); if ( TRUE == calStatus ) { @@ -754,47 +752,7 @@ return tareLoadCellRequest; } -/*********************************************************************//** - * @brief - * The processCalibrationData function gets the calibration data and makes - * sure it is valid by checking the calibration date. The calibration date - * should not be 0. - * @details Inputs: none - * @details Outputs: reservoirsCalRecord - * @return TRUE if the calibration record is valid, otherwise FALSE - *************************************************************************/ -static BOOL processCalibrationData( void ) -{ - BOOL status = TRUE; - U32 reservoir; - // Get the calibration record from NVDataMgmt - DG_RESERVOIR_VOLUME_RECORD_T calData = getDGReservoirsVolumeRecord(); - - for ( reservoir = 0; reservoir < NUM_OF_CAL_DATA_RSRVRS; reservoir++ ) - { -#ifndef SKIP_CAL_CHECK - // Check if the calibration data that was received from NVDataMgmt is legitimate - // The calibration date item should not be zero. If the calibration date is 0, - // then the data is not stored in the NV memory or it was corrupted. - if ( 0 == calData.reservoir[ reservoir ].calibrationTime ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DG_RESERVOIRS_INVALID_CAL_RECORD, (U32)reservoir ); - status = FALSE; - } -#endif - - // The calibration data was valid, update the local copy - reservoirsCalRecord.reservoir[ reservoir ].maxResidualFluid = calData.reservoir[ reservoir ].maxResidualFluid; - reservoirsCalRecord.reservoir[ reservoir ].normalFillVolume = calData.reservoir[ reservoir ].normalFillVolume; - reservoirsCalRecord.reservoir[ reservoir ].rsrvrUnfilledWeight = calData.reservoir[ reservoir ].rsrvrUnfilledWeight; - reservoirsCalRecord.reservoir[ reservoir ].rsrvrVolume = calData.reservoir[ reservoir ].rsrvrVolume; - } - - return status; -} - - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r025612ad77fe630889a364586de54bffe5262d56 -rbe4507c7fef6c9d987eba9e34369402e989e962e --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 025612ad77fe630889a364586de54bffe5262d56) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision be4507c7fef6c9d987eba9e34369402e989e962e) @@ -478,7 +478,12 @@ void handleDGSerialNumberRequest( void ) { MESSAGE_T msg; - DG_SYSTEM_RECORD_T system = getDGSystemRecord(); + DG_SYSTEM_RECORD_T system; + + // Get the system's record. There are no arrays of system to check and also, raise no alarm since the system record + // has been already checked in POST + getNVRecord2Driver( GET_SYS_RECORD, (U08*)&system, sizeof( DG_SYSTEM_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record @@ -509,18 +514,23 @@ void handleDGServiceScheduleRequest( MESSAGE_T *message ) { MESSAGE_T msg; - DG_SERVICE_RECORD_T payload = getDGServiceRecord(); + DG_SERVICE_RECORD_T service; + + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + U08 *payloadPtr = msg.payload; // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); // Fill message payload - memcpy( payloadPtr, &payload.lastServiceEpochDate, sizeof( U32 ) ); + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &payload.serviceIntervalSeconds, sizeof( U32 ) ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED );