Index: NVDataMgmt.c =================================================================== diff -u -r1ba84c9eec58aca4e7b5ce35ba249e9434d74ca4 -r3961e8da11b5c561e88d9d0775917b78d0820276 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 1ba84c9eec58aca4e7b5ce35ba249e9434d74ca4) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 3961e8da11b5c561e88d9d0775917b78d0820276) @@ -267,15 +267,6 @@ U16 crc; ///< Log header CRC. } LOG_RECORD_T; -typedef struct -{ - U08 swConfigs[ NUM_OF_SW_CONFIGS ]; ///< 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(NUM_OF_SW_CONFIGS, MAX_RTC_RAM_OPS_BUFFER_BYTES) - - RECORD_BYTE_SIZE(NUM_OF_SW_CONFIGS) ]; ///< Software configurations group padding. - U16 crc; ///< Software configurations CRC. -} SW_CONFIGS_RECORD_T; - // ********** HD/DG record structures ********** #ifdef _DG_ @@ -355,6 +346,16 @@ RECORD_BYTE_SIZE(DG_HEATERS_RECORD_T) ]; ///< DG heater info group padding. U16 crc; ///< CRC for the DG heaters info structure. } DG_HEATERS_INFO_GROUP_T; + +/// DG software configurations group +typedef struct +{ + DG_SW_CONFIG_RECORD_T dgSWConfigsRecord; ///< 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(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. +} DG_SW_CONFIG_GROUP_T; #endif #ifdef _HD_ @@ -410,8 +411,6 @@ #endif #pragma pack(pop) -static SW_CONFIGS_RECORD_T swConfigsRecord; ///< Software configurations record. - // Calibration variables #ifdef _DG_ static DG_CALIBRATION_RECORD_T dgCalibrationRecord; ///< DG calibration record structure (including padding and final CRC). @@ -420,14 +419,16 @@ static DG_SCHEDULED_RUNS_GROUP_T dgScheduledRunsGroup; ///< DG scheduled run structure (including padding and final CRC). static DG_USAGE_INFO_GROUP_T dgUsageInfoGroup; ///< DG usage info structure (including padding and final CRC). static DG_HEATERS_INFO_GROUP_T dgHeatersInfoGroup; ///< DG heaters info structure (including padding and final CRC). +static DG_SW_CONFIG_GROUP_T dgSWConfigGroup; ///< DG 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(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&(dgCalibrationRecord.crc), NVDATAMGMT_EEPROM}, // NVDATAMGMT_CALIBRATION_RECORD + {CAL_RECORD_NV_MEM_START_ADDRESS, sizeof(DG_CALIBRATION_RECORD_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_CALIBRATION_RECORD_T), (U08*)&dgCalibrationRecord, (U08*)&dgCalibrationRecord.crc, NVDATAMGMT_EEPROM}, // NVDATAMGMT_CALIBRATION_RECORD {SYSTEM_RECORD_NV_MEM_START_ADDRESS, sizeof(DG_SYSTEM_GROUP_T), MAX_EEPROM_WRITE_BUFFER_BYTES, sizeof(DG_SYSTEM_GROUP_T), (U08*)&dgSystemGroup, (U08*)&dgSystemGroup.crc, NVDATAMGMT_EEPROM}, // NVDATAMGMT_SYSTEM_RECORD {SERVICE_RECORD_START_ADDRESS, sizeof(DG_SERVICE_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgServiceGroup, (U08*)&dgServiceGroup.crc, NVDATAMGMT_RTC}, // NVDATAMGMT_SERVICE_RECORD + {SW_CONFIGS_START_ADDRESS, sizeof(DG_SW_CONFIG_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgSWConfigGroup, (U08*)&dgSWConfigGroup.crc, NVDATAMGMT_RTC}, // NVDATAMGMT_SW_CONFIG_RECORD {DG_SCHEDULED_RUNS_START_ADDRESS, sizeof(DG_SCHEDULED_RUNS_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgScheduledRunsGroup, (U08*)&dgScheduledRunsGroup.crc, NVDATAMGMT_RTC}, // NVDATAMGMT_SCHEDULER_RECORD - {DG_HEATERS_INFO_START_ADDRESS, sizeof(DG_HEATERS_INFO_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgHeatersInfoGroup, (U08*)&dgHeatersInfoGroup.crc, NVDATAMGMT_RTC}, // NVDATAMGMT_HEATERS_INFO_RECORD - {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 + {DG_HEATERS_INFO_START_ADDRESS, sizeof(DG_HEATERS_INFO_GROUP_T), MAX_RTC_RAM_OPS_BUFFER_BYTES, MAX_RTC_RAM_OPS_BUFFER_BYTES, (U08*)&dgHeatersInfoGroup, (U08*)&dgHeatersInfoGroup.crc, NVDATAMGMT_RTC} // NVDATAMGMT_HEATERS_INFO_RECORD }; #endif @@ -1559,8 +1560,10 @@ // If the build is a release, the configuration not matter what its value is kept in // the NV RAM, it returns a 0 which is the configuration is disabled #ifndef _RELEASE_ - value = swConfigsRecord.swConfigs[ config ]; +#ifdef _DG_ + value = dgSWConfigGroup.dgSWConfigsRecord.swConfigs[ config ]; #endif +#endif return value; } @@ -2138,7 +2141,17 @@ memcpy( &dgHeatersInfoGroup, bufferAddress, sizeof( DG_HEATERS_INFO_GROUP_T ) ); } - state = NVDATAMGMT_SELF_TEST_STATE_READ_SW_CONFIG_RECORD; + 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; + } } return state; @@ -2279,6 +2292,11 @@ enqueueSector0Records(); } + if ( FALSE == hasSWConfigRecordPassed ) + { + enqueueRecordJob( NVDATAMGMT_WRITE, NVDATAMGMT_RTC, NVDATAMGMT_SW_CONFIG_RECORD ); + } + // Check if the records' entire CRCs as well as the individual CRCs passed if ( ( TRUE == haveCalGroupsPassed ) && ( TRUE == haveRecordsPassed ) && ( TRUE == hasSystemRecordPassed ) && ( TRUE == hasServiceRecordPassed ) ) @@ -2855,6 +2873,11 @@ // There are no scheduled runs for HD right now. break; #endif + case NVDATAMGMT_SW_CONFIG_RECORD: +#ifdef _DG_ + sendDGSWConfigRecord( calPublishMessageCount + 1, calPublishTotalMessages, length, startPtr ); +#endif + break; default: //Ignore @@ -3307,42 +3330,7 @@ return status; } -/*********************************************************************//** - * @brief - * The isSWConfigRecordValid function checks the validity of the software - * configuration record. - * @details Inputs: dgSystemGroup.dgSystemRecord - * @details Outputs: none - * @return TRUE if the DG system record is valid otherwise FALSE - *************************************************************************/ -static BOOL isSWConfigRecordValid( void ) -{ - BOOL status = TRUE; - U16 calcCRC = crc16( (U08*)&swConfigsRecord, sizeof(SW_CONFIGS_RECORD_T) - sizeof(U16) ); - U16 recordCRC = swConfigsRecord.crc; - - if ( calcCRC != recordCRC ) - { - memset( swConfigsRecord.swConfigs, 0, sizeof( swConfigsRecord.swConfigs ) ); - - // Recalculate the CRC with the default values - swConfigsRecord.crc = crc16 ( (U08*)&swConfigsRecord.swConfigs, sizeof(SW_CONFIGS_RECORD_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; - } - - return status; -} - -#ifdef _DG_ /*********************************************************************//** * @brief * The isDGSystemRecordValid function checks the validity of the DG system @@ -3599,6 +3587,41 @@ /*********************************************************************//** * @brief + * The isSWConfigRecordValid function checks the validity of the software + * configuration record. + * @details Inputs: dgSystemGroup.dgSystemRecord + * @details Outputs: none + * @return TRUE if the DG system record is valid otherwise FALSE + *************************************************************************/ +static BOOL isSWConfigRecordValid( void ) +{ + BOOL status = TRUE; + U16 calcCRC = crc16( (U08*)&dgSWConfigGroup, sizeof( DG_SW_CONFIG_GROUP_T ) - sizeof(U16) ); + U16 recordCRC = dgSWConfigGroup.crc; + + if ( calcCRC != recordCRC ) + { + memset( (U08*)&dgSWConfigGroup, 0, sizeof( DG_SW_CONFIG_GROUP_T ) ); + + // 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; + } + + return status; +} + +/*********************************************************************//** + * @brief * The isDGConcPumpRecordValid function checks whether the calibration * record of concentrate pump is valid or not. * @details Inputs: none Index: NVDataMgmtDGRecords.h =================================================================== diff -u -r1ba84c9eec58aca4e7b5ce35ba249e9434d74ca4 -r3961e8da11b5c561e88d9d0775917b78d0820276 --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 1ba84c9eec58aca4e7b5ce35ba249e9434d74ca4) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 3961e8da11b5c561e88d9d0775917b78d0820276) @@ -443,6 +443,12 @@ F32 averageFillFlow; ///< Average fill flow rate. } DG_HEATERS_RECORD_T; +/// DG software configurations +typedef struct +{ + U08 swConfigs[ NUM_OF_SW_CONFIGS ]; +} DG_SW_CONFIG_RECORD_T; + #pragma pack(pop) /**@}*/