Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r5109bb981cab2025fcb9de33e303d046085efa18 -r5e47cac9994e1e0f5b4cebbeb9994c7a2aa83096 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5109bb981cab2025fcb9de33e303d046085efa18) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5e47cac9994e1e0f5b4cebbeb9994c7a2aa83096) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Dara Navaei -* @date (last) 15-May-2023 +* @date (last) 31-May-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -36,6 +36,7 @@ #include "ModeHeatDisinfect.h" #include "ModeHeatDisinfectActiveCool.h" #include "ModeInitPOST.h" +#include "ModeROPermeateSample.h" #include "ModeStandby.h" #include "MsgQueues.h" #include "NVDataMgmt.h" @@ -575,14 +576,14 @@ /*********************************************************************//** * @brief - * The handleDGServiceScheduleRequest function handles a request for DG - * service information. + * The handleDGServiceScheduleRequestToUI function handles a request for DG + * service information to UI. * @details Inputs: none * @details Outputs: message handled, response constructed and queued for * transmit. * @return none *************************************************************************/ -void handleDGServiceScheduleRequest( MESSAGE_T *message ) +void handleDGServiceScheduleRequestToUI( MESSAGE_T *message ) { MESSAGE_T msg; DG_SERVICE_RECORD_T service; @@ -594,19 +595,19 @@ // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA_TO_UI; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); if ( 0 == message->hdr.payloadLen ) { - // Fill message payload memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); + service.serviceIntervalSeconds = ( 0 == service.lastServiceEpochDate ? 0 : service.serviceIntervalSeconds ); 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_HD, ACK_REQUIRED ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); } /*********************************************************************//** @@ -1606,7 +1607,7 @@ } // 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_HD, ACK_REQUIRED ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_REQUIRED ); } /*********************************************************************//** @@ -1789,7 +1790,121 @@ serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_UI, ACK_REQUIRED ); } +/************************************************************************* + * @brief + * The handleStartStopDGROPermeateSample function handles a request to + * start or stop DG RO permeate sample mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message: a pointer to the message to handle + * @return result + *************************************************************************/ +void handleStartStopDGROPermeateSample( MESSAGE_T* message ) +{ + BOOL status = FALSE; + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGROPermeateSample; + + memcpy( &startingDGROPermeateSample, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGROPermeateSample ) + { + status = startDGROPermeateSample(); + } + else + { + status = stopDGROPermeateSample(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); +} + +/*********************************************************************//** + * @brief + * The handleReceiveROPermeatSampleDispenseRequest function handles receiving + * the RO permeate sample dispense request + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleReceiveROPermeatSampleDispenseRequest( MESSAGE_T* message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 result; + + memcpy( &result, message->payload, sizeof(U32) ); + + setROPermeateSampleDispenseRequest( result ); + + status = TRUE; + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); +} + +/*********************************************************************//** + * @brief + * The sendROPermeateSampleDispenseReadyToHD function handles sending + * RO permeate sample dispense ready to HD + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void sendROPermeateSampleDispenseReadyToHD( void ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_RO_PERMEATE_SAMPLE_DISPENSE_READY_TO_HD; + msg.hdr.payloadLen = 0; + + // 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_HD, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The handleSendDGServiceRecordToHD function handles sending DG service + * record to HD upon request from HD + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSendDGServiceRecordToHD( MESSAGE_T* message ) +{ + MESSAGE_T msg; + DG_SERVICE_RECORD_T service; + U08 *payloadPtr = msg.payload; + + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_SERVICE_SCHEDULE_DATA_TO_HD; + msg.hdr.payloadLen = sizeof( DG_SERVICE_RECORD_T ); + + if ( 0 == message->hdr.payloadLen ) + { + memcpy( payloadPtr, &service, sizeof( DG_SERVICE_RECORD_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_2_HD, ACK_REQUIRED ); +} + + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -3773,6 +3888,7 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +#ifndef _RELEASE_ /*********************************************************************//** * @brief * The handleGetDGSoftwareConfigRecord function handles a request to get the DG @@ -3835,6 +3951,7 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } +#endif /*********************************************************************//** * @brief @@ -4739,4 +4856,28 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } +/*********************************************************************//** + * @brief + * The handleTestDGSetRecoverFromFaultModeSignal function handles a request to + * set the signal to recover from the fault mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestDGSetRecoverFromFaultModeSignal( MESSAGE_T* message ) +{ + BOOL status = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + status = TRUE; + + setRecoverFromFaultModeSignal(); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + /**@}*/