Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r1a5aa1dff6978966ecda860b09c07a84e80399fe -r981de1f5228152ec6877aceae3d66ebf5efc7101 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1a5aa1dff6978966ecda860b09c07a84e80399fe) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 981de1f5228152ec6877aceae3d66ebf5efc7101) @@ -531,6 +531,34 @@ return result; } + +/*********************************************************************//** + * @brief + * The sendDGChangeValveSettingCommand function constructs a DG change valve + * setting message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG change valve setting msg constructed and queued. + * @param valveSettingCmd valve setting ID to change to + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGChangeValveSettingCommand( U32 valveSettingCmd ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CHANGE_VALVE_SETTING_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &valveSettingCmd, 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_DG, ACK_REQUIRED ); + + return result; +} /*********************************************************************//** * @brief @@ -686,8 +714,11 @@ if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) { + DG_CMD_RESPONSE_T dgCmdResponse; + result = TRUE; - handleDGCommandResponse( messagePtr->payload ); + memcpy( &dgCmdResponse, messagePtr->payload, sizeof( DG_CMD_RESPONSE_T ) ); + handleDGCommandResponse( &dgCmdResponse ); } sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); @@ -1734,56 +1765,6 @@ /*********************************************************************//** * @brief - * The handleUIUserEndTreatmentRequest function handles a treatment end - * request message from the UI. - * @details Inputs: none - * @details 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 - * @details 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_TREATMENT_END_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 Inputs: none @@ -4053,71 +4034,4 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestHDCalibrationDataRequest function handles a request for - * HD calibration data. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( 0 == message->hdr.payloadLen ) - { - CALIBRATION_DATA_T cal; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Get calibration data - result = getCalibrationData( &cal ); - if ( TRUE == result ) - { - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; - msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); - - memcpy( payloadPtr, &cal, sizeof( CALIBRATION_DATA_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_HD_BROADCAST, ACK_NOT_REQUIRED ); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestEraseHDCalibrationDataRequest function handles a request for - * HD calibration data erasure. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 key; - - memcpy( &key, message->payload, sizeof(U32) ); - - result = testResetCalibrationData( key ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /**@}*/