Index: firmware/App/Services/NVMessagingDD.c =================================================================== diff -u -r6d135d17d73d70a909f346bff2a9b14fec7d2478 -r517909d3e696abaaa2927232f4bbafe8d7446ef5 --- firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 6d135d17d73d70a909f346bff2a9b14fec7d2478) +++ firmware/App/Services/NVMessagingDD.c (.../NVMessagingDD.c) (revision 517909d3e696abaaa2927232f4bbafe8d7446ef5) @@ -17,6 +17,7 @@ #include "Messaging.h" #include "NVJobQ.h" #include "NVMessagingDD.h" +#include "NVMsgQ.h" #include "NVRecordsDD.h" #include "OperationModes.h" #include "TaskGeneral.h" @@ -501,26 +502,50 @@ { SEND_RECORD_STATE_T state = NVM_SEND_RECORD_STATE_IDLE; - if ( TRUE == isPublishRecordRequested[ nvPublishRecordType ] ) +// if ( TRUE == isPublishRecordRequested[ nvPublishRecordType ] ) +// { +// recordToPublish = nvPublishRecordType; +// +// // Set the publish flag to FALSE +// isPublishRecordRequested[ recordToPublish ] = FALSE; +// +// // Time interval in between data to be sent. It is set to the interval count so on the first call +// // of the send calibration record function, the first packet of data is sent +// recordSendDataIntervalCounter = RECORD_DATA_SEND_INTERVAL_COUNT; +// +// state = NVM_SEND_RECORD_STATE_SEND; +// } +// +// nvPublishRecordType = ( NV_DATA_T )( nvPublishRecordType + 1 ); +// if ( nvPublishRecordType >= NUM_OF_NV_DD_DATA ) +// { +// nvPublishRecordType = NV_DD_DATA_SYSTEM_RECORD; +// } + + NVM_MSG_REQUEST_Q_T currentNVMsgRequest; + + if ( FALSE == isNVMsgRequestQueueEmpty() ) { - recordToPublish = nvPublishRecordType; + dequeueNVMsgRequest(); + currentNVMsgRequest = getCurrentNVMsgRequest(); - // Set the publish flag to FALSE - isPublishRecordRequested[ recordToPublish ] = FALSE; + if ( NVM_MSG_GET_RECORD_REQUEST == currentNVMsgRequest.requestType ) + { + recordToPublish = currentNVMsgRequest.recordType; + if ( TRUE == currentNVMsgRequest.isIndexed ) + { + sendCalIdx = currentNVMsgRequest.idx; + } + } + // Time interval in between data to be sent. It is set to the interval count so on the first call // of the send calibration record function, the first packet of data is sent recordSendDataIntervalCounter = RECORD_DATA_SEND_INTERVAL_COUNT; state = NVM_SEND_RECORD_STATE_SEND; } - nvPublishRecordType = ( NV_DATA_T )( nvPublishRecordType + 1 ); - if ( nvPublishRecordType >= NUM_OF_NV_DD_DATA ) - { - nvPublishRecordType = NV_DD_DATA_SYSTEM_RECORD; - } - return state; } @@ -877,43 +902,31 @@ DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T payload; DD_PRES_SENSORS_CAL_RECORD_T record; - // Check if record of current sensor index was requested - if ( TRUE == isGetPressureCalRequested[ sendCalIdx ] ) + // Get the record + if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_PRESSURE_SENOSRS, + (U08*)&record, + sizeof( DD_PRES_SENSORS_CAL_RECORD_T ), + NUM_OF_PRESSURE_SENSORS, + ALARM_ID_DD_NVM_INVALID_CAL_PRESSURE_SENSOR ) ) { - // Get the record - if ( TRUE == getNVMRecord( NV_DD_DATA_CAL_PRESSURE_SENOSRS, - (U08*)&record, - sizeof( DD_PRES_SENSORS_CAL_RECORD_T ), - NUM_OF_PRESSURE_SENSORS, - ALARM_ID_DD_NVM_INVALID_CAL_PRESSURE_SENSOR ) ) - { - payload.accepted = TRUE; - payload.rejectionReason = 0; - payload.idx = sendCalIdx; - payload.data = record.pressureSensors[ sendCalIdx ]; + payload.accepted = TRUE; + payload.rejectionReason = 0; + payload.idx = sendCalIdx; + payload.data = record.pressureSensors[ sendCalIdx ]; - // Send the record - sendMessage( MSG_ID_DD_UI_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, - COMM_BUFFER_OUT_CAN_DD_BROADCAST, - (U08*)&payload, - ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); - } + // Send the record + sendMessage( MSG_ID_DD_UI_NVM_GET_PRESSURE_SENSOR_CAL_RECORD_RESPONSE, + COMM_BUFFER_OUT_CAN_DD_BROADCAST, + (U08*)&payload, + ( sizeof( DD_NVM_GET_LINEAR_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } - sendCalIdx = sendCalIdx + 1; + // Clear the publishing flags + recordToPublish = NUM_OF_NV_DD_DATA; - if ( sendCalIdx >= NUM_OF_PRESSURE_SENSORS ) - { - // Reset Sensor Index - sendCalIdx = 0; + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; - // Clear the publishing flags - recordToPublish = NUM_OF_NV_DD_DATA; - - // Move to Send Idle State - state = NVM_SEND_RECORD_STATE_IDLE; - } - return state; } @@ -1054,8 +1067,15 @@ COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&payload, ( sizeof( DD_NVM_GET_D12_PUMP_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); + } + // Clear the publishing flags + recordToPublish = NUM_OF_NV_DD_DATA; + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + return state; } @@ -1090,6 +1110,12 @@ ( sizeof( DD_NVM_GET_D48_PUMP_CAL_REC_PAYLOAD_T ) - sizeof( U16 ) ) ); } + // Clear the publishing flags + recordToPublish = NUM_OF_NV_DD_DATA; + + // Move to Send Idle State + state = NVM_SEND_RECORD_STATE_IDLE; + return state; } @@ -1837,8 +1863,14 @@ if ( idx < NUM_OF_PRESSURE_SENSORS ) { - isPublishRecordRequested[ NV_DD_DATA_CAL_PRESSURE_SENOSRS ] = TRUE; - isGetPressureCalRequested[ idx ] = TRUE; + NVM_MSG_REQUEST_Q_T newRequest; + + newRequest.requestType = NVM_MSG_GET_RECORD_REQUEST; + newRequest.recordType = NV_DD_DATA_CAL_PRESSURE_SENOSRS; + newRequest.isIndexed = TRUE; + newRequest.idx = idx; + enqueueNVMsgRequest( newRequest ); + result = TRUE; } else