Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r79ad3aec7dd37a8acc7ab2391dc9dd806cb9e5cd -ra6684f5a4c807bf27996b9521c6d0f9f7c85d9f5 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 79ad3aec7dd37a8acc7ab2391dc9dd806cb9e5cd) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a6684f5a4c807bf27996b9521c6d0f9f7c85d9f5) @@ -853,6 +853,46 @@ return result; } +/*********************************************************************//** + * @brief + * The broadcastDGCalibrationRecord function sends out the DG calibration + * record. + * @details Inputs: none + * @details Outputs: DG calibration record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param calRcrdAddress: start address of the calibration record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGCalibrationRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* calRcrdAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SEND_CALIBRATION_DATA; + msg.hdr.payloadLen = sizeof( payloadCurrNum ) + sizeof( payloadTotalNum ) + sizeof( length ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( payloadCurrNum ) ); + payloadPtr += sizeof( payloadCurrNum ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( payloadTotalNum ) ); + payloadPtr += sizeof( payloadTotalNum ); + + memcpy( payloadPtr, &length, sizeof( length ) ); + payloadPtr += sizeof( length ); + + memcpy( payloadPtr, calRcrdAddress, length ); + + // 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_PC, ACK_NOT_REQUIRED ); + + return result; +} + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -2345,7 +2385,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -//*******************************************************************/ +/*********************************************************************//** +* @brief +* The handleROPumpTargetPressureOverride function handles a request +* to override the target RO pump pressure. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ void handleROPumpTargetPressureOverride( MESSAGE_T *message ) { BOOL result = FALSE; @@ -2365,17 +2413,63 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** +* @brief +* The handleSetDGCalibration function handles a request to set the DG +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ void handleSetDGCalibration( MESSAGE_T *message ) { - struct + BOOL status = FALSE; + U08* payloadPtr = message->payload; + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + memcpy(¤tMessage, payloadPtr, sizeof(currentMessage)); + payloadPtr += sizeof(currentMessage); + + memcpy(&totalMessages, payloadPtr, sizeof(totalMessages)); + payloadPtr += sizeof(totalMessages); + + memcpy(&payloadLength, payloadPtr, sizeof(payloadLength)); + payloadPtr += sizeof(payloadLength); + + status = setDGCalibrationRecord( currentMessage, totalMessages, payloadLength, payloadPtr ); + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** +* @brief +* The handleGetDGCalibration function handles a request to get the DG +* calibration data record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetDGCalibration( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) { - F32 offset; - F32 gain; - U32 time; - } test; + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + getDGCalibrationRecord(); + } + } - U32 dara = sizeof(test); - memcpy( &test, message->payload, sizeof(test)); + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /**@}*/