Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra9315539f527b92523b1598ff91e47db4d71dae2 -rbb7a4629cc96d96b6d1749c924e77886e0d64bcb --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a9315539f527b92523b1598ff91e47db4d71dae2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bb7a4629cc96d96b6d1749c924e77886e0d64bcb) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Dara Navaei -* @date (last) 02-Mar-2022 +* @date (last) 31-Mar-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -20,11 +20,13 @@ #include "reg_system.h" #include "Accel.h" +#include "Compatible.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "Fans.h" #include "FPGA.h" #include "Heaters.h" +#include "ModeFill.h" #include "ModeFlush.h" #include "ModeGenIdle.h" #include "ModeInitPOST.h" @@ -448,20 +450,24 @@ DG_VERSIONS_T payload; U08 *payloadPtr = msg.payload; - // populate payload - payload.major = (U08)DG_VERSION_MAJOR; - payload.minor = (U08)DG_VERSION_MINOR; - payload.micro = (U08)DG_VERSION_MICRO; - payload.build = (U16)DG_VERSION_BUILD; - getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); + if ( message->hdr.payloadLen == sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ) + sizeof( U32 ) ) + { + // populate payload + payload.major = (U08)DG_VERSION_MAJOR; + payload.minor = (U08)DG_VERSION_MINOR; + payload.micro = (U08)DG_VERSION_MICRO; + payload.build = (U16)DG_VERSION_BUILD; + payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_VERSION; - msg.hdr.payloadLen = sizeof( DG_VERSIONS_T ); + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_VERSION; + msg.hdr.payloadLen = sizeof( DG_VERSIONS_T ); - // fill message payload - memcpy( payloadPtr, &payload, sizeof( DG_VERSIONS_T ) ); + // fill message payload + memcpy( payloadPtr, &payload, sizeof( DG_VERSIONS_T ) ); + } // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); @@ -494,7 +500,7 @@ msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; // Fill message payload - memcpy( payloadPtr, &system.topLevelSN, MAX_TOP_LEVEL_SN_CHARS ); + memcpy( payloadPtr, &system.topLevelSN, sizeof( U08 ) * MAX_TOP_LEVEL_SN_CHARS ); payloadPtr += MAX_TOP_LEVEL_SN_CHARS; *payloadPtr = 0; @@ -521,17 +527,19 @@ getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); U08 *payloadPtr = msg.payload; + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + // Fill message payload + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + } - // Fill message payload - memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); } @@ -862,6 +870,41 @@ } /*********************************************************************//** +* @brief +* The handleStartStopDGFlush function handles a request to start or stop +* DG flush mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +BOOL handleStartStopDGFlush( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGFlush; + + memcpy( &startingDGFlush, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGFlush ) + { + result = startDGFlush(); + } + else + { + result = stopDGFlush(); + } + } + + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + +/*********************************************************************//** * @brief * The sendCommandResponseMsg function constructs a command response to HD * and queues the msg for transmit on the appropriate CAN channel. @@ -885,10 +928,6 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } -// *********************************************************************** -// **************** Message Handling Helper Functions ******************** -// *********************************************************************** - /*********************************************************************//** * @brief * The handleSwitchReservoirCmd function handles a switch reservoirs command @@ -1113,8 +1152,120 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleStartStopDGHeatDisinfect function handles a request start or + * stop DG heat disifect mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message: a pointer to the message to handle + * @return result + *************************************************************************/ +BOOL handleStartStopDGHeatDisinfect( MESSAGE_T *message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGHeatDisinfect; + + memcpy( &startingDGHeatDisinfect, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGHeatDisinfect ) + { + status = startDGHeatDisinfect(); + } + else + { + status = stopDGHeatDisinfect(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); + + return status; +} + /*********************************************************************//** * @brief + * The handleUIClockSyncRequest function handles a UI clock sync message. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleUIClockSyncRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U32 epoch; + + memcpy( &epoch, message->payload, sizeof( U32 ) ); + result = setRTCEpoch( epoch ); + if ( FALSE == result ) + { + rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; + } + } + else + { + rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Create a response message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_UI_SET_RTC_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payloadPtr, &result, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); +} + +/*********************************************************************//** +* @brief +* The handleDGPOSTResultRequest function handles a request to report DG +* POST results. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleDGPOSTResultRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + if ( TRUE == isPOSTCompleted() ) + { + status = TRUE; + if ( TRUE == isPOSTPassed() ) + { + result = TRUE; + } + sendPOSTFinalResult( result ); + } + } + // If can't respond to request, NAK the message + if ( status != TRUE ) + { + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + } +} + +/*********************************************************************//** + * @brief * The handleStartStopPrimaryHeater function handles a request start or * stop the primary heater * @details Inputs: none @@ -1148,11 +1299,82 @@ return result; } +/*********************************************************************//** +* @brief +* The handleStartStopDGChemicalDisinfect function handles a request to start +* or stop DG chemical disinfect mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +BOOL handleStartStopDGChemicalDisinfect( MESSAGE_T *message ) +{ + BOOL result = FALSE; + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGChemicalDisinfect; + + memcpy( &startingDGChemicalDisinfect, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGChemicalDisinfect ) + { + result = startDGChemicalDisinfect(); + } + else + { + result = stopChemicalDisinfect(); + } + } + + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleSetHDOperationMode function receives the HD operation modes data + * publish message. + * @details Inputs: none + * @details Outputs: none + * @param message a pointer to the message to handle + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSetHDOperationMode( MESSAGE_T *message ) +{ + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + // HD mode broadcast is operations mode and submode so 8 bytes + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + U32 mode; + + // NOTE: the HD operations modes broadcast message contains the mode and submode states + // In this case, only the mode is needed. The mode is received to check if HD is in treatment + // and therefore, DG can void the last disinfect. + memcpy( payloadPtr, &mode, sizeof( U32 ) ); + setHDOperationMode( mode ); + status = TRUE; + } + + return status; +} + + +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ + /*********************************************************************//** * @brief * The isTestingActivated function determines whether a tester has successfully @@ -2631,120 +2853,8 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* - * @brief - * The handleStartStopDGHeatDisinfect function handles a request start or - * stop DG heat disifect mode. - * @details Inputs: none - * @details Outputs: message handled - * @param message: a pointer to the message to handle - * @return result - *************************************************************************/ -BOOL handleStartStopDGHeatDisinfect( MESSAGE_T *message ) -{ - BOOL status = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGHeatDisinfect; - - memcpy( &startingDGHeatDisinfect, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGHeatDisinfect ) - { - status = startDGHeatDisinfect(); - } - else - { - status = stopDGHeatDisinfect(); - } - } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); - - return status; -} - /*********************************************************************//** - * @brief - * The handleUIClockSyncRequest function handles a UI clock sync message. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param messagePtr pointer to the message to handle. - * @return none - *************************************************************************/ -void handleUIClockSyncRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - U32 rejReason = REQUEST_REJECT_REASON_NONE; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - if ( message->hdr.payloadLen == sizeof( U32 ) ) - { - U32 epoch; - - memcpy( &epoch, message->payload, sizeof( U32 ) ); - result = setRTCEpoch( epoch ); - if ( FALSE == result ) - { - rejReason = REQUEST_REJECT_REASON_INVALID_DATE_OR_TIME; - } - } - else - { - rejReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - // Create a response message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_UI_SET_RTC_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); - memcpy( payloadPtr, &result, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); -} - -/*********************************************************************//** * @brief -* The handleDGPOSTResultRequest function handles a request to report DG -* POST results. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -void handleDGPOSTResultRequest( MESSAGE_T *message ) -{ - BOOL status = FALSE; - BOOL result = FALSE; - - if ( 0 == message->hdr.payloadLen ) - { - if ( TRUE == isPOSTCompleted() ) - { - status = TRUE; - if ( TRUE == isPOSTPassed() ) - { - result = TRUE; - } - sendPOSTFinalResult( result ); - } - } - // If can't respond to request, NAK the message - if ( status != TRUE ) - { - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); - } -} - -/*********************************************************************//** -* @brief * The handleSetDGCalibrationRecord function handles a request to set the DG * calibration data record. * @details Inputs: none @@ -2775,41 +2885,8 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } -/*********************************************************************//** -* @brief -* The handleStartStopDGFlush function handles a request to start or stop -* DG flush mode. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -BOOL handleStartStopDGFlush( MESSAGE_T *message ) -{ - BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGFlush; - memcpy( &startingDGFlush, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGFlush ) - { - result = startDGFlush(); - } - else - { - result = stopDGFlush(); - } - } - - // Respond to request - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - /*********************************************************************//** * @brief * The handleGetDGCalibrationRecord function handles a request to get the DG @@ -3131,41 +3208,6 @@ } /*********************************************************************//** -* @brief -* The handleStartStopDGChemicalDisinfect function handles a request to start -* or stop DG chemical disinfect mode. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -BOOL handleStartStopDGChemicalDisinfect( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - BOOL startingDGChemicalDisinfect; - - memcpy( &startingDGChemicalDisinfect, message->payload, sizeof(U32) ); - - if ( TRUE == startingDGChemicalDisinfect ) - { - result = startDGChemicalDisinfect(); - } - else - { - result = stopChemicalDisinfect(); - } - } - - // Respond to request - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); - - return result; -} - -/*********************************************************************//** * @brief * The handleTestBlockMessagesRequest function handles a request to * block transmission of specific message(s). @@ -3251,30 +3293,87 @@ /*********************************************************************//** * @brief - * The handleTestFansRPMAlarmStartTimeOverrideRequest function handles a - * request to override the fan RPM alarm start time. + * The handleTestFansRPMAlarmStartTimeOffsetRequest function handles a + * request to set the fans RPM alarm start time offset. * @details Inputs: none * @details Outputs: message handled - * @param message a pointer to the message to handle + * @param message : a pointer to the message to handle * @return none *************************************************************************/ -void handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( MESSAGE_T *message ) +void handleTestFansRPMAlarmStartTimeOffsetRequest( MESSAGE_T *message ) { + U32 rpmTimeOffset; + + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &rpmTimeOffset, message->payload, sizeof(U32) ); + + result = testSetFanRPMAlarmStartTimestamp( rpmTimeOffset ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestUsedAcidVolumeMLOverrideRequest function handles a + * request to override the acid volume. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestUsedAcidVolumeMLOverrideRequest( MESSAGE_T *message ) +{ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); + if ( FALSE == payload.reset ) + { + result = testSetUsedAcidVolumeMLOverride( payload.state.f32 ); + } + else + { + result = testResetUsedAcidVolumeMLOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} +/*********************************************************************//** +* The handleSetFansDutyCycleOverrideRequest function handles a +* request to override the fans duty cycle. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetFansDutyCycleOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + // verify payload length if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetFanRPMAlarmStartTimeOffsetOverride( payload.state.u32 ); + result = testSetFansDutyCycleOverride( payload.state.f32 ); } else { - result = testResetFanRPMAlarmStartTimeOffsetOverride(); + result = testResetFansDutyCycleOverride(); } } @@ -3284,30 +3383,29 @@ /*********************************************************************//** * @brief - * The handleSetFansDutyCycleOverrideRequest function handles a - * request to override the fans duty cycle. + * The handleTestUsedBicarbVolumeMLOverrideRequest function handles a + * request to override the used bicarb volume. * @details Inputs: none * @details Outputs: message handled - * @param message a pointer to the message to handle + * @param message : a pointer to the message to handle * @return none *************************************************************************/ -void handleSetFansDutyCycleOverrideRequest( MESSAGE_T *message ) +void handleTestUsedBicarbVolumeMLOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + // Verify payload length + if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); - + memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { - result = testSetFansDutyCycleOverride( payload.state.f32 ); + result = testSetUsedBicarbVolumeMLOverride( payload.state.f32 ); } else { - result = testResetFansDutyCycleOverride(); + result = testResetUsedBicarbVolumeMLOverride(); } } @@ -3378,4 +3476,138 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } +/*********************************************************************//** + * @brief + * The handleTestHDCommunicationStatusOverrideRequest function handles a request + * request to override the HD Communication Status. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestHDCommunicationStatusOverrideRequest(MESSAGE_T *message) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetHDCommunicationStatus(payload.state.u32); + } + else + { + result = testResetHDCommuncationStatus(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGUsageInfoRecord function handles a request to get the DG +* usage information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_USAGE_INFO_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetDGUsageInfoRecord function handles a request to set the DG +* information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGUsageInfoRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_USAGE_INFO_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The sendDGUsageInfoRecord function sends out the DG usage information record. + * @details Inputs: none + * @details Outputs: DG usage information record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param usageInfoAddress: start address of the susage information record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGUsageInfoRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* usageInfoAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_USAGE_INFO_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, usageInfoAddress, length ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + /**@}*/