Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rda397faac84255cf064e0dc5f52b81a869dab6c2 -ra504d6899e709d7432af9c055db1bd1fe340d032 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision da397faac84255cf064e0dc5f52b81a869dab6c2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision a504d6899e709d7432af9c055db1bd1fe340d032) @@ -34,6 +34,13 @@ #include "Valves.h" #include "WatchdogMgmt.h" #include "SystemCommMessages.h" +#include "SafetyShutdown.h" +#include "Utilities.h" +#include "SystemComm.h" +#include "RTC.h" +#include "LoadCell.h" +#include "TemperatureSensors.h" +#include "Heaters.h" // ********** private definitions ********** @@ -100,6 +107,13 @@ U32 targetTrimmerHeaterTemp; } TARGET_TEMPS_PAYLOAD_T; +typedef struct +{ + U32 mainPrimayHeaterDC; + U32 smallPrimaryHeaterDC; + U32 trimmerHeaterDC; +} HEATERS_DATA_T; + #pragma pack(pop) // ********** private data ********** @@ -453,6 +467,41 @@ /************************************************************************* * @brief + * The broadcastHeatersData function sends out DG heaters data + * @details + * Inputs : heaters data + * Outputs : heatears data msg constructed and queued + * @param mainPrimaryDC : main primary heater duty cycle + * @param smallPrimaryDC : small primary heater duty cycle + * @param trimmerDC : trimmer heater duty cycle + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastHeatersData ( U32 mainPrimaryDC, U32 smallPrimaryDC, U32 trimmerDC ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + HEATERS_DATA_T payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_HEATERS_DATA; + msg.hdr.payloadLen = sizeof( HEATERS_DATA_T ); + + payload.mainPrimayHeaterDC = mainPrimaryDC; + payload.smallPrimaryHeaterDC = smallPrimaryDC; + payload.trimmerHeaterDC = trimmerDC; + + memcpy( payloadPtr, &payload, sizeof( HEATERS_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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/************************************************************************* + * @brief * The broadcastROPumpData function sends out RO pump data. * @details * Inputs : none @@ -591,6 +640,34 @@ return result; } +/************************************************************************* + * @brief + * The broadcastTemperatureSensorsData function sends out DG temperature + * sensors data + * Inputs : heaters data + * Outputs : temperatur sensors data msg constructed and queued + * @param sensorsValue : sensors value array + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastTemperatureSensorsData ( U08 *sensorsValue, U32 byteLength ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_TEMPERATURE_DATA; + msg.hdr.payloadLen = byteLength; + + memcpy( payloadPtr, sensorsValue, byteLength ); + + // 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_DG_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -954,6 +1031,59 @@ DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestAlarmStateOverrideRequest, testSetAlarmStateOverride, testResetAlarmStateOverride ) /************************************************************************* +<<<<<<< HEAD +======= + * @brief + * The handleTestLoadCellOverrideRequest function handles a request to \n + * override the value read from the given load cell. + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestLoadCellOverrideRequest, testSetLoadCellOverride, testResetLoadCellOverride ) + +/************************************************************************* + * @brief + * The handleTestTemperatureSensorsOverrideRequest function handles a + * request to override a temperatures sensor's value + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( BOOL, handleTestTemperatureSensorsOverrideRequest, \ + testSetMeasuredTemperatureOverride, testResetMeasuredTemperatureOverride ) + +/************************************************************************* +* @brief +* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles \n +* a request to override the publish interval of temperature sensors data +* @details +* Inputs : none +* Outputs : message handled +* @param message : a pointer to the message to handle +* @return none +*************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestTemperatureSensorsDataPublishOverrideRequest, \ + testSetTemperatureSensorsPublishIntervalOverride, testResetTemperatureSensorsPublishIntervalOverride ) + +/************************************************************************* + * @brief + * The handleTestHeatersDataPublishOverrideRequest function handles \n + * a request to override the publish interval of heaters data + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +DATA_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestHeatersDataPublishOverrideRequest, \ + testSetHeatersPublishIntervalOverride, testResetHeatersPublishIntervalOverride ) + +/************************************************************************* * @brief handleSetRTCTimestamp * The handleSetRTCTimestamp function handles a request to write time and * date to RTC @@ -974,29 +1104,14 @@ U32 years; memcpy(&years, &message->payload[5], sizeof(U32)); - // TODO: Change setRTCTimestamp to return a boolean for this - result = TRUE; + result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); - setRTCTimestamp( seconds, minutes, hours, days, months, years ); - // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } /************************************************************************* * @brief - * The handleTestLoadCellOverrideRequest function handles a request to \n - * override the value read from the given load cell. - * @details - * Inputs : none - * Outputs : message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestLoadCellOverrideRequest, testSetLoadCellOverride, testResetLoadCellOverride ) - -/************************************************************************* - * @brief * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles \n * a request to override the broadcast interval for load cell data. * @details @@ -1152,3 +1267,31 @@ } #endif + +/************************************************************************* + * @brief + * The handleStartStopPrimaryHeater function handles a request start or + * stop the primary heater + * @details + * Inputs : none + * Outputs : message handled + * @param message : a pointer to the message to handle + * @return result + *************************************************************************/ +BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) +{ + BOOL result; + U32 heaterStatus = message->payload[0]; + + if ( heaterStatus == 1 ) + { + result = startPrimaryHeater(); + } + else + { + stopPrimaryHeater(); + result = TRUE; + } + + return result; +}