Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r056bb7c3e42a6c56e10ff75f69aa1d7b9e5c8af8 -r9fcd1ad071bcce7a592833367c103e235e49654f --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 056bb7c3e42a6c56e10ff75f69aa1d7b9e5c8af8) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 9fcd1ad071bcce7a592833367c103e235e49654f) @@ -109,9 +109,9 @@ { MSG_ID_FW_VERSIONS_REQUEST, &handleVersionRequestMessage }, { MSG_ID_UI_CHECK_IN, &handleUICheckIn }, { MSG_ID_DD_OP_MODE_DATA, &setDDOpMode }, + { MSG_ID_UI_VERSION_INFO_RESPONSE, &handleUIVersionResponse }, { MSG_ID_DD_GEN_DIALYSATE_MODE_DATA, &setDialysateData }, { MSG_ID_DD_PRESSURES_DATA, &setDialysatePressure }, - { MSG_ID_OFF_BUTTON_PRESS_REQUEST, &handleOffButtonConfirmMsgFromUI }, { MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE, &validateAndSetTreatmentParameters }, { MSG_ID_UI_INITIATE_TREATMENT_WORKFLOW, &signalUserInitiateTreatment }, { MSG_ID_UI_UF_PAUSE_RESUME_REQUEST, &signalPauseResumeUF }, @@ -224,7 +224,6 @@ static MsgFuncPtr getMsgHandler( U16 msgID ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); /*********************************************************************//** * @brief @@ -383,7 +382,7 @@ * @param ack TRUE to ACK, FALSE to NAK * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) +BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) { BOOL result; MESSAGE_T msg; @@ -510,59 +509,6 @@ return result; } -/*********************************************************************//** - * @brief - * The handleOffButtonConfirmMsgFromUI function handles a response to an - * off button message to the UI. - * @details \b Inputs: none - * @details \b Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -BOOL handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) -{ - OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T payload; - - if ( message->hdr.payloadLen == sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ) - { - memcpy( &payload, message->payload, sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ); - userConfirmOffButton( payload.confirmed ); - } - return TRUE; -} - -/*********************************************************************//** - * @brief - * The handleUIConfirmationResponse function handles a UI response for - * confirmation request. - * @details \b Inputs: none - * @details \b Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -BOOL handleUIConfirmationResponse( MESSAGE_T *message ) -{ - U08* payloadPtr = message->payload; - - if ( message->hdr.payloadLen == 2 * sizeof(U32) ) - { - U32 request_id; - U32 status; - - memcpy( &request_id, payloadPtr, sizeof(U32) ); - payloadPtr += sizeof(U32); - memcpy( &status, payloadPtr, sizeof(U32) ); - - if ( ( CONFIRMATION_REQUEST_STATUS_REJECTED == status ) || ( CONFIRMATION_REQUEST_STATUS_ACCEPTED == status ) ) - { - setConfirmationRequestStatus( (GENERIC_CONFIRM_ID_T)request_id, (CONFIRMATION_REQUEST_STATUS_T)status ); - } - } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); - return TRUE; -} - // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** @@ -615,28 +561,79 @@ * @param prompt 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 prompt ) +BOOL sendOffButtonMsgToUI( GENERIC_CONFIRM_COMMAND_T prompt ) { - BOOL result; - MESSAGE_T msg; UI_OFF_BUTTON_RESPONSE_PAYLOAD_T cmd; - + MSG_ID_T msgID = MSG_ID_TD_UI_CONFIRMATION_REQUEST; cmd.userRequest = prompt; + U08 len = 1; + switch ( prompt ) + { + case GENERIC_CONFIRM_CMD_REQUEST_OPEN: + msgID = MSG_ID_TD_POWER_OFF_REQUEST; + break; + case GENERIC_CONFIRM_CMD_TIMEOUT_CLOSE: + case GENERIC_CONFIRM_CMD_REJECT: + case GENERIC_CONFIRM_CMD_ACCEPT_CLOSE: + msgID = MSG_ID_TD_UI_CONFIRMATION_REQUEST; + len = 4; + break; + default: + break; + } + // Use the generic send helper for transmission. + return sendMessage( msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08 *)&cmd, len ); +} +/*********************************************************************//** + * @brief + * The sendUIVersionRequest function constructs a UI version request msg + * to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details /b Inputs: none + * @details /b Outputs: UI version request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUIVersionRequest( void ) +{ + BOOL result; + MESSAGE_T msg; + // Create a message record blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS_REQUEST; - msg.hdr.payloadLen = sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ); + msg.hdr.msgID = MSG_ID_TD_UI_VERSION_INFO_REQUEST; + msg.hdr.payloadLen = 0; - memcpy( &msg.payload, &cmd, sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ) ); - // 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_TD_2_UI, ACK_REQUIRED ); return result; } +/*********************************************************************//** + * @brief + * The sendRequestForDDResendAlarms function sends out the TD request for + * DG re-send all active alarms. + * @details Inputs: none + * @details Outputs: DD alarms re-send request msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendRequestForDDResendAlarms( void ) +{ + BOOL result; + MESSAGE_T msg; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_TD_DD_ALARMS_REQUEST; + msg.hdr.payloadLen = 0; + + // 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_TD_2_DD, ACK_REQUIRED ); + + return result; +} + + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -786,25 +783,16 @@ *************************************************************************/ BOOL sendPOSTTestResult( TD_POST_STATE_T test, BOOL passed ) { - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + + U08 payload[ sizeof( BOOL ) + sizeof( U32 ) ]; U32 testID = (U32)test; - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TD_POST_SINGLE_TEST_RESULT; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + memcpy( payload, &passed, sizeof( BOOL ) ); + memcpy( &payload[ sizeof( BOOL ) ], &testID, sizeof( U32 ) ); - memcpy( payloadPtr, &passed, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &testID, sizeof( U32) ); + // Use the generic send helper for transmission. + return sendMessage( MSG_ID_TD_POST_SINGLE_TEST_RESULT, COMM_BUFFER_OUT_CAN_TD_BROADCAST, payload, sizeof( payload ) ); - // 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_TD_BROADCAST, ACK_REQUIRED ); - - return result; - } /*********************************************************************//** @@ -818,21 +806,8 @@ *************************************************************************/ BOOL sendPOSTFinalResult( BOOL passed ) { - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TD_POST_FINAL_TEST_RESULT; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &passed, sizeof( BOOL ) ); - - // 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_TD_BROADCAST, ACK_REQUIRED ); - - return result; + // Use the generic send helper for transmission. + return sendMessage( MSG_ID_TD_POST_FINAL_TEST_RESULT, COMM_BUFFER_OUT_CAN_TD_BROADCAST, (U08 *)&passed, sizeof( BOOL ) ); } /*********************************************************************//**