Index: firmware/App/Drivers/ConductivitySensors.h =================================================================== diff -u -r83bae6ae5f7f26a3511d1d6965310fd8ac9ad496 -r6d135d17d73d70a909f346bff2a9b14fec7d2478 --- firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision 83bae6ae5f7f26a3511d1d6965310fd8ac9ad496) +++ firmware/App/Drivers/ConductivitySensors.h (.../ConductivitySensors.h) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) @@ -76,6 +76,8 @@ NUM_OF_CONDUCTIVTY_CAL_IDXS, ///< Number of conductivity cal indexes. } CONDUCTIVITY_CAL_IDX_T; +#pragma pack(push, 1) + /// Conductivity sensor calibration struct typedef struct { F32 K_high; ///< Cell coefficient, high range, default = 4, range = [3, 6] @@ -94,6 +96,8 @@ U16 crc; ///< CRC } CONDUCTIVITY_COEFFICIENTS_T; +#pragma pack(pop) + typedef struct { U08 swRev[ CONDUCTIVITY_CAL_CHAR_LENGTH ]; ///< SW Revision. Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -rf3af61ba8f46e4cdde1c5daf749a29ae31b9f514 -r6d135d17d73d70a909f346bff2a9b14fec7d2478 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision f3af61ba8f46e4cdde1c5daf749a29ae31b9f514) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) @@ -32,7 +32,7 @@ #define NEW_CAL_AVAILABLE_SIGNAL_TIMEOUT_MS (1 * MS_PER_SECOND) ///< New calibration available signal timeout in milliseconds. #define NUM_OF_BYTES_PER_RECORD_PAYLOAD ( MAX_MSG_PAYLOAD_SIZE - ( sizeof( U32 ) ) ) ///< Number of bytes per calibration payload. -#define RECORD_DATA_SEND_INTERVAL_COUNT (MS_PER_SECOND / (5 * TASK_GENERAL_INTERVAL)) ///< Calibration data send time interval in counts. +#define RECORD_DATA_SEND_INTERVAL_COUNT (MS_PER_SECOND / (5 * TASK_GENERAL_INTERVAL) ) ///< Calibration data send time interval in counts. #define RECORD_DATA_RECEIVE_TIMEOUT_MS (4 * MS_PER_SECOND) ///< Record data receive all the data packets timeout in ms. #define RECORD_DATA_MAX_MESSAGE_DFFIRENCE 1 ///< Calibration data receive message different from the previous message. #define RECORD_DATA_FIRST_RECEIVING_MSG_NUM 1 ///< Calibration data first receiving message number. @@ -441,29 +441,6 @@ break; } -// if( nvmExecreceiveRecordState == NVM_RECEIVE_RECORD_STATE_RECEIVE ) -// { -// if ( ( NVM_CALIBRATION_RECORD == currentRxRecordType ) && -// ( TRUE == didTimeout( calRecordReceiveStartTime, RECORD_DATA_RECEIVE_TIMEOUT_MS ) ) ) -// { -// updateRecordCRC(NVM_CALIBRATION_RECORD); -// enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); -// startNewCalRecordAvailableTimer(); -// setNewCalibrationRecordAvailable( TRUE ); -// sendNVEvent( NVM_CALIBRATION_RECORD , 0, 0 ); -// nvmExecreceiveRecordState = NVM_RECEIVE_RECORD_STATE_IDLE; -// } -// -// if ( ( NVM_INSTITUTIONAL_RECORD == currentRxRecordType ) && -// ( TRUE == didTimeout( institRecordReceiveStartTime, RECORD_DATA_RECEIVE_TIMEOUT_MS ) ) ) -// { -// updateRecordCRC(NVM_INSTITUTIONAL_RECORD); -// enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); -// sendNVEvent( NVM_INSTITUTIONAL_RECORD , 0, 0 ); -// nvmExecreceiveRecordState = NVM_RECEIVE_RECORD_STATE_IDLE; -// } -// } - // Check the calibration signal monitorNewCalSignal(); } @@ -539,7 +516,7 @@ } nvPublishRecordType = ( NV_DATA_T )( nvPublishRecordType + 1 ); - if( nvPublishRecordType >= NUM_OF_NV_DD_DATA ) + if ( nvPublishRecordType >= NUM_OF_NV_DD_DATA ) { nvPublishRecordType = NV_DD_DATA_SYSTEM_RECORD; } @@ -891,7 +868,7 @@ * The handleSendPressureSensorCalRecord function sends the calibration * record of the selected pressure sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendPressureSensorCalRecord( void ) @@ -945,7 +922,7 @@ * The handleSendTempSensorCalRecord function sends the calibration record * of the selected temperature sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendTempSensorCalRecord( void ) @@ -999,7 +976,7 @@ * The handleSendConcPumpCalRecord function sends the calibration record * of the selected concentrate pump. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendConcPumpCalRecord( void ) @@ -1053,7 +1030,7 @@ * The handleSendD12PumpCalRecord function sends the calibration record of * the D12 dialysate pump. * @details \b Inputs: None - * @details \b Outputs: sendCalIdx + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendD12PumpCalRecord( void ) @@ -1087,7 +1064,7 @@ * The handleSendD48PumpCalRecord function sends the calibration record of * the D48 dialysate pump. * @details \b Inputs: None - * @details \b Outputs: sendCalIdx + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendD48PumpCalRecord( void ) @@ -1121,7 +1098,7 @@ * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendAcidConcCalRecord( void ) @@ -1175,7 +1152,7 @@ * The handleSendAcidConcCalRecord function sends the calibration record of * the selected acid concentrate. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendBicarbConcCalRecord( void ) @@ -1229,7 +1206,7 @@ * The handleSendAccelSensorCalRecord function sends the calibration record * of the accelerometer sensor. * @details \b Inputs: None - * @details \b Outputs: sendCalIdx + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendAccelSensorCalRecord( void ) @@ -1269,7 +1246,7 @@ * The handleSendBloodLeakSensorCalRecord function sends the calibration * record of the blood leak sensor. * @details \b Inputs: None - * @details \b Outputs: sendCalIdx + * @details \b Outputs: None * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendBloodLeakSensorCalRecord( void ) @@ -1309,7 +1286,7 @@ * The handleSendConductivitySensorCalRecord function sends the calibration * record of the conductivity sensor. * @details \b Inputs: sendCalIdx - * @details \b Outputs: None + * @details \b Outputs: sendCalIdx, recordToPublish * @return state next state of the state machine *************************************************************************/ static SEND_RECORD_STATE_T handleSendConductivitySensorCalRecord( void ) @@ -1379,10 +1356,21 @@ } } +/*********************************************************************//** + * @brief + * The handleDDGetSystemRecRequest function processes a request to + * publish the system record. If the NVM send state machine is idle, + * it schedules the system 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 handleDDGetSystemRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - DD_NVM_GET_SYSTEM_REC_PAYLOAD_T response; + BOOL result = FALSE; + DD_NVM_GET_SYSTEM_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1395,13 +1383,23 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_SYSTEM_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_SYSTEM_REC_PAYLOAD_T ) ); } return result; } +/*********************************************************************//** + * @brief + * The handleDDSetSystemRecRequest function processes a request to + * update the system 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 handleDDSetSystemRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; @@ -1416,7 +1414,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_SYSTEM_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_SYSTEM_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SYSTEM_RECORD ); sendNVEvent( NVM_SYSTEM_RECORD, 0, 0 ); response.accepted = TRUE; @@ -1432,16 +1430,27 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_SYSTEM_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_SYSTEM_REC_PAYLOAD_T ) ); return result; } +/*********************************************************************//** + * @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 + * 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 handleDDGetServicRecRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - DD_NVM_GET_SERVICE_REC_PAYLOAD_T response; + BOOL result = FALSE; + DD_NVM_GET_SERVICE_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1454,13 +1463,23 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_SERVICE_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_SERVICE_REC_PAYLOAD_T ) ); } return result; } +/*********************************************************************//** + * @brief + * 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 handleDDSetServicRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; @@ -1475,7 +1494,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_SERVICE_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_SERVICE_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_SERVICE_RECORD ); sendNVEvent( NVM_SERVICE_RECORD, 0, 0 ); response.accepted = TRUE; @@ -1491,16 +1510,27 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_SERVICE_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_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. + * @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_USAGE_INFO_REC_PAYLOAD_T response; + DD_NVM_GET_USAGE_INFO_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1513,13 +1543,24 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_USAGE_INFO_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_USAGE_INFO_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. + * @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; @@ -1531,7 +1572,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_USAGE_INFO_RECORD, (U08*)&record, 0 ); + 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; @@ -1542,16 +1583,27 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_USAGE_INFO_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&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; + BOOL result = FALSE; + DD_NVM_GET_INSTIT_BASIC_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1564,13 +1616,24 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_BASIC_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (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; @@ -1582,7 +1645,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_INSTIT_BASIC_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); response.accepted = TRUE; @@ -1593,16 +1656,27 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_BASIC_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&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; + DD_NVM_GET_INSTIT_ADVANCED_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1615,13 +1689,24 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADVANCED_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (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; @@ -1633,7 +1718,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_INSTIT_ADVANCED_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); response.accepted = TRUE; @@ -1644,16 +1729,28 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADVANCED_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&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; + DD_NVM_GET_INSTIT_ADDITIONAL_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1666,13 +1763,24 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_INSTIT_ADDITIONAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (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; @@ -1684,7 +1792,7 @@ { memcpy( &record, message->payload, expectedPayloadLen ); record.crc = crc16( (U08*)&record, expectedPayloadLen ); - setNVMMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_INSTIT_ADDITIONAL_RECORD, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_INSTITUTIONAL_RECORD ); sendNVEvent( NVM_INSTITUTIONAL_RECORD, 0, 0 ); response.accepted = TRUE; @@ -1695,27 +1803,39 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_INSTIT_ADDITIONAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&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 + * for publishing. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested, + * isGetPressureCalRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ BOOL handleDDGetPressureSensorCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_PRESSURE_SENSORS ) + if ( idx < NUM_OF_PRESSURE_SENSORS ) { isPublishRecordRequested[ NV_DD_DATA_CAL_PRESSURE_SENOSRS ] = TRUE; isGetPressureCalRequested[ idx ] = TRUE; @@ -1734,16 +1854,31 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); } return result; } +/*********************************************************************//** + * @brief + * The handleDDSetPressureSensorCalRecRequest function processes a + * request to update a pressure sensor calibration record. It validates + * the request format and sensor index, updates the calibration 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 handleDDSetPressureSensorCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; @@ -1759,14 +1894,14 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); - payloadPtr += sizeof(U32); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_PRESSURE_SENSORS ) + if ( idx < NUM_OF_PRESSURE_SENSORS ) { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_PRESSURE_SENOSRS, (U08*)&record, idx ); + setNVMRecord( NV_DD_DATA_CAL_PRESSURE_SENOSRS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.idx = idx; @@ -1788,27 +1923,39 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T ) ); return result; } +/*********************************************************************//** + * @brief + * The handleDDGetTemperatureSensorCalRecRequest function processes a + * request to publish a temperature sensor calibration record. It + * validates the request payload and sensor index before scheduling + * the record for publishing. + * @details \b Inputs: nvMExecSendRecordState + * @details \b Outputs: isPublishRecordRequested, + * isGetTempCalRequested + * @param message Pointer to the received message + * @return TRUE if the request was accepted otherwise FALSE + *************************************************************************/ BOOL handleDDGetTemperatureSensorCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_TEMPERATURE_SENSORS ) + if ( idx < NUM_OF_TEMPERATURE_SENSORS ) { isPublishRecordRequested[ NV_DD_DATA_CAL_TEMPERATURE_SENSORS ] = TRUE; isGetTempCalRequested[ idx ] = TRUE; @@ -1827,10 +1974,14 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); } @@ -1852,14 +2003,14 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U08)); - payloadPtr += sizeof(U08); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_TEMPERATURE_SENSORS ) + if ( idx < NUM_OF_TEMPERATURE_SENSORS ) { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_TEMPERATURE_SENSORS, (U08*)&record, idx ); + setNVMRecord( NV_DD_DATA_CAL_TEMPERATURE_SENSORS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.idx = idx; @@ -1881,7 +2032,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_TEMPERATURE_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T ) ); return result; @@ -1892,16 +2043,16 @@ BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_CONCENTRATE_PUMPS ) + if ( idx < NUM_OF_CONCENTRATE_PUMPS ) { isPublishRecordRequested[ NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD] = TRUE; isGetConcPumpCalRequested[ idx ] = TRUE; @@ -1920,10 +2071,14 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_CONC_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) ); } @@ -1945,14 +2100,14 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U08)); - payloadPtr += sizeof(U08); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_CONCENTRATE_PUMPS ) + if ( idx < NUM_OF_CONCENTRATE_PUMPS ) { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_CONCENTRATE_PUMPS_RECORD, (U08*)&record, idx ); + 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; @@ -1974,7 +2129,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_CONC_PUMP_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_LINEAR_CAL_REC_PAYLOAD_T ) ); return result; @@ -1983,7 +2138,7 @@ BOOL handleDDGetD12PumpCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -1996,10 +2151,11 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_D12_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T ) ); } + return result; } @@ -2018,7 +2174,7 @@ { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_D12_PUMP_RECORD, (U08*)&record, 0 ); + 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; @@ -2035,7 +2191,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_D12_PUMP_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_D12_PUMP_CAL_REC_PAYLOAD_T ) ); return result; @@ -2044,7 +2200,7 @@ BOOL handleDDGetD48PumpCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -2057,7 +2213,7 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_D48_PUMP_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T ) ); } @@ -2079,7 +2235,7 @@ { memcpy( &record, payloadPtr, recordSize ); record.d48DialysatePump.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_D48_PUMP_RECORD, (U08*)&record, 0 ); + 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; @@ -2096,7 +2252,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_D48_PUMP_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_D48_PUMP_CAL_REC_PAYLOAD_T ) ); return result; @@ -2107,16 +2263,16 @@ BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_ACID_TYPE ) + if ( idx < NUM_OF_ACID_TYPE ) { isPublishRecordRequested[ NV_DD_DATA_CAL_ACID_CONCENTREATES] = TRUE; isGetAcidConcCalRequested[ idx ] = TRUE; @@ -2135,10 +2291,14 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_ACID_CONC_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_ACID_CONC_CAL_REC_PAYLOAD_T ) ); } @@ -2160,14 +2320,14 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U08)); - payloadPtr += sizeof(U08); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_ACID_TYPE ) + if ( idx < NUM_OF_ACID_TYPE ) { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_ACID_CONCENTREATES, (U08*)&record, idx ); + setNVMRecord( NV_DD_DATA_CAL_ACID_CONCENTREATES, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.idx = idx; @@ -2189,7 +2349,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_ACID_CONC_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_ACID_CONC_CAL_REC_PAYLOAD_T ) ); return result; @@ -2200,16 +2360,16 @@ BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_BICARB_TYPE ) + if ( idx < NUM_OF_BICARB_TYPE ) { isPublishRecordRequested[ NV_DD_DATA_CAL_BICARB_CONCENTRATES] = TRUE; isGetBicarbConcCalRequested[ idx ] = TRUE; @@ -2228,10 +2388,14 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_BICARB_CONC_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_BICARB_CONC_CAL_REC_PAYLOAD_T ) ); } @@ -2253,14 +2417,14 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U08)); - payloadPtr += sizeof(U08); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_BICARB_TYPE ) + if ( idx < NUM_OF_BICARB_TYPE ) { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_BICARB_CONCENTRATES, (U08*)&record, idx ); + setNVMRecord( NV_DD_DATA_CAL_BICARB_CONCENTRATES, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.idx = idx; @@ -2282,7 +2446,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_BICARB_CONC_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_BICARB_CONC_CAL_REC_PAYLOAD_T ) ); return result; @@ -2291,7 +2455,7 @@ BOOL handleDDGetAccelSensorCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -2304,7 +2468,7 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T ) ); } @@ -2326,7 +2490,7 @@ { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_ACCELEROMETER_SENSOR, (U08*)&record, 0 ); + setNVMRecord( NV_DD_DATA_CAL_ACCELEROMETER_SENSOR, (U08*)&record, 0 ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.accepted = TRUE; @@ -2343,7 +2507,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_ACCEL_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_ACCEL_SENSOR_CAL_REC_PAYLOAD_T ) ); return result; @@ -2352,7 +2516,7 @@ BOOL handleDDGetBloodLeakSensorCalRecRequest( MESSAGE_T *message ) { BOOL result = FALSE; - DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { @@ -2365,7 +2529,7 @@ sendMessage( MSG_ID_DD_UI_NVM_GET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T ) ); } @@ -2387,7 +2551,7 @@ { memcpy( &record, payloadPtr, recordSize ); record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_BLOOD_LEAK_SENSOR, (U08*)&record, 0 ); + 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; @@ -2404,7 +2568,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_BLOOD_LEAK_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_BLOOD_LEAK_SENSOR_CAL_REC_PAYLOAD_T ) ); return result; @@ -2415,16 +2579,16 @@ BOOL result = FALSE; U08* payloadPtr = message->payload; U08 expectedPayloadLen = sizeof( U32 ); - DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T response; + DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T response = { 0 }; U32 idx; if ( NVM_SEND_RECORD_STATE_IDLE == nvMExecSendRecordState ) { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U32)); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); - if( idx < NUM_OF_CONDUCTIVITY_SENSORS ) + if ( idx < NUM_OF_CONDUCTIVITY_SENSORS ) { isPublishRecordRequested[ NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS ] = TRUE; isGetCondSensCalRequested[ idx ] = TRUE; @@ -2443,10 +2607,14 @@ else { response.rejectionReason = REQUEST_REJECT_REASON_NVM_JOB_QUEUE_BUSY; + } + //Send the rejection message + if ( FALSE == result ) + { sendMessage( MSG_ID_DD_UI_NVM_GET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08 *)&response, + (U08*)&response, sizeof( DD_NVM_GET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) ); } @@ -2468,17 +2636,15 @@ { if ( message->hdr.payloadLen == expectedPayloadLen ) { - memcpy( &idx, payloadPtr, sizeof(U08)); - payloadPtr += sizeof(U08); + memcpy( &idx, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); - if( idx < NUM_OF_CONDUCTIVITY_SENSORS ) + if ( idx < NUM_OF_CONDUCTIVITY_SENSORS ) { memcpy( &record, payloadPtr, recordSize ); - // TODO: Update calibrationTime to current timestamp published by UI. - record.calibrationTime = 0; record.crc = crc16( (U08*)&record, recordSize ); - setNVMMRecord( NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS, (U08*)&record, idx ); + setNVMRecord( NV_DD_DATA_CAL_CONDUCTIVITY_SENSORS, (U08*)&record, idx ); result = enqueueEraseAndWriteSector( NVM_CALIBRATION_RECORD ); sendNVEvent( NVM_CALIBRATION_RECORD, 0, 0 ); response.idx = idx; @@ -2500,7 +2666,7 @@ } sendMessage( MSG_ID_DD_UI_NVM_SET_CONDUCTIVITY_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08 *)&response, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&response, sizeof( DD_NVM_SET_CONDUCTIVITY_SENSOR_CAL_REC_PAYLOAD_T ) ); return result; Index: firmware/App/Services/NVRecordsDD.c =================================================================== diff -u -rc0855c6b4beeedc43b020c4e106d8e379de757d9 -r6d135d17d73d70a909f346bff2a9b14fec7d2478 --- firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision c0855c6b4beeedc43b020c4e106d8e379de757d9) +++ firmware/App/Services/NVRecordsDD.c (.../NVRecordsDD.c) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) @@ -1635,7 +1635,7 @@ * @param bufferAddress Pointer to the source data buffer * @return TRUE if the record was updated successfully otherwise FALSE *************************************************************************/ -BOOL setNVMMRecord( NV_DATA_T recType, U08* bufferAddress, U08 idx ) +BOOL setNVMRecord( NV_DATA_T recType, U08* bufferAddress, U08 idx ) { BOOL result = FALSE; U08* destPtr = NULL; Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -rac72b3fa86015b2c60c7687a4597dd4ae5c24dc8 -r6d135d17d73d70a909f346bff2a9b14fec7d2478 --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision ac72b3fa86015b2c60c7687a4597dd4ae5c24dc8) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) @@ -338,7 +338,7 @@ BOOL getNVMRecord( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ); -BOOL setNVMMRecord(NV_DATA_T recType, U08* bufferAddress, U08 idx); +BOOL setNVMRecord(NV_DATA_T recType, U08* bufferAddress, U08 idx); void sendNVEvent( NVM_RECORD_TYPE_T recType, U32 d1, U32 d2 ); void updateRecordCRC( NVM_RECORD_TYPE_T recType );