Index: firmware/App/Services/NVMsgQ.c =================================================================== diff -u -rf525d2be1e7038cacbe2bb34b8db3505cf26a350 -r0face6417892ea9de28d146bf88d44a9f30cf2a4 --- firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision f525d2be1e7038cacbe2bb34b8db3505cf26a350) +++ firmware/App/Services/NVMsgQ.c (.../NVMsgQ.c) (revision 0face6417892ea9de28d146bf88d44a9f30cf2a4) @@ -183,7 +183,7 @@ break; default: -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_NVDATAMGMT_EXEC_CAL_STATE, nvMExecSendRecordState ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_NVM_INVALID_EXEC_SEND_STATE, ( U32 )nvMExecSendRecordState ); nvMExecSendRecordState = NVM_SEND_RECORD_STATE_IDLE; break; } @@ -404,7 +404,7 @@ { BOOL status = FALSE; - if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_FOR_A_RECORD ) + if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_TO_WRITE_A_RECORD ) { // Service and Calibration record are stored in the same sector. if( ( job == NVDATAMGMT_SERVICE_RECORD ) || ( job == NVDATAMGMT_CALIBRATION_RECORD ) ) @@ -429,7 +429,7 @@ { BOOL status = FALSE; - if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_FOR_ALL_RECORDS ) + if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_TO_WRITE_ALL_RECORDS ) { RECORD_JOBS_STATE_T record; @@ -453,22 +453,30 @@ /*********************************************************************//** * @brief - * The enqueuePOSTReadRecords enqueues the NV records to be read during POST. + * The enqueueReadAllRecords enqueues the NV records to be read during POST. * @details Inputs: none * @details Outputs: recordsReadStatus * @return none *************************************************************************/ -void enqueuePOSTReadRecords( void ) +BOOL enqueueReadAllRecords( void ) { + BOOL status = FALSE; RECORD_JOBS_STATE_T record; - for ( record = NVDATAMGMT_SYSTEM_RECORD; record < NUM_OF_NVDATMGMT_RECORDS_JOBS; record++ ) + if ( getAvailableRecordQueueCount() >= MIN_JOBS_NEEDED_TO_READ_ALL_RECORDS ) { - enqueueRecordJob( NVDATAMGMT_READ, record ); + for ( record = NVDATAMGMT_SYSTEM_RECORD; record < NUM_OF_NVDATMGMT_RECORDS_JOBS; record++ ) + { + enqueueRecordJob( NVDATAMGMT_READ, record ); + } + + status = TRUE; } // Set the status to records were queued successfully recordsReadStatus = NVDATAMGMT_RECORDS_QUEUED; + + return status; } /*********************************************************************//** @@ -507,6 +515,59 @@ return result; } +BOOL testDDSetNVSystemRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // System record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVServiceRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Service record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVCalibrationRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Calibration record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) + { + result = receiveDDRecord ( message ); + } + + return result; +} + +BOOL testDDSetNVInstitutionalRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + result = receiveDDRecord ( message ); + return result; +} + +BOOL testDDSetNVUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + result = receiveDDRecord ( message ); + return result; +} + /*********************************************************************//** * @brief * The sendDDCalibrationRecord function sends out the DD calibration @@ -536,7 +597,6 @@ return result; } - static BOOL receiveDDRecord( MESSAGE_T *message ) { BOOL status = FALSE; @@ -549,16 +609,8 @@ MSG_ID_T msgID = (MSG_ID_T)message->hdr.msgID; RECORD_JOBS_STATE_T job = getNVMRecordJobState( msgID ); - BOOL isValidPayloadLen = ( message->hdr.payloadLen >= minPayloadLen); - - BOOL isServiceJob = ( ( job == NVDATAMGMT_SYSTEM_RECORD ) || - ( job == NVDATAMGMT_SERVICE_RECORD ) || - ( job == NVDATAMGMT_CALIBRATION_RECORD ) ); - - BOOL isServiceMode = ( DD_MODE_SERV == getCurrentOperationMode() ); - // To proceed, the payload length should be valid. And, if it is a service job, then DD mode should also be in service. - if ( ( TRUE == isValidPayloadLen ) && ( ( FALSE == isServiceJob ) || ( TRUE == isServiceMode ) ) ) + if ( message->hdr.payloadLen >= minPayloadLen ) { memcpy(¤tMessage, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); @@ -590,7 +642,7 @@ * @param *addressPtr: address to the beginning of the calibration data from Dialin * @return TRUE if the request was successfully registered *************************************************************************/ -BOOL verifyAndSaveReceivedRecord( RECORD_JOBS_STATE_T job, U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) +static BOOL verifyAndSaveReceivedRecord( RECORD_JOBS_STATE_T job, U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ) { BOOL status = TRUE; @@ -699,6 +751,7 @@ default: // Software Fault + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, ( U32 )msgID ) break; } @@ -733,6 +786,7 @@ default: // Software fault + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, ( U32 )job ) break; }