Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -r1e742ba641458eaf36c8d953275a3e1c32b943d4 -r7b414857790dd5282137bf67d56688a703d4bfe7 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 1e742ba641458eaf36c8d953275a3e1c32b943d4) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 7b414857790dd5282137bf67d56688a703d4bfe7) @@ -69,105 +69,52 @@ U32 mfgDateRejectReason; ///< Reason to reject System record parameter mfgDate }DD_NVM_SET_SYSTEM_REC_PAYLOAD_T; -/// DD NVM Get Service Record Response Payload +/// DD NVM Get FP Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. - DD_SERVICE_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_SERVICE_REC_PAYLOAD_T; + SERVICE_RECORD_FP_T data; ///< Data to be sent +}DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T; -/// DD NVM Set Service Record Response Payload +/// DD NVM Set FP Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Reason to reject the entire request - U32 isHDFOnlineFluidAvailableRejectReason; ///< Reason to reject Service record parameter isHDFOnlineFluidAvailable U32 waterRecoveryRejectReason; ///< Reason to reject Service record parameter waterRecovery + U32 primaryFilterReplacementDateRejectReason; ///< Reason to reject Service record parameter primaryFilterReplacementDate + U32 secondaryFilterReplacementDateRejectReason; ///< Reason to reject Service record parameter secondaryFilterReplacementDate + U32 ROMembraneReplacementDateRejectReason; ///< Reason to reject Service record parameter ROMembraneReplacementDate U32 serviceLocRejectReason; ///< Reason to reject Service record parameter serviceLoc U32 lastServiceEpochDateRejectReason; ///< Reason to reject Service record parameter lastServiceEpochDate U32 serviceIntervalSecondsRejectReason; ///< Reason to reject Service record parameter serviceIntervalSeconds U32 lastResetTimeEpochRejectReason; ///< Reason to reject Service record parameter lastResetTimeEpoch -}DD_NVM_SET_SERVICE_REC_PAYLOAD_T; +}DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T; -/// DD NVM Get Usage Info Record Response Payload +/// DD NVM Get DD Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Rejection reason if not accepted. - DD_USAGE_INFO_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T; + SERVICE_RECORD_DD_T data; ///< Data to be sent +}DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T; -/// DD NVM Set Usage Info Record Response Payload +/// DD NVM Set Service Record Response Payload typedef struct { BOOL accepted; ///< Accepted/Rejected U32 rejectionReason; ///< Reason to reject the entire request - U32 roWaterGenTotalLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenTotalL - U32 roWaterGenSinceLastServiceLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenSinceLastServiceL - U32 lastBasicFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastBasicFlushCompleteDateEpoch - U32 lastHeatDisCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatDisCompleteDateEpoch - U32 lastHeatActiveCoolCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatActiveCoolCompleteDateEpoch - U32 lastFilterFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastFilterFlushCompleteDateEpoch - U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch -}DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T; + U32 isHDFOnlineFluidAvailableRejectReason; ///< Reason to reject Service record parameter isHDFOnlineFluidAvailable + U32 ultraFilter1ReplacementDateRejectReason; ///< Reason to reject Service record parameter ultraFilter1ReplacementDate + U32 ultraFilter2ReplacementDateRejectReason; ///< Reason to reject Service record parameter ultraFilter2ReplacementDate + U32 UFPumpTubingReplacementDateRejectReason; ///< Reason to reject Service record parameter UFPumpTubingReplacementDate + U32 serviceLocRejectReason; ///< Reason to reject Service record parameter serviceLoc + U32 lastServiceEpochDateRejectReason; ///< Reason to reject Service record parameter lastServiceEpochDate + U32 serviceIntervalSecondsRejectReason; ///< Reason to reject Service record parameter serviceIntervalSeconds + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Service record parameter lastResetTimeEpoch +}DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T; -/// Institutional data reject reason structure. -typedef struct -{ - U32 minRejectReason; ///< Reason to reject Institutional record parameter min - U32 maxRejectReason; ///< Reason to reject Institutional record parameter max - U32 defRejectReason; ///< Reason to reject Institutional record parameter def -} INSTIT_DATA_REJECT_REASON_T; - -/// DD NVM Get Institutional Basic Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_BASIC_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Basic Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_BASIC ]; ///< Reject reasons for each param of basic institutional record. -}DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T; - -/// DD NVM Get Institutional Advanced Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_ADVANCED_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Advanced Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADVANCED ]; ///< Reject reasons for each param of advanced institutional record. -}DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T; - -/// DD NVM Get Institutional Additional Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Rejection reason if not accepted. - DD_INSTIT_ADDITIONAL_RECORD_T data; ///< Data to be sent -}DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; - -/// DD NVM Set Institutional Additional Record Response Payload -typedef struct -{ - BOOL accepted; ///< Accepted/Rejected - U32 rejectionReason; ///< Reason to reject the entire request - INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADDITIONAL ]; ///< Reject reasons for each param of Additional institutional record. -}DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; - /// Linear reject reason calibration structure typedef struct { @@ -337,6 +284,112 @@ U32 calibrationTimeRejectReason; ///< Reason to reject conductivity sensor calibration record parameter calibrationTime } DD_NVM_SET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T; +/// Institutional data reject reason structure. +typedef struct +{ + U32 minRejectReason; ///< Reason to reject Institutional record parameter min + U32 maxRejectReason; ///< Reason to reject Institutional record parameter max + U32 defRejectReason; ///< Reason to reject Institutional record parameter def +} INSTIT_DATA_REJECT_REASON_T; + +/// DD NVM Get Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_BASIC_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Basic Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_BASIC ]; ///< Reject reasons for each param of basic institutional record. +}DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T; + +/// DD NVM Get Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADVANCED_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Advanced Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADVANCED ]; ///< Reject reasons for each param of advanced institutional record. +}DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T; + +/// DD NVM Get Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + DD_INSTIT_ADDITIONAL_RECORD_T data; ///< Data to be sent +}DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; + +/// DD NVM Set Institutional Additional Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + INSTIT_DATA_REJECT_REASON_T param[ NUM_OF_INSTIT_ADDITIONAL ]; ///< Reject reasons for each param of Additional institutional record. +}DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T; + +/// DD NVM Get FP Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + USAGE_RECORD_FP_T data; ///< Data to be sent +}DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Set FP Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 primaryFilterTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter primaryFilterTreatmentNum + U32 primaryFilterDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter primaryFilterDisinfectionNum + U32 secondaryFilterTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter secondaryFilterTreatmentNum + U32 secondaryFilterDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter secondaryFilterDisinfectionNum + U32 ROMembraneTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ROMembraneTreatmentNum + U32 ROMembraneDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ROMembraneDisinfectionNum + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch +}DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Get DD Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Rejection reason if not accepted. + USAGE_RECORD_DD_T data; ///< Data to be sent +}DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T; + +/// DD NVM Set DD Usage Info Record Response Payload +typedef struct +{ + BOOL accepted; ///< Accepted/Rejected + U32 rejectionReason; ///< Reason to reject the entire request + U32 roWaterGenTotalLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenTotalL + U32 roWaterGenSinceLastServiceLRejectReason; ///< Reason to reject Usage Info record parameter roWaterGenSinceLastServiceL + U32 ultraFilter1TreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter1TreatmentNum + U32 ultraFilter1DisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter1DisinfectionNum + U32 ultraFilter2TreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter2TreatmentNum + U32 ultraFilter2DisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter ultraFilter2DisinfectionNum + U32 UFPumpTubingTreatmentNumRejectReason; ///< Reason to reject Usage Info record parameter UFPumpTubingTreatmentNum + U32 UFPumpTubingDisinfectionNumRejectReason; ///< Reason to reject Usage Info record parameter UFPumpTubingDisinfectionNum + U32 lastBasicFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastBasicFlushCompleteDateEpoch + U32 lastHeatDisCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatDisCompleteDateEpoch + U32 lastHeatActiveCoolCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastHeatActiveCoolCompleteDateEpoch + U32 lastFilterFlushCompleteDateEpochRejectReason; ///< Reason to reject Usage Info record parameter lastFilterFlushCompleteDateEpoch + U32 lastResetTimeEpochRejectReason; ///< Reason to reject Usage Info record parameter lastResetTimeEpoch +}DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T; + #pragma pack(pop) // ********** private data ********** @@ -355,11 +408,8 @@ static SEND_RECORD_STATE_T handleExecSendRecordSendState( void ); static SEND_RECORD_STATE_T handleSendDDSystemRecord( void ); +static SEND_RECORD_STATE_T handleSendFPServiceRecord( void ); static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ); -static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ); -static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ); static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ); @@ -370,6 +420,11 @@ static SEND_RECORD_STATE_T handleSendAccelSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendBloodLeakSensorCalRecord( void ); static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ); +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ); +static SEND_RECORD_STATE_T handleSendFPUsageInfoRecord( void ); +static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ); static void monitorNewCalSignal( void ); @@ -531,7 +586,11 @@ state = handleSendDDSystemRecord(); break; - case NV_DD_DATA_SERVICE_RECORD: + case NV_DD_DATA_FP_SERVICE_RECORD: + state = handleSendFPServiceRecord(); + break; + + case NV_DD_DATA_DD_SERVICE_RECORD: state = handleSendDDServiceRecord(); break; @@ -587,7 +646,11 @@ state = handleSendDDInstitAdditionalRecord(); break; - case NV_DD_DATA_USAGE_INFO_RECORD: + case NV_DD_DATA_FP_USAGE_INFO_RECORD: + state = handleSendFPUsageInfoRecord(); + break; + + case NV_DD_DATA_DD_USAGE_INFO_RECORD: state = handleSendDDUsageInfoRecord(); break; @@ -640,31 +703,31 @@ /*********************************************************************//** * @brief - * The handleSendDDServiceRecord function sends the DD service record. + * The handleSendFPServiceRecord function sends the FP service record. * @details \b Inputs: None * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) +static SEND_RECORD_STATE_T handleSendFPServiceRecord( void ) { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_SERVICE_REC_PAYLOAD_T payload; + DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T payload; // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_SERVICE_RECORD, + if ( TRUE == getNVMRecord( NV_DD_DATA_FP_SERVICE_RECORD, (U08*)&payload.data, - sizeof( DD_SERVICE_RECORD_T ) , + sizeof( SERVICE_RECORD_FP_T ) , 0, - ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC ) ) + ALARM_ID_FP_NVM_INVALID_SERVICE_RECORD_CRC ) ) { payload.accepted = TRUE; payload.rejectionReason = 0; // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - ( sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + ( sizeof( DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } // Move to Send Idle State @@ -675,32 +738,31 @@ /*********************************************************************//** * @brief - * The handleSendDDUsageInfoRecord function sends the DD usage - * information record. + * The handleSendDDServiceRecord function sends the DD service record. * @details \b Inputs: None * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +static SEND_RECORD_STATE_T handleSendDDServiceRecord( void ) { - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T payload; + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T payload; // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_USAGE_INFO_RECORD, + if ( TRUE == getNVMRecord( NV_DD_DATA_DD_SERVICE_RECORD, (U08*)&payload.data, - sizeof( DD_USAGE_INFO_RECORD_T ), + sizeof( SERVICE_RECORD_DD_T ) , 0, - ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) + ALARM_ID_DD_NVM_INVALID_SERVICE_RECORD_CRC ) ) { payload.accepted = TRUE; payload.rejectionReason = 0; // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, - ( sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + ( sizeof( DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } // Move to Send Idle State @@ -711,114 +773,6 @@ /*********************************************************************//** * @brief - * The handleSendDDInstitBasicRecord function sends the DD basic - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: None - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_BASIC_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_BASIC_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief - * The handleSendDDInstitAdvancedRecord function sends the DD advanced - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: None - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_ADVANCED_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_ADVANCED_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief - * The handleSendDDInstitAdditionalRecord function sends the DD additional - * institutional record. - * @details \b Inputs: None - * @details \b Outputs: recordToPublish - * @return state next state of the state machine - *************************************************************************/ -static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ) -{ - SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; - DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T payload; - - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, - (U08*)&payload.data, - sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ), - 0, - ALARM_ID_DD_NVM_INVALID_INSTIT_ADDITIONAL_RECORD_CRC ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - - return state; -} - -/*********************************************************************//** - * @brief * The handleSendPressureSensorCalRecord function sends the calibration * record of the selected pressure sensor. * @details \b Inputs: sendCalIdx @@ -1201,6 +1155,186 @@ /*********************************************************************//** * @brief + * The handleSendDDInstitBasicRecord function sends the DD basic + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitBasicRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_BASIC_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_BASIC_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDInstitAdvancedRecord function sends the DD advanced + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitAdvancedRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_ADVANCED_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_ADVANCED_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDInstitAdditionalRecord function sends the DD additional + * institutional record. + * @details \b Inputs: None + * @details \b Outputs: recordToPublish + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDInstitAdditionalRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, + (U08*)&payload.data, + sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_INSTIT_ADDITIONAL_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendFPUsageInfoRecord function sends the FP usage + * information record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendFPUsageInfoRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_FP_USAGE_INFO_RECORD, + (U08*)&payload.data, + sizeof( USAGE_RECORD_FP_T ), + 0, + ALARM_ID_FP_NVM_INVALID_USAGE_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_FP_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief + * The handleSendDDUsageInfoRecord function sends the DD usage + * information record. + * @details \b Inputs: None + * @details \b Outputs: None + * @return state next state of the state machine + *************************************************************************/ +static SEND_RECORD_STATE_T handleSendDDUsageInfoRecord( void ) +{ + SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_SEND; + DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T payload; + + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_DD_USAGE_INFO_RECORD, + (U08*)&payload.data, + sizeof( USAGE_RECORD_DD_T ), + 0, + ALARM_ID_DD_NVM_INVALID_USAGE_RECORD_CRC ) ) + { + payload.accepted = TRUE; + payload.rejectionReason = 0; + + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + + return state; +} + +/*********************************************************************//** + * @brief * The monitorNewCalSignal function monitors the new calibration signal * and clears it when the timeout has elapsed. * @details \b Inputs: isNewCalRecordAvailable, @@ -1311,55 +1445,55 @@ /*********************************************************************//** * @brief - * The handleDDGetServicRecRequest function processes a request to - * publish the service record. If the NVM send state machine is idle, - * it schedules the service record for publishing; otherwise, it sends + * The handleFPGetServicRecRequest function processes a request to + * publish the FP service record. If the NVM msg queue is not full + * it schedules the FP service record for publishing; otherwise, it sends * a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested + * @details \b Inputs: None + * @details \b Outputs: None * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDGetServicRecRequest( MESSAGE_T *message ) +BOOL handleFPGetServicRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_SERVICE_REC_PAYLOAD_T response = { 0 }; + DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T response = { 0 }; NVM_MSG_REQUEST_Q_T newRequest; newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_SERVICE_RECORD; + newRequest.recordType = NV_DD_DATA_FP_SERVICE_RECORD; newRequest.idx = 0; result = enqueueNVMsgRequest( newRequest ); if ( FALSE == result ) { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_FP_SERVICE_REC_PAYLOAD_T ) ); } return result; } /*********************************************************************//** * @brief - * The handleDDSetServicRecRequest function processes a request to + * The handleFPSetServicRecRequest function processes a request to * update the service record. It validates the request format, updates * the record, schedules it for NV storage, and sends a response. * @details \b Inputs: none * @details \b Outputs: none * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDSetServicRecRequest( MESSAGE_T *message ) +BOOL handleFPSetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_SERVICE_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_SERVICE_REC_PAYLOAD_T response = { 0 }; - DD_SERVICE_RECORD_T record; + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( SERVICE_RECORD_FP_T ) - sizeof( U16 ); + DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T response = { 0 }; + SERVICE_RECORD_FP_T record; // Service record can be updated only in service mode if ( DD_MODE_SERV == getCurrentOperationMode() ) @@ -1368,7 +1502,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_SERVICE_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_FP_SERVICE_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); if ( TRUE == result ) @@ -1391,344 +1525,104 @@ response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; } - sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, + sendMessage( MSG_ID_FP_UI_NVM_SET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_SERVICE_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_SET_FP_SERVICE_REC_PAYLOAD_T ) ); return result; } /*********************************************************************//** * @brief - * The handleDDGetUsageInfoRecRequest function processes a request to - * publish the usage information record. If the NVM send state machine - * is idle, it schedules the usage information record for publishing; - * otherwise, it sends a rejection response. + * The handleDDGetServicRecRequest function processes a request to + * publish the service record. If the NVM send state machine is idle, + * it schedules the service record for publishing; otherwise, it sends + * a rejection response. * @details \b Inputs: nvMExecSendRecordState * @details \b Outputs: isPublishRecordRequested * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) +BOOL handleDDGetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + BOOL result = FALSE; + DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T response = { 0 }; NVM_MSG_REQUEST_Q_T newRequest; newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_USAGE_INFO_RECORD; + newRequest.recordType = NV_DD_DATA_DD_SERVICE_RECORD; newRequest.idx = 0; result = enqueueNVMsgRequest( newRequest ); if ( FALSE == result ) { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_GET_DD_SERVICE_REC_PAYLOAD_T ) ); } return result; } /*********************************************************************//** * @brief - * The handleDDSetUsageInfoRecRequest function processes a request to - * update the usage information record. It validates the request - * format, updates the record, schedules it for NV storage, and sends - * a response. + * The handleDDSetServicRecRequest function processes a request to + * update the service record. It validates the request format, updates + * the record, schedules it for NV storage, and sends a response. * @details \b Inputs: none * @details \b Outputs: none * @param message Pointer to the received message * @return TRUE if the request was accepted otherwise FALSE *************************************************************************/ -BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ) +BOOL handleDDSetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; - DD_USAGE_INFO_RECORD_T record; + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( SERVICE_RECORD_DD_T ) - sizeof( U16 ); + DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T response = { 0 }; + SERVICE_RECORD_DD_T record; - if ( message->hdr.payloadLen == expectedPayloadLen ) + // Service record can be updated only in service mode + if ( DD_MODE_SERV == getCurrentOperationMode() ) { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_USAGE_INFO_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); - - if ( TRUE == result ) + if ( message->hdr.payloadLen == expectedPayloadLen ) { - sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_DD_SERVICE_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); - sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_USAGE_INFO_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDGetInstitBasicRecRequest function processes a request to - * publish the institutional basic record. If the NVM send state - * machine is idle, it schedules the institutional basic record for - * publishing; otherwise, it sends a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_BASIC_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitBasicRecRequest function processes a request to - * update the institutional basic record. It validates the request - * format, updates the record, schedules it for NV storage, and sends - * a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_BASIC_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_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 { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; } } else { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + response.rejectionReason = REQUEST_REJECT_REASON_NVM_INVALID_OPERATION_MODE; } - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, + sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + sizeof( DD_NVM_SET_DD_SERVICE_REC_PAYLOAD_T ) ); return result; } /*********************************************************************//** * @brief - * The handleDDGetInstitAdvancedRecRequest function processes a request - * to publish the institutional advanced record. If the NVM send state - * machine is idle, it schedules the institutional advanced record for - * publishing; otherwise, it sends a rejection response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_ADVANCED_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitAdvancedRecRequest function processes a request - * to update the institutional advanced record. It validates the - * request format, updates the record, schedules it for NV storage, - * and sends a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_ADVANCED_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDGetInstitAdditionalRecRequest function processes a - * request to publish the institutional additional record. If the NVM - * send state machine is idle, it schedules the institutional - * additional record for publishing; otherwise, it sends a rejection - * response. - * @details \b Inputs: nvMExecSendRecordState - * @details \b Outputs: isPublishRecordRequested - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; - NVM_MSG_REQUEST_Q_T newRequest; - - newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; - newRequest.recordType = NV_DD_DATA_INSTIT_ADDITIONAL_RECORD; - newRequest.idx = 0; - result = enqueueNVMsgRequest( newRequest ); - - if ( FALSE == result ) - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - - sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&response, - sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); - } - - return result; -} - -/*********************************************************************//** - * @brief - * The handleDDSetInstitAdditionalRecRequest function processes a - * request to update the institutional additional record. It validates - * the request format, updates the record, schedules it for NV storage, - * and sends a response. - * @details \b Inputs: none - * @details \b Outputs: none - * @param message Pointer to the received message - * @return TRUE if the request was accepted otherwise FALSE - *************************************************************************/ -BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U08 expectedPayloadLen = sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ); - DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; - DD_INSTIT_ADDITIONAL_RECORD_T record; - - if ( message->hdr.payloadLen == expectedPayloadLen ) - { - memcpy( &record, message->payload, expectedPayloadLen ); - record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); - result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); - - if ( TRUE == result ) - { - sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); - response.accepted = TRUE; - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; - } - } - else - { - response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, - sizeof( DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); - - return result; -} - -/*********************************************************************//** - * @brief * The handleDDGetPressureSensorCalRecRequest function processes a * request to publish a pressure sensor calibration record. It validates * the request payload and sensor index before scheduling the record @@ -2671,7 +2565,417 @@ return result; } +/*********************************************************************//** + * @brief + * The handleDDGetInstitBasicRecRequest function processes a request to + * publish the institutional basic record. If the NVM send state + * machine is idle, it schedules the institutional basic record for + * publishing; otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_BASIC_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitBasicRecRequest function processes a request to + * update the institutional basic record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_BASIC_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_BASIC_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_BASIC_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetInstitAdvancedRecRequest function processes a request + * to publish the institutional advanced record. If the NVM send state + * machine is idle, it schedules the institutional advanced record for + * publishing; otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADVANCED_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitAdvancedRecRequest function processes a request + * to update the institutional advanced record. It validates the + * request format, updates the record, schedules it for NV storage, + * and sends a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADVANCED_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADVANCED_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_ADVANCED_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetInstitAdditionalRecRequest function processes a + * request to publish the institutional additional record. If the NVM + * send state machine is idle, it schedules the institutional + * additional record for publishing; otherwise, it sends a rejection + * response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_INSTIT_ADDITIONAL_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetInstitAdditionalRecRequest function processes a + * request to update the institutional additional record. It validates + * the request format, updates the record, schedules it for NV storage, + * and sends a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( DD_INSTIT_ADDITIONAL_RECORD_T ) - sizeof( U16 ); + DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; + DD_INSTIT_ADDITIONAL_RECORD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_INSTIT_ADDITIONAL_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleFPGetUsageInfoRecRequest function processes a request to + * publish the FP usage information record. If the NVM send state machine + * is idle, it schedules the usage information record for publishing; + * otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleFPGetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_FP_USAGE_INFO_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_FP_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_FP_USAGE_INFO_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetUsageInfoRecRequest function processes a request to + * update the FP usage information record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleFPSetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( USAGE_RECORD_FP_T ) - sizeof( U16 ); + DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + USAGE_RECORD_FP_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_FP_USAGE_INFO_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_FP_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_FP_USAGE_INFO_REC_PAYLOAD_T ) ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDGetUsageInfoRecRequest function processes a request to + * publish the DD usage information record. If the NVM send state machine + * is idle, it schedules the usage information record for publishing; + * otherwise, it sends a rejection response. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_DD_USAGE_INFO_RECORD; + newRequest.idx = 0; + result = enqueueNVMsgRequest( newRequest ); + + if ( FALSE == result ) + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + + sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&response, + sizeof( DD_NVM_GET_DD_USAGE_INFO_REC_PAYLOAD_T ) ); + } + + return result; +} + +/*********************************************************************//** + * @brief + * The handleDDSetUsageInfoRecRequest function processes a request to + * update the DD usage information record. It validates the request + * format, updates the record, schedules it for NV storage, and sends + * a response. + * @details \b Inputs: none + * @details \b Outputs: none + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ +BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U08 expectedPayloadLen = sizeof( USAGE_RECORD_DD_T ) - sizeof( U16 ); + DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; + USAGE_RECORD_DD_T record; + + if ( message->hdr.payloadLen == expectedPayloadLen ) + { + memcpy( &record, message->payload, expectedPayloadLen ); + record.crc = crc16( (U08*)&record, expectedPayloadLen ); + setNVMRecord( NV_DD_DATA_DD_USAGE_INFO_RECORD, (U08*)&record, 0 ); + result = enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); + + if ( TRUE == result ) + { + sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); + response.accepted = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, + sizeof( DD_NVM_SET_DD_USAGE_INFO_REC_PAYLOAD_T ) ); + + return result; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Services/NVMessagingDD.h =================================================================== diff -u -r6a30402a7d47d1c77c04845a1c880935f00c6551 -r7b414857790dd5282137bf67d56688a703d4bfe7 --- firmware/App/Services/NVMessagingDD.h (.../NVMessagingDD.h) (revision 6a30402a7d47d1c77c04845a1c880935f00c6551) +++ firmware/App/Services/NVMessagingDD.h (.../NVMessagingDD.h) (revision 7b414857790dd5282137bf67d56688a703d4bfe7) @@ -42,21 +42,12 @@ BOOL handleDDGetSystemRecRequest( MESSAGE_T *message ); BOOL handleDDSetSystemRecRequest( MESSAGE_T *message ); +BOOL handleFPGetServicRecRequest( MESSAGE_T *message ); +BOOL handleFPSetServicRecRequest( MESSAGE_T *message ); + BOOL handleDDGetServicRecRequest( MESSAGE_T *message ); BOOL handleDDSetServicRecRequest( MESSAGE_T *message ); -BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ); -BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ); - -BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ); -BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ); - -BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ); -BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ); - -BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ); -BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ); - BOOL handleDDGetPressureSensorCalRecRequest( MESSAGE_T *message ); BOOL handleDDSetPressureSensorCalRecRequest( MESSAGE_T *message ); @@ -87,6 +78,21 @@ BOOL handleDDGetConductivitySensorCalRecRequest( MESSAGE_T *message ); BOOL handleDDSetConductivitySensorCalRecRequest( MESSAGE_T *message ); +BOOL handleDDGetInstitBasicRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitBasicRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetInstitAdvancedRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitAdvancedRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetInstitAdditionalRecRequest( MESSAGE_T *message ); +BOOL handleDDSetInstitAdditionalRecRequest( MESSAGE_T *message ); + +BOOL handleFPGetUsageInfoRecRequest( MESSAGE_T *message ); +BOOL handleFPSetUsageInfoRecRequest( MESSAGE_T *message ); + +BOOL handleDDGetUsageInfoRecRequest( MESSAGE_T *message ); +BOOL handleDDSetUsageInfoRecRequest( MESSAGE_T *message ); + BOOL testSetNVRecordCRCOverride( MESSAGE_T *message ); /**@}*/ Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -r1e742ba641458eaf36c8d953275a3e1c32b943d4 -r7b414857790dd5282137bf67d56688a703d4bfe7 --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 1e742ba641458eaf36c8d953275a3e1c32b943d4) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 7b414857790dd5282137bf67d56688a703d4bfe7) @@ -1265,7 +1265,7 @@ // TODO: Update lastUpdatedTime to current timestamp published by UI. ddServiceGroup.ddServiceRecord.fpRecord.lastResetTimeEpoch = RECORD_DEFAULT_TIME; - ddServiceGroup.ddServiceRecord.fpRecord.crc = crc16( (U08*)&ddServiceGroup.fpServiceRecord, + ddServiceGroup.ddServiceRecord.fpRecord.crc = crc16( (U08*)&ddServiceGroup.ddServiceRecord.fpRecord, sizeof( SERVICE_RECORD_FP_T ) - sizeof( U16 ) ); } @@ -1281,8 +1281,8 @@ static void initDDServiceRecord( void ) { ddServiceGroup.ddServiceRecord.ddRecord.isHDFOnlineFluidAvailable = 0; - ddServiceGroup.ddServiceRecord.ddRecord.UltraFilter1ReplacementDate = 0; - ddServiceGroup.ddServiceRecord.ddRecord.UltraFilter2ReplacementDate = 0; + ddServiceGroup.ddServiceRecord.ddRecord.ultraFilter1ReplacementDate = 0; + ddServiceGroup.ddServiceRecord.ddRecord.ultraFilter2ReplacementDate = 0; ddServiceGroup.ddServiceRecord.ddRecord.UFPumpTubingReplacementDate = 0; ddServiceGroup.ddServiceRecord.ddRecord.serviceLoc = 0; ddServiceGroup.ddServiceRecord.ddRecord.lastServiceEpochDate = 0; @@ -1376,12 +1376,12 @@ *************************************************************************/ static void initFPUsageRecord( void ) { - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.primaryFilterTreatmentNum; = 0; - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.primaryFilterDisinfectionNum; = 0; - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.secondaryFilterTreatmentNum; = 0; - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.secondaryFilterDisinfectionNum; = 0; - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.ROMembraneTreatmentNum; = 0; - ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.ROMembraneDisinfectionNum; = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.primaryFilterTreatmentNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.primaryFilterDisinfectionNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.secondaryFilterTreatmentNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.secondaryFilterDisinfectionNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.ROMembraneTreatmentNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.ROMembraneDisinfectionNum = 0; // TODO: Update lastUpdatedTime to current timestamp published by UI. ddUsageInfoGroup.ddUsageInfoRecord.fpRecord.lastResetTimeEpoch = RECORD_DEFAULT_TIME; @@ -1403,10 +1403,10 @@ { ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.roWaterGenTotalL = 0.0F; ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.roWaterGenSinceLastServiceL = 0.0F; - ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UltraFilter1TreatmentNum = 0; - ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UltraFilter1DisinfectionNum = 0; - ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UltraFilter2TreatmentNum = 0; - ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UltraFilter2DisinfectionNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.ultraFilter1TreatmentNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.ultraFilter1DisinfectionNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.ultraFilter2TreatmentNum = 0; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.ultraFilter2DisinfectionNum = 0; ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UFPumpTubingTreatmentNum = 0; ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.UFPumpTubingDisinfectionNum = 0; ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.lastBasicFlushCompleteDateEpoch = 0; @@ -1498,15 +1498,13 @@ switch ( recType ) { case NVM_SYSTEM_RECORD: - ddSystemGroup.ddSystemRecord.crc = crc16 ( (U08*)&ddSystemGroup.ddSystemRecord, - sizeof( DD_SYSTEM_RECORD_T ) - sizeof( U16 ) ); - ddSystemGroup.crc = crc16 ( (U08*)&ddSystemGroup, - sizeof( DD_SYSTEM_GROUP_T ) - sizeof( U16 ) ); - break; + ddSystemGroup.ddSystemRecord.crc = crc16 ( (U08*)&ddSystemGroup.ddSystemRecord, + sizeof( DD_SYSTEM_RECORD_T ) - sizeof( U16 ) ); + ddSystemGroup.crc = crc16 ( (U08*)&ddSystemGroup, + sizeof( DD_SYSTEM_GROUP_T ) - sizeof( U16 ) ); + break; case NVM_SERVICE_RECORD: - ddServiceGroup.ddServiceRecord.crc = crc16 ( (U08*)&ddServiceGroup.ddServiceRecord, - sizeof( DD_SERVICE_RECORD_T ) - sizeof( U16 ) ); ddServiceGroup.crc = crc16 ( (U08*)&ddServiceGroup, sizeof( DD_SERVICE_GROUP_T ) - sizeof( U16 ) ); break; @@ -1522,8 +1520,6 @@ break; case NVM_USAGE_INFO_RECORD: - ddUsageInfoGroup.ddUsageInfoRecord.crc = crc16 ( (U08*)&ddUsageInfoGroup.ddUsageInfoRecord, - sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ) ); ddUsageInfoGroup.crc = crc16 ( (U08*)&ddUsageInfoGroup, sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ) ); break; @@ -1554,30 +1550,32 @@ switch ( disinfect ) { case USAGE_INFO_BASIC_FLUSH: - ddUsageInfoGroup.ddUsageInfoRecord.lastBasicFlushCompleteDateEpoch = epochTime; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.lastBasicFlushCompleteDateEpoch = epochTime; break; case USAGE_INFO_HEAT_DIS: - ddUsageInfoGroup.ddUsageInfoRecord.lastHeatDisCompleteDateEpoch = epochTime; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.lastHeatDisCompleteDateEpoch = epochTime; break; case USAGE_INFO_FILTER_FLUSH: - ddUsageInfoGroup.ddUsageInfoRecord.lastFilterFlushCompleteDateEpoch = epochTime; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.lastFilterFlushCompleteDateEpoch = epochTime; break; case USAGE_INFO_HEAT_DIS_ACTIVE_COOL: - ddUsageInfoGroup.ddUsageInfoRecord.lastHeatActiveCoolCompleteDateEpoch = epochTime; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.lastHeatActiveCoolCompleteDateEpoch = epochTime; break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_NVM_INVALID_USAGE_INFO_SELECTED, ( U32 )disinfect ); break; } - ddUsageInfoGroup.ddUsageInfoRecord.crc = crc16( (U08*)&ddUsageInfoGroup.ddUsageInfoRecord, sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ) ); - ddUsageInfoGroup.crc = crc16( (U08*)&ddUsageInfoGroup, sizeof( DD_USAGE_INFO_GROUP_T ) - sizeof( U16 ) ); - usageWriteTries = 0; - status = TRUE; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.crc = crc16( (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.ddRecord, + sizeof( USAGE_RECORD_DD_T ) - sizeof( U16 ) ); + ddUsageInfoGroup.crc = crc16( (U08*)&ddUsageInfoGroup, + sizeof( DD_USAGE_INFO_GROUP_T ) - sizeof( U16 ) ); + usageWriteTries = 0; + status = TRUE; enqueueEraseAndWriteSector( NVM_USAGE_INFO_RECORD ); sendNVEvent( NVM_USAGE_INFO_RECORD, 0, 0 ); @@ -1608,16 +1606,22 @@ { // When the service record is changed, all the sector 0 must be re-written plus the stack's usage information must be updated. // Therefore, at least 4 queues are needed to be able to update all the records. The usage records are changed: - // In HD the treatment time since last service is reset to 0 - // In DG the RO water generation since the last service in reset to 0 + // In TD the treatment time since last service is reset to 0 + // In DD the RO water generation since the last service in reset to 0 -// ddServiceGroup.ddServiceRecord.lastServiceEpochDate = getRTCTimestamp(); - ddServiceGroup.ddServiceRecord.crc = crc16( (U08*)&ddServiceGroup.ddServiceRecord, sizeof( DD_SERVICE_RECORD_T ) - sizeof( U16 ) ); - ddServiceGroup.crc = crc16( (U08*)&ddServiceGroup, sizeof( DD_SERVICE_GROUP_T ) - sizeof( U16 ) ); + // TODO: Update lastUpdatedTime to current timestamp published by UI. +// ddServiceGroup.ddServiceRecord.ddRecord.lastServiceEpochDate = getRTCTimestamp(); + + ddServiceGroup.ddServiceRecord.ddRecord.crc = crc16( (U08*)&ddServiceGroup.ddServiceRecord.ddRecord, + sizeof( SERVICE_RECORD_DD_T ) - sizeof( U16 ) ); + ddServiceGroup.crc = crc16( (U08*)&ddServiceGroup, + sizeof( DD_SERVICE_GROUP_T ) - sizeof( U16 ) ); // Update the DG usage info - ddUsageInfoGroup.ddUsageInfoRecord.roWaterGenSinceLastServiceL = 0; - ddUsageInfoGroup.ddUsageInfoRecord.crc = crc16( (U08*)&ddUsageInfoGroup.ddUsageInfoRecord, sizeof( DD_USAGE_INFO_RECORD_T ) - sizeof( U16 ) ); - ddUsageInfoGroup.crc = crc16( (U08*)&ddUsageInfoGroup, sizeof( DD_USAGE_INFO_GROUP_T ) - sizeof( U16 ) ); + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.roWaterGenSinceLastServiceL = 0; + ddUsageInfoGroup.ddUsageInfoRecord.ddRecord.crc = crc16( (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.ddRecord, + sizeof( USAGE_RECORD_DD_T ) - sizeof( U16 ) ); + ddUsageInfoGroup.crc= crc16( (U08*)&ddUsageInfoGroup, + sizeof( DD_USAGE_INFO_GROUP_T ) - sizeof( U16 ) ); // Service record has been touched so the entire sector 0 of the EEPROM must be rewritten enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); @@ -1694,11 +1698,16 @@ nvDataLength = sizeof( ddSystemGroup.ddSystemRecord ); break; - case NV_DD_DATA_SERVICE_RECORD: - nvDataStartPtr = (U08*)&ddServiceGroup.ddServiceRecord; - nvDataLength = sizeof( ddServiceGroup.ddServiceRecord ); + case NV_DD_DATA_FP_SERVICE_RECORD: + nvDataStartPtr = (U08*)&ddServiceGroup.ddServiceRecord.fpRecord; + nvDataLength = sizeof( ddServiceGroup.ddServiceRecord.fpRecord ); break; + case NV_DD_DATA_DD_SERVICE_RECORD: + nvDataStartPtr = (U08*)&ddServiceGroup.ddServiceRecord.ddRecord; + nvDataLength = sizeof( ddServiceGroup.ddServiceRecord.ddRecord ); + break; + case NV_DD_DATA_CAL_PRESSURE_SENOSRS: nvDataStartPtr = (U08*)&ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord; nvDataLength = sizeof( ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord ); @@ -1782,11 +1791,16 @@ nvDataLength = sizeof( ddInstitutionalGroup.ddInstitutionalRecord.additionalRecord ); break; - case NV_DD_DATA_USAGE_INFO_RECORD: - nvDataStartPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord; - nvDataLength = sizeof( ddUsageInfoGroup.ddUsageInfoRecord ); + case NV_DD_DATA_FP_USAGE_INFO_RECORD: + nvDataStartPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.fpRecord; + nvDataLength = sizeof( ddUsageInfoGroup.ddUsageInfoRecord.fpRecord ); break; + case NV_DD_DATA_DD_USAGE_INFO_RECORD: + nvDataStartPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.ddRecord; + nvDataLength = sizeof( ddUsageInfoGroup.ddUsageInfoRecord.ddRecord ); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_NVM_INVALID_RECORD_SELECTED, ( U32 )nvData ); break; @@ -1849,12 +1863,18 @@ recTypeGroup = NVM_SYSTEM_RECORD; break; - case NV_DD_DATA_SERVICE_RECORD: - destPtr = (U08*)&ddServiceGroup.ddServiceRecord; - dataSize = sizeof( ddServiceGroup.ddServiceRecord ); + case NV_DD_DATA_FP_SERVICE_RECORD: + destPtr = (U08*)&ddServiceGroup.ddServiceRecord.fpRecord; + dataSize = sizeof( ddServiceGroup.ddServiceRecord.fpRecord ); recTypeGroup = NVM_SERVICE_RECORD; break; + case NV_DD_DATA_DD_SERVICE_RECORD: + destPtr = (U08*)&ddServiceGroup.ddServiceRecord.ddRecord; + dataSize = sizeof( ddServiceGroup.ddServiceRecord.ddRecord ); + recTypeGroup = NVM_SERVICE_RECORD; + break; + case NV_DD_DATA_CAL_PRESSURE_SENOSRS: destPtr = (U08*)&ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord.pressureSensors[ idx ]; dataSize = sizeof( ddCalibrationGroup.ddCalibrationRecord.presSensorsCalRecord.pressureSensors[ 0 ] ); @@ -1935,12 +1955,18 @@ recTypeGroup = NVM_INSTITUTIONAL_RECORD; break; - case NV_DD_DATA_USAGE_INFO_RECORD: - destPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord; - dataSize = sizeof( ddUsageInfoGroup.ddUsageInfoRecord ); + case NV_DD_DATA_FP_USAGE_INFO_RECORD: + destPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.fpRecord; + dataSize = sizeof( ddUsageInfoGroup.ddUsageInfoRecord.fpRecord ); recTypeGroup = NVM_USAGE_INFO_RECORD; break; + case NV_DD_DATA_DD_USAGE_INFO_RECORD: + destPtr = (U08*)&ddUsageInfoGroup.ddUsageInfoRecord.ddRecord; + dataSize = sizeof( ddUsageInfoGroup.ddUsageInfoRecord.ddRecord ); + recTypeGroup = NVM_USAGE_INFO_RECORD; + break; + default: break; } @@ -2048,15 +2074,15 @@ break; case NVM_SERVICE_RECORD: - ddServiceGroup.ddServiceRecord.crc = crc; + ddServiceGroup.crc = crc; break; case NVM_INSTITUTIONAL_RECORD: ddInstitutionalGroup.crc = crc; break; case NVM_USAGE_INFO_RECORD: - ddUsageInfoGroup.ddUsageInfoRecord.crc = crc; + ddUsageInfoGroup.crc = crc; break; default: Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -r1e742ba641458eaf36c8d953275a3e1c32b943d4 -r7b414857790dd5282137bf67d56688a703d4bfe7 --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 1e742ba641458eaf36c8d953275a3e1c32b943d4) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 7b414857790dd5282137bf67d56688a703d4bfe7) @@ -74,7 +74,8 @@ typedef enum DD_nv_commands { NV_DD_DATA_SYSTEM_RECORD = 0, ///< System record. - NV_DD_DATA_SERVICE_RECORD, ///< Service record + NV_DD_DATA_FP_SERVICE_RECORD, ///< FP Service record + NV_DD_DATA_DD_SERVICE_RECORD, ///< DD Service record NV_DD_DATA_CAL_PRESSURE_SENOSRS, ///< Pressure sensors calibration data. NV_DD_DATA_CAL_TEMPERATURE_SENSORS, ///< Temperature sensors calibration data. NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD, ///< Concentrate pumps calibration record. @@ -88,7 +89,8 @@ NV_DD_DATA_INSTIT_BASIC_RECORD, ///< Basic institutional record. NV_DD_DATA_INSTIT_ADVANCED_RECORD, ///< Advanced institutional record. NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, ///< Additional institutional record. - NV_DD_DATA_USAGE_INFO_RECORD, ///< Usage record. + NV_DD_DATA_FP_USAGE_INFO_RECORD, ///< FP Usage record. + NV_DD_DATA_DD_USAGE_INFO_RECORD, ///< DD Usage record. NUM_OF_NV_DD_DATA ///< Number of non-volatile data. } NV_DATA_T; @@ -294,8 +296,8 @@ typedef struct { BOOL isHDFOnlineFluidAvailable; ///< True : HDF Online Fluid feature is available, False if not. - U32 UltraFilter1ReplacementDate; ///< Last replacement date of Ultrafilter 1 - U32 UltraFilter2ReplacementDate; ///< Last replacement date of Ultrafilter 2 + U32 ultraFilter1ReplacementDate; ///< Last replacement date of Ultrafilter 1 + U32 ultraFilter2ReplacementDate; ///< Last replacement date of Ultrafilter 2 U32 UFPumpTubingReplacementDate; ///< Last replacement date of UP Pump Tubing U32 serviceLoc; ///< DD service location. U32 lastServiceEpochDate; ///< DD last service date in epoch. @@ -373,10 +375,10 @@ { F32 roWaterGenTotalL; ///< Total RO water generated in liters. (Cannot be reset) F32 roWaterGenSinceLastServiceL; ///< RO water generated since last treatment in liters. - U32 UltraFilter1TreatmentNum; ///< Number of treatments performed on ultrafilter 1 since last replaced - U32 UltraFilter1DisinfectionNum; ///< Number of disinfections performed on ultrafilter 1 since last replaced - U32 UltraFilter2TreatmentNum; ///< Number of treatments performed on ultrafilter 2 since last replaced - U32 UltraFilter2DisinfectionNum; ///< Number of disinfections performed on ultrafilter 2 since last replaced + U32 ultraFilter1TreatmentNum; ///< Number of treatments performed on ultrafilter 1 since last replaced + U32 ultraFilter1DisinfectionNum; ///< Number of disinfections performed on ultrafilter 1 since last replaced + U32 ultraFilter2TreatmentNum; ///< Number of treatments performed on ultrafilter 2 since last replaced + U32 ultraFilter2DisinfectionNum; ///< Number of disinfections performed on ultrafilter 2 since last replaced U32 UFPumpTubingTreatmentNum; ///< Number of treatments performed on UF Pump Tubing since last replaced U32 UFPumpTubingDisinfectionNum; ///< Number of disinfections performed on UF Pump Tubing since last replaced U32 lastBasicFlushCompleteDateEpoch; ///< Last basic flush complete date in epoch.