Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -ra2c3d3a057ff491401d8507ae15e87d741e5ea65 -r4b25bf00656b9067a13541014fa1333386a7ed95 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a2c3d3a057ff491401d8507ae15e87d741e5ea65) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4b25bf00656b9067a13541014fa1333386a7ed95) @@ -8,7 +8,7 @@ * @file SystemCommMessages.c * * @author (last) Dara Navaei -* @date (last) 03-Nov-2022 +* @date (last) 21-Nov-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -828,6 +828,35 @@ } /*********************************************************************//** + * @brief + * The handleDGScheduledRunsRequest function handles a request for DG + * scheduled runs information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none + *************************************************************************/ +void handleDGScheduledRunsRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + DG_SCHEDULED_RUN_RECORD_T scheduledService; + + // 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_SRR_RECORD, (U08*)&scheduledService, sizeof( DG_SCHEDULED_RUN_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SCHEDULED_RUNS_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + // TODO this message is for Phase 1B. + + // 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 ); +} + +/*********************************************************************//** * @brief * The handleStartStopDGFlush function handles a request to start or stop * DG flush mode. @@ -1434,6 +1463,44 @@ } /*********************************************************************//** +* @brief +* The handleServiceModeRequest function handles a request to enter service +* mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleServiceModeRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + DG_OP_MODE_T currentMode = getCurrentOperationMode(); + REQUEST_REJECT_REASON_CODE_T reject; + + if ( 0 == message->hdr.payloadLen ) + { + if ( ( DG_MODE_STAN == currentMode ) || ( DG_MODE_FAUL == currentMode ) ) + { + status = TRUE; + requestNewOperationMode( DG_MODE_SERV ); + reject = REQUEST_REJECT_REASON_NONE; + } + else + { + reject = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; + } + } + else + { + reject = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + sendServiceModeResponse( status, (U32)reject ); +} + +/*********************************************************************//** * @brief * The handleHDRequestDGUsageInfo function handles a request for DG * usage information. @@ -1451,7 +1518,7 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_USAGE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( BOOL ); + msg.hdr.payloadLen = sizeof( DG_USAGE_INFO_RECORD_T ); // 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 @@ -1460,18 +1527,42 @@ if ( 0 == message->hdr.payloadLen ) { // Fill message payload - memcpy( payloadPtr, &usageInfo.lastHeatDisDateEpoch, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &usageInfo.lastChemicalDisDateEpoch, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &usageInfo.isDisinfected, sizeof( BOOL ) ); + memcpy( payloadPtr, &usageInfo, sizeof( DG_USAGE_INFO_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 ); } +/*********************************************************************//** + * @brief + * The handleCpldStatusRequest function handles a CPLD Status request message. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleCpldStatusRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + CPLD_STATUS_T payload; + U08 *payloadPtr = msg.payload; + // populate payload + getCPLDStatus( &payload ); + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CPLD_STATUS; + msg.hdr.payloadLen = sizeof( CPLD_STATUS_T ); + + // fill message payload + memcpy( payloadPtr, &payload, sizeof( CPLD_STATUS_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 ); +} + + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -3785,44 +3876,6 @@ } /*********************************************************************//** -* @brief -* The handleServiceModeRequest function handles a request to enter service -* mode. -* @details Inputs: none -* @details Outputs: message handled -* @param message a pointer to the message to handle -* @return none -*************************************************************************/ -void handleServiceModeRequest( MESSAGE_T *message ) -{ - BOOL status = FALSE; - DG_OP_MODE_T currentMode = getCurrentOperationMode(); - REQUEST_REJECT_REASON_CODE_T reject; - - if ( 0 == message->hdr.payloadLen ) - { - if ( ( DG_MODE_STAN == currentMode ) || ( DG_MODE_FAUL == currentMode ) ) - { - status = TRUE; - requestNewOperationMode( DG_MODE_SERV ); - reject = REQUEST_REJECT_REASON_NONE; - } - else - { - reject = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; - } - } - else - { - reject = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); - sendServiceModeResponse( status, (U32)reject ); -} - -/*********************************************************************//** * @brief * The sendServiceModeResponse function sends out the DG response to a * UI request to go to service mode. @@ -3855,34 +3908,6 @@ /*********************************************************************//** * @brief - * The handleCpldStatusRequest function handles a CPLD Status request message. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleCpldStatusRequest( MESSAGE_T *message ) -{ - MESSAGE_T msg; - CPLD_STATUS_T payload; - U08 *payloadPtr = msg.payload; - - // populate payload - getCPLDStatus( &payload ); - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_CPLD_STATUS; - msg.hdr.payloadLen = sizeof( CPLD_STATUS_T ); - - // fill message payload - memcpy( payloadPtr, &payload, sizeof( CPLD_STATUS_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 ); -} - -/*********************************************************************//** - * @brief * The handleTestDrainPumpMeasuredCurrentOverride function handles a request * to override the drain pump measured current * @details Inputs: none @@ -3965,11 +3990,11 @@ memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetROPumpMeasuredFeedbackVoltageOverride( payload.state.f32 ); + result = testSetROPumpMeasuredFeedbackDutyCycleOverride( payload.state.f32 ); } else { - result = testResetROPumpMeasuredFeedbackVoltageOverride(); + result = testResetROPumpMeasuredFeedbackDutyCycleOverride(); } }