Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb0b3522f2bd0b5b20ecbfd53c8f55b0e646ffa11 -r101bf85b0b425e919b01b4b7fabcbd15fd5bbde5 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b0b3522f2bd0b5b20ecbfd53c8f55b0e646ffa11) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 101bf85b0b425e919b01b4b7fabcbd15fd5bbde5) @@ -1461,6 +1461,91 @@ /*********************************************************************//** * @brief + * The sendTreatmentStartResponseMsg function constructs a treatment start + * request response message to the UI and queues the msg for transmit on + * the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : Treatment start response msg constructed and queued. + * @param accepted T/F - request accepted? + * @param reason reason code if rejected + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentStartResponseMsg( BOOL accepted, U32 reason ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, 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_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleUIUserEndTreatmentRequest function handles a treatment end + * request message from the UI. + * @details + * Inputs : none + * Outputs : message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIUserEndTreatmentRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == 0 ) + { + result = userRequestEndTreatment(); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendTreatmentEndResponseMsg function constructs a treatment end + * request response message to the UI and queues the msg for transmit on + * the appropriate CAN channel. + * @details + * Inputs : none + * Outputs : Treatment end response msg constructed and queued. + * @param accepted T/F - request accepted? + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentEndResponseMsg( BOOL accepted ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &accepted, 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_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The handleTreatmentParametersFromUI function handles a treatment parameters * set and validate request message from the UI. * @details