Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r4b25bf00656b9067a13541014fa1333386a7ed95 -r35179cc5895f6b7b9b1f8338754836898514a14e --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4b25bf00656b9067a13541014fa1333386a7ed95) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 35179cc5895f6b7b9b1f8338754836898514a14e) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Dara Navaei -* @date (last) 21-Nov-2022 +* @date (last) 21-Dec-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -28,9 +28,12 @@ #include "FlowSensors.h" #include "FPGA.h" #include "Heaters.h" +#include "ModeChemicalDisinfect.h" #include "ModeFill.h" #include "ModeFlush.h" #include "ModeGenIdle.h" +#include "ModeHeatDisinfect.h" +#include "ModeHeatDisinfectActiveCool.h" #include "ModeInitPOST.h" #include "ModeStandby.h" #include "MsgQueues.h" @@ -1382,6 +1385,41 @@ } /*********************************************************************//** +* @brief +* The handleStartStopDGChemicalDisinfectFlush function handles a request to start +* or stop DG chemical disinfect flush mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +BOOL handleStartStopDGChemicalDisinfectFlush( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(BOOL) ) + { + BOOL startingDGChemicalDisinfectFlush; + + memcpy( &startingDGChemicalDisinfectFlush, message->payload, sizeof(BOOL) ); + + if ( TRUE == startingDGChemicalDisinfectFlush ) + { + result = startDGChemicalDisinfectFlush(); + } + else + { + result = stopChemicalDisinfectFlush(); + } + } + + // Respond to request + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); + + return result; +} + +/*********************************************************************//** * @brief * The handleTestSetOpModeRequest function handles a request to set the * DG operation mode. @@ -1536,6 +1574,90 @@ /*********************************************************************//** * @brief + * The sendServiceModeResponse function sends out the DG response to a + * UI request to go to service mode. + * @details Inputs: none + * @details Outputs: Service mode request response msg constructed and queued + * @param accepted TRUE if request was accepted, FALSE if not + * @param rejCode Reject reason code explaining why request was rejected + * @return none + *************************************************************************/ +BOOL sendServiceModeResponse( BOOL accepted, U32 rejCode ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_RESPONSE_SERVICE_MODE_REQUEST; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejCode, 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_HD, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleSetDGServiceTime function sets the DG service time once the + * command is received from UI + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetDGServiceTime( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( 0 == message->hdr.payloadLen ) + { + result = setServiceTime(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_UI, result ); +} + +/************************************************************************* + * @brief + * The handleStartStopDGHeatDisinfectActiveCool function handles a request + * start or stop DG heat disinfect active cool mode. + * @details Inputs: none + * @details Outputs: message handled + * @param message: a pointer to the message to handle + * @return result + *************************************************************************/ +void handleStartStopDGHeatDisinfectActiveCool( MESSAGE_T* message ) +{ + BOOL status = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + BOOL startingDGHeatDisinfectActiveCool; + + memcpy( &startingDGHeatDisinfectActiveCool, message->payload, sizeof(U32) ); + + if ( TRUE == startingDGHeatDisinfectActiveCool ) + { + status = startDGHeatDisinfectActiveCool(); + } + else + { + status = stopDGHeatDisinfectActiveCool(); + } + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, status ); +} + +/*********************************************************************//** + * @brief * The handleCpldStatusRequest function handles a CPLD Status request message. * @details Inputs: none * @details Outputs: message handled @@ -2769,13 +2891,13 @@ result = TRUE; memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); - if ( ( BOOL )payload.state.u32 ) + if ( TRUE == ( BOOL )payload.state.u32 ) { requestConcentratePumpOn( ( CONCENTRATE_PUMPS_T )payload.index ); } else { - requestConcentratePumpOff( ( CONCENTRATE_PUMPS_T )payload.index ); + requestConcentratePumpOff( ( CONCENTRATE_PUMPS_T )payload.index, NO_PARK_CONC_PUMPS ); } } @@ -3041,16 +3163,19 @@ U32 totalMessages; U32 payloadLength; - memcpy(¤tMessage, payloadPtr, sizeof(U32)); - payloadPtr += sizeof(U32); + 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(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); - memcpy(&payloadLength, payloadPtr, sizeof(U32)); - payloadPtr += sizeof(U32); + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); - status = receiveRecordFromDialin( NVDATAMGMT_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_CALIBRATION_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -3100,16 +3225,19 @@ U32 totalMessages; U32 payloadLength; - memcpy(¤tMessage, payloadPtr, sizeof(U32)); - payloadPtr += sizeof(U32); + 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(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); - memcpy(&payloadLength, payloadPtr, sizeof(U32)); - payloadPtr += sizeof(U32); + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); - status = receiveRecordFromDialin( NVDATAMGMT_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + status = receiveRecordFromDialin( NVDATAMGMT_SYSTEM_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); @@ -3186,7 +3314,7 @@ U32 totalMessages; U32 payloadLength; - if ( 0 == message->hdr.payloadLen ) + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) { memcpy(¤tMessage, payloadPtr, sizeof(U32)); payloadPtr += sizeof(U32); @@ -3778,30 +3906,6 @@ /*********************************************************************//** * @brief -* The handleResendAllAlarmsCommand function handles a request to re-send -* all active DG alarms. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -void handleResendAllAlarmsCommand( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - // verify payload length - if ( 0 == message->hdr.payloadLen ) - { - handleResendActiveAlarmsRequest(); - result = TRUE; - } - - // 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 @@ -3876,37 +3980,144 @@ } /*********************************************************************//** - * @brief - * The sendServiceModeResponse function sends out the DG response to a - * UI request to go to service mode. - * @details Inputs: none - * @details Outputs: Service mode request response msg constructed and queued - * @param accepted TRUE if request was accepted, FALSE if not - * @param rejCode Reject reason code explaining why request was rejected - * @return none - *************************************************************************/ -BOOL sendServiceModeResponse( BOOL accepted, U32 rejCode ) +* @brief +* The handleResendAllAlarmsCommand function handles a request to re-send +* all active DG alarms. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleResendAllAlarmsCommand( MESSAGE_T *message ) { - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + BOOL result = FALSE; - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_RESPONSE_SERVICE_MODE_REQUEST; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + handleResendActiveAlarmsRequest(); + result = TRUE; + } - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &rejCode, sizeof( U32 ) ); + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} - // 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_HD, ACK_REQUIRED ); +/*********************************************************************//** +* @brief +* The handleTestDGNVRecordCRCOverride function handles a request to override +* the selected NV record's CRC. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGNVRecordCRCOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; - return result; + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + result = testSetNVRecordCRCOverride( payload.index, (U16)payload.state.u32 ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /*********************************************************************//** +* The handleTestDGConcPumpParkStatusOverrideRequest function handles a +* request to override the parked status of a given concentrate pump. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGConcPumpParkStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + + if ( FALSE == payload.reset ) + { + result = testSetConcentratePumpParkedOverride( payload.index, (U16)payload.state.u32 ); + } + else + { + result = testResetConcentratePumpParkedOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* The handleTestDGConcPumpParkFaultStatusOverrideRequest function handles a +* request to override the park faulted status of a given concentrate pump. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGConcPumpParkFaultStatusOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + + if ( FALSE == payload.reset ) + { + result = testSetConcentratePumpParkCmdFaultedOverride( payload.index, (U16)payload.state.u32 ); + } + else + { + result = testResetConcentratePumpParkCmdFaultedOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* The handleTestDGConcPumpParkCommandRequest function handles a command +* to park a given concentrate pump. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestDGConcPumpParkCommandRequest( MESSAGE_T *message ) +{ + U32 pumpIdx; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + memcpy( &pumpIdx, message->payload, sizeof( U32 ) ); + + result = testSetConcentratePumpParkCommand( pumpIdx ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleTestDrainPumpMeasuredCurrentOverride function handles a request * to override the drain pump measured current