Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -r517909d3e696abaaa2927232f4bbafe8d7446ef5 -r2078ddd685487111457759eca96387b2008d6717 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 517909d3e696abaaa2927232f4bbafe8d7446ef5) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 2078ddd685487111457759eca96387b2008d6717) @@ -344,20 +344,10 @@ static SEND_RECORD_STATE_T nvMExecSendRecordState; ///< NVM exec process record state. static U32 newRecordStartTimer; ///< New record availability start timer. static BOOL isNewCalRecordAvailable; ///< Signal to indicate whether a new NVM data is available. -static NV_DATA_T recordToPublish; ///< Record type which is being processed currently for sending -static NV_DATA_T nvPublishRecordType; ///< Used to index over isPublishRecordRequested in the idle state static U32 recordSendDataIntervalCounter; ///< Record data send to CAN bust interval counter. -static U08 sendCalIdx; ///< Current Index of sensor calibration data to be sent -static BOOL isPublishRecordRequested[ NUM_OF_NV_DD_DATA ]; ///< Record state machine publish request flag. +static NV_DATA_T recordToPublish; ///< Record type which is being processed currently for sending +static U32 sendCalIdx; ///< Current Index of sensor calibration data to be sent -// Calibration Record Publish Flag for index of each component -static BOOL isGetPressureCalRequested[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure Sensors Get Calibration Request Flag -static BOOL isGetTempCalRequested[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature Sensors Get Calibration Request Flag -static BOOL isGetConcPumpCalRequested[ NUM_OF_CONCENTRATE_PUMPS ]; ///< Concentrate Pumps Get Calibration Request Flag -static BOOL isGetAcidConcCalRequested[ NUM_OF_ACID_TYPE ]; ///< Acid Concentrates Get Calibration Request Flag -static BOOL isGetBicarbConcCalRequested[ NUM_OF_BICARB_TYPE ]; ///< Bicarb Concentrates Get Calibration Request Flag -static BOOL isGetCondSensCalRequested[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Conductivity Sensor Get Calibration Request Flag - // ********** private function prototypes ********** // Process record functions @@ -389,27 +379,19 @@ * states and variables. It resets send and receive states, flags, * counters, and timing values. * @details \b Inputs: None - * @details \b Outputs: nvMExecSendRecordState, - * nvmExecreceiveRecordState, newRecordStartTimer, - * isNewCalRecordAvailable, nvPublishRecordType, - * isPublishRecordRequested, recordPublishMsgCount, - * recordPublishTotalMsgs, recordSendDataIntervalCounter, - * previousRecordMessageNum, recordReceiveStartTime + * @details \b Outputs: nvMExecSendRecordState, newRecordStartTimer, + * isNewCalRecordAvailable, recordSendDataIntervalCounter, + * recordToPublish, sendCalIdx * @return None *************************************************************************/ void initNVMessagingDD( void ) { - nvMExecSendRecordState = NVM_SEND_RECORD_STATE_IDLE; - newRecordStartTimer = 0; - isNewCalRecordAvailable = FALSE; - nvPublishRecordType = NV_DD_DATA_SYSTEM_RECORD; - recordSendDataIntervalCounter = 0; - - U32 i; - for ( i = 0; i < NUM_OF_NV_DD_DATA; i++ ) - { - isPublishRecordRequested[ i ] = FALSE; - } + nvMExecSendRecordState = NVM_SEND_RECORD_STATE_IDLE; + newRecordStartTimer = 0; + isNewCalRecordAvailable = FALSE; + recordSendDataIntervalCounter = 0; + recordToPublish = NUM_OF_NV_DD_DATA; + sendCalIdx = 0; } /*********************************************************************//** @@ -490,53 +472,31 @@ * The handleExecSendRecordIdleState function handles the idle state of * the exec send record state machine. It prepares record data for * publishing when requested. - * @details \b Inputs: isPublishRecordRequested, - * nvPublishRecordType - * @details \b Outputs: isPublishRecordRequested, - * recordPublishTotalMsgs, recordPublishMsgCount, - * recordSendDataIntervalCounter, nvPublishRecordType, - * recordToPublish + * @details \b Inputs: None + * @details \b Outputs: recordToPublish, sendCalIdx, recordSendDataIntervalCounter, , * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleExecSendRecordIdleState( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_IDLE; - -// if ( TRUE == isPublishRecordRequested[ nvPublishRecordType ] ) -// { -// recordToPublish = nvPublishRecordType; -// -// // Set the publish flag to FALSE -// isPublishRecordRequested[ recordToPublish ] = FALSE; -// -// // Time interval in between data to be sent. It is set to the interval count so on the first call -// // of the send calibration record function, the first packet of data is sent -// recordSendDataIntervalCounter = RECORD_DATA_SEND_INTERVAL_COUNT; -// -// state = NVM_SEND_RECORD_STATE_SEND; -// } -// -// nvPublishRecordType = ( NV_DATA_T )( nvPublishRecordType + 1 ); -// if ( nvPublishRecordType >= NUM_OF_NV_DD_DATA ) -// { -// nvPublishRecordType = NV_DD_DATA_SYSTEM_RECORD; -// } - NVM_MSG_REQUEST_Q_T currentNVMsgRequest; + // Clear the Publish Flags + recordToPublish = NUM_OF_NV_DD_DATA; + sendCalIdx = 0; + + // Check if the NV Message Queue has any unprocessed request if ( FALSE == isNVMsgRequestQueueEmpty() ) { + // Get the request dequeueNVMsgRequest(); currentNVMsgRequest = getCurrentNVMsgRequest(); + // Set the flags if the request is to publish the record if ( NVM_MSG_GET_RECORD_REQUEST == currentNVMsgRequest.requestType ) { recordToPublish = currentNVMsgRequest.recordType; - - if ( TRUE == currentNVMsgRequest.isIndexed ) - { - sendCalIdx = currentNVMsgRequest.idx; - } + sendCalIdx = currentNVMsgRequest.idx; } // Time interval in between data to be sent. It is set to the interval count so on the first call @@ -554,11 +514,8 @@ * The handleExecSendRecordSendState function handles the send state of * the exec send record state machine. It sends record data in chunks * based on timing and message count. - * @details \b Inputs: recordPublishTotalMsgs, - * recordPublishMsgCount, recordSendDataIntervalCounter, - * recordToPublish - * @details \b Outputs: recordPublishMsgCount, - * recordSendDataIntervalCounter + * @details \b Inputs: recordToPublish, recordSendDataIntervalCounter, + * @details \b Outputs: recordSendDataIntervalCounter * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleExecSendRecordSendState( void ) @@ -650,7 +607,7 @@ * It retries transmission on failure and returns to the idle state * after a successful send or when retries are exhausted. * @details \b Inputs: None - * @details \b Outputs: recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDSystemRecord( void ) @@ -675,9 +632,6 @@ ( sizeof( DD_NVM_GET_SYSTEM_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -687,10 +641,8 @@ /*********************************************************************//** * @brief * The handleSendDDServiceRecord function sends the DD service record. - * It retries transmission on failure and returns to the idle state - * after a successful send or when retries are exhausted. * @details \b Inputs: None - * @details \b Outputs: recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) @@ -715,9 +667,6 @@ ( sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -727,11 +676,9 @@ /*********************************************************************//** * @brief * The handleSendDDUsageInfoRecord function sends the DD usage - * information record. It retries transmission on failure and returns - * to the idle state after a successful send or when retries are - * exhausted. + * information record. * @details \b Inputs: None - * @details \b Outputs: recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) @@ -756,9 +703,6 @@ ( sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -768,11 +712,9 @@ /*********************************************************************//** * @brief * The handleSendDDInstitBasicRecord function sends the DD basic - * institutional record. It retries transmission on failure and returns - * to the idle state after a successful send or when retries are - * exhausted. + * institutional record. * @details \b Inputs: None - * @details \b Outputs: recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) @@ -797,9 +739,6 @@ ( sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -809,11 +748,9 @@ /*********************************************************************//** * @brief * The handleSendDDInstitAdvancedRecord function sends the DD advanced - * institutional record. It retries transmission on failure and returns - * to the idle state after a successful send or when retries are - * exhausted. + * institutional record. * @details \b Inputs: None - * @details \b Outputs: recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) @@ -838,9 +775,6 @@ ( sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -850,9 +784,7 @@ /*********************************************************************//** * @brief * The handleSendDDInstitAdditionalRecord function sends the DD additional - * institutional record. It retries transmission on failure and returns - * to the idle state after a successful send or when retries are - * exhausted. + * institutional record. * @details \b Inputs: None * @details \b Outputs: recordToPublish * @return state next state of the state machine @@ -879,9 +811,6 @@ ( sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -893,7 +822,7 @@ * The handleSendPressureSensorCalRecord function sends the calibration * record of the selected pressure sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: none * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ) @@ -921,9 +850,6 @@ ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -935,7 +861,7 @@ * The handleSendTempSensorCalRecord function sends the calibration record * of the selected temperature sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: none * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ) @@ -944,43 +870,28 @@ DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; DD_TEMP_SENSORS_CAL_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetTempCalRequested[ sendCalIdx ] ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_TEMPERATURE_SENSORS, + (U08*)&record, + sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), + NUM_OF_TEMPERATURE_SENSORS, + ALARM_ID_DD_NVM_INVALID_CAL_TEMP_SENSOR ) ) { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_TEMPERATURE_SENSORS, - (U08*)&record, - sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), - NUM_OF_TEMPERATURE_SENSORS, - ALARM_ID_DD_NVM_INVALID_CAL_TEMP_SENSOR ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.tempSensors[ sendCalIdx ]; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.tempSensors[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - sendCalIdx = sendCalIdx + 1; + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; - if ( sendCalIdx >= NUM_OF_TEMPERATURE_SENSORS ) - { - // Reset Sensor Index - sendCalIdx = 0; - - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -989,7 +900,7 @@ * The handleSendConcPumpCalRecord function sends the calibration record * of the selected concentrate pump. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: none * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ) @@ -998,43 +909,29 @@ DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; DD_CONC_PUMPS_CAL_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetConcPumpCalRequested[ sendCalIdx ] ) - { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD, - (U08*)&record, - sizeof( DD_CONC_PUMPS_CAL_RECORD_T ), - NUM_OF_CONCENTRATE_PUMPS, - ALARM_ID_DD_NVM_INVALID_CAL_CONC_PUMP ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.concentratePumps[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_CONC_PUMP_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - } - - sendCalIdx = sendCalIdx + 1; - - if ( sendCalIdx >= NUM_OF_CONCENTRATE_PUMPS ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD, + (U08*)&record, + sizeof( DD_CONC_PUMPS_CAL_RECORD_T ), + NUM_OF_CONCENTRATE_PUMPS, + ALARM_ID_DD_NVM_INVALID_CAL_CONC_PUMP ) ) { - // Reset Sensor Index - sendCalIdx = 0; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.concentratePumps[ sendCalIdx ]; - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_CONC_PUMP_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + return state; } @@ -1060,7 +957,6 @@ { payload.accepted = TRUE; payload.rejectionReason = 0; - sendCalIdx = 0; // Send the record sendMessage( MSG_ID_DD_UI_NVM_GET_D12_PUMP_CAL_RECORD_RESPONSE, @@ -1070,9 +966,6 @@ } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -1101,7 +994,6 @@ { payload.accepted = TRUE; payload.rejectionReason = 0; - sendCalIdx = 0; // Send the record sendMessage( MSG_ID_DD_UI_NVM_GET_D48_PUMP_CAL_RECORD_RESPONSE, @@ -1110,9 +1002,6 @@ ( sizeof( DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -1124,7 +1013,7 @@ * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: none * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendAcidConcCalRecord( void ) @@ -1133,43 +1022,29 @@ DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T payload; DD_ACID_CONCENTRATES_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetAcidConcCalRequested[ sendCalIdx ] ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_ACID_CONCENTREATES, + (U08*)&record, + sizeof( DD_ACID_CONCENTRATES_RECORD_T ), + NUM_OF_ACID_TYPE, + ALARM_ID_DD_NVM_INVALID_CAL_ACID_CONCENTRATE ) ) { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_ACID_CONCENTREATES, - (U08*)&record, - sizeof( DD_ACID_CONCENTRATES_RECORD_T ), - NUM_OF_ACID_TYPE, - ALARM_ID_DD_NVM_INVALID_CAL_ACID_CONCENTRATE ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.acidConcentrate[ sendCalIdx ]; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.acidConcentrate[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_ACID_CONC_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_ACID_CONC_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - sendCalIdx = sendCalIdx + 1; + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; - if ( sendCalIdx >= NUM_OF_ACID_TYPE ) - { - // Reset Sensor Index - sendCalIdx = 0; - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -1178,7 +1053,7 @@ * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: none * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendBicarbConcCalRecord( void ) @@ -1187,43 +1062,28 @@ DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T payload; DD_BICARB_CONCENTRATES_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetBicarbConcCalRequested[ sendCalIdx ] ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_BICARB_CONCENTRATES, + (U08*)&record, + sizeof( DD_BICARB_CONCENTRATES_RECORD_T ), + NUM_OF_BICARB_TYPE, + ALARM_ID_DD_NVM_INVALID_CAL_BICARB_CONCENTRATE ) ) { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_BICARB_CONCENTRATES, - (U08*)&record, - sizeof( DD_BICARB_CONCENTRATES_RECORD_T ), - NUM_OF_BICARB_TYPE, - ALARM_ID_DD_NVM_INVALID_CAL_BICARB_CONCENTRATE ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.bicarbConcentrate[ sendCalIdx ]; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.bicarbConcentrate[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_BICARB_CONC_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_BICARB_CONC_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - sendCalIdx = sendCalIdx + 1; + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; - if ( sendCalIdx >= NUM_OF_BICARB_TYPE ) - { - // Reset Sensor Index - sendCalIdx = 0; - - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -1249,7 +1109,6 @@ { payload.accepted = TRUE; payload.rejectionReason = 0; - sendCalIdx = 0; // Send the record sendMessage( MSG_ID_DD_UI_NVM_GET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, @@ -1258,9 +1117,6 @@ ( sizeof( DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -1289,7 +1145,6 @@ { payload.accepted = TRUE; payload.rejectionReason = 0; - sendCalIdx = 0; // Send the record sendMessage( MSG_ID_DD_UI_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, @@ -1298,9 +1153,6 @@ ( sizeof( DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - // Move to Send Idle State state = NVM_SEND_RECORD_STATE_IDLE; @@ -1312,7 +1164,7 @@ * The handleSendConductivitySensorCalRecord function sends the calibration * record of the conductivity sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: sendCalIdx, recordToPublish + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ) @@ -1321,43 +1173,29 @@ DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T payload; DD_CONDUCTIVITY_SENSOR_CAL_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetCondSensCalRequested[ sendCalIdx ] ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS, + (U08*)&record, + sizeof( DD_CONDUCTIVITY_SENSOR_CAL_RECORD_T ), + NUM_OF_CONDUCTIVITY_SENSORS, + ALARM_ID_DD_NVM_INVALID_CAL_CONDUCTIVITY_SENSOR ) ) { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS, - (U08*)&record, - sizeof( DD_CONDUCTIVITY_SENSOR_CAL_RECORD_T ), - NUM_OF_CONDUCTIVITY_SENSORS, - ALARM_ID_DD_NVM_INVALID_CAL_CONDUCTIVITY_SENSOR ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.condSensors[ sendCalIdx ]; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.condSensors[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - sendCalIdx = sendCalIdx + 1; + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; - if ( sendCalIdx >= NUM_OF_CONDUCTIVITY_SENSORS ) - { - // Reset Sensor Index - sendCalIdx = 0; - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -1397,14 +1235,15 @@ { BOOL result = FALSE; DD_NVM_GET_SYSTEM_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_SYSTEM_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_SYSTEM_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_SYSTEM_RECORD_RESPONSE, @@ -1442,8 +1281,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_SYSTEM_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SYSTEM_RECORD ); - sendNVEvent( NVM_SYSTEM_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_SYSTEM_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1477,14 +1324,15 @@ { BOOL result = FALSE; DD_NVM_GET_SERVICE_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_SERVICE_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_SERVICE_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, @@ -1522,8 +1370,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_SERVICE_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); - sendNVEvent( NVM_SERVICE_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_SERVICE_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1555,16 +1411,17 @@ *************************************************************************/ BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_USAGE_INFO_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_USAGE_INFO_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, @@ -1600,8 +1457,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_USAGE_INFO_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); - sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1630,14 +1495,15 @@ { BOOL result = FALSE; DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_BASIC_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_INSTIT_BASIC_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, @@ -1673,8 +1539,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1701,16 +1575,17 @@ *************************************************************************/ BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADVANCED_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_INSTIT_ADVANCED_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, @@ -1746,8 +1621,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1775,16 +1658,17 @@ *************************************************************************/ BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; + BOOL result = FALSE; DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADDITIONAL_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_INSTIT_ADDITIONAL_RECORD ] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, @@ -1820,8 +1704,16 @@ record.crc = crc16( (U08*)&record, expectedPayloadLen ); setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1854,38 +1746,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_PRESSURE_SENSORS ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_PRESSURE_SENOSRS; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_PRESSURE_SENSORS ) + if ( FALSE == result ) { - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_CAL_PRESSURE_SENOSRS; - newRequest.isIndexed = TRUE; - newRequest.idx = idx; - enqueueNVMsgRequest( newRequest ); - - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -1935,9 +1821,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_PRESSURE_SENOSRS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -1980,32 +1874,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_TEMPERATURE_SENSORS ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_TEMPERATURE_SENSORS; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_TEMPERATURE_SENSORS ) + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_TEMPERATURE_SENSORS ] = TRUE; - isGetTempCalRequested[ idx ] = TRUE; - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -2044,9 +1938,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_TEMPERATURE_SENSORS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2077,32 +1979,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_CONCENTRATE_PUMPS ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_CONCENTRATE_PUMPS ) + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD] = TRUE; - isGetConcPumpCalRequested[ idx ] = TRUE; - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -2141,9 +2043,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2171,14 +2081,15 @@ { BOOL result = FALSE; DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_D12_PUMP_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_D12_PUMP_RECORD] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_D12_PUMP_CAL_RECORD_RESPONSE, @@ -2187,7 +2098,6 @@ sizeof( DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T ) ); } - return result; } @@ -2208,9 +2118,16 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_D12_PUMP_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.accepted = TRUE; + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2233,14 +2150,15 @@ { BOOL result = FALSE; DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_D48_PUMP_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( TRUE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_D48_PUMP_RECORD] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_D48_PUMP_CAL_RECORD_RESPONSE, @@ -2269,9 +2187,16 @@ record.d48DialysatePump.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_D48_PUMP_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.accepted = TRUE; + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2297,32 +2222,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_ACID_TYPE ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_ACID_CONCENTREATES; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_ACID_TYPE ) + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_ACID_CONCENTREATES] = TRUE; - isGetAcidConcCalRequested[ idx ] = TRUE; - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -2361,9 +2286,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_ACID_CONCENTREATES, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2394,32 +2327,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_BICARB_TYPE ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_BICARB_CONCENTRATES; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_BICARB_TYPE ) + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_BICARB_CONCENTRATES] = TRUE; - isGetBicarbConcCalRequested[ idx ] = TRUE; - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -2458,9 +2391,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_BICARB_CONCENTRATES, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { @@ -2488,14 +2429,15 @@ { BOOL result = FALSE; DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_ACCELEROMETER_SENSOR; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_ACCELEROMETER_SENSOR] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, @@ -2524,9 +2466,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_ACCELEROMETER_SENSOR, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.accepted = TRUE; + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } else { @@ -2549,14 +2499,15 @@ { BOOL result = FALSE; DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_BLOOD_LEAK_SENSOR; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_BLOOD_LEAK_SENSOR] = TRUE; - result = TRUE; - } - else - { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; sendMessage( MSG_ID_DD_UI_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, @@ -2585,9 +2536,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_BLOOD_LEAK_SENSOR, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.accepted = TRUE; + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } else { @@ -2613,32 +2572,32 @@ U08 expectedPayloadLen = sizeof( U32 ); DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; + NVM_MSG_REQUEST_Q_T newRequest; - if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - if ( message->hdr.payloadLen == expectedPayloadLen ) + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + + if ( idx < NUM_OF_CONDUCTIVITY_SENSORS ) { - memcpy( &idx, payloadPtr, sizeof( U32 ) ); + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS; + newRequest.idx = idx; + result = enqueueNVMsgRequest( newRequest ); - if ( idx < NUM_OF_CONDUCTIVITY_SENSORS ) + if ( FALSE == result ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS ] = TRUE; - isGetCondSensCalRequested[ idx ] = TRUE; - result = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; - } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_INDEX_OUT_OF_RANGE; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } //Send the rejection message @@ -2678,9 +2637,17 @@ record.crc = crc16( (U08*)&record, recordSize ); setNVMRecord( NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); - sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); - response.idx = idx; - response.accepted = TRUE; + + if ( TRUE == result ) + { + sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); + response.idx = idx; + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } } else { Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -r6d135d17d73d70a909f346bff2a9b14fec7d2478 -r2078ddd685487111457759eca96387b2008d6717 --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 2078ddd685487111457759eca96387b2008d6717) @@ -1444,7 +1444,7 @@ *************************************************************************/ U32 getMinRORejectionRatioInInstitRecordPCT( void ) { -// return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord[ INSTIT_PARAM_RO_REJECTION_RATIO_ALRAM ].min; +// return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.param[ INSTIT_PARAM_RO_REJECTION_RATIO_ALRAM ].min; } /*********************************************************************//** @@ -1460,7 +1460,7 @@ F32 getMinInletWaterConductivityLimitInstitRecordUSPCM( void ) { -// return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord[ INSTIT_PARAM_INLET_WATER_COND_LOW_ALARM ].min; +// return ddInstitutionalGroup.ddInstitutionalRecord.advancedRecord.param[ INSTIT_PARAM_INLET_WATER_COND_LOW_ALARM ].min; } /*********************************************************************//**