Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rf308cc4c35eab630ebbbde405cfe47d049afeafb -rc31c6e4340c28577df4d146165ccbfc8f0a47134 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c31c6e4340c28577df4d146165ccbfc8f0a47134) @@ -8,16 +8,19 @@ * @file SystemCommMessages.c * * @author (last) Quang Nguyen -* @date (last) 21-Jul-2020 +* @date (last) 26-Aug-2020 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 * ***************************************************************************/ -#include // for memcpy() +#include // for memcpy() -#include "Accel.h" +#include "reg_system.h" + +#include "Accel.h" +#include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "DrainPump.h" #include "FPGA.h" @@ -40,45 +43,49 @@ #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" + +/** + * @addtogroup SystemCommMessages + * @{ + */ // ********** private definitions ********** -#define ACK_REQUIRED TRUE -#define ACK_NOT_REQUIRED FALSE +#define ACK_REQUIRED TRUE ///< Require an ACK. +#define ACK_NOT_REQUIRED FALSE ///< Not require an ACK. #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 #endif // ********** private data ********** -static BOOL testerLoggedIn = FALSE; -static volatile U16 nextSeqNo = 1; +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. +static volatile U16 nextSeqNo = 1; ///< Next sequence number. // ********** private function prototypes ********** static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); -/************************************************************************* - * @brief serializeMessage - * The serializeMessage function serializes a given message into a given \n - * array of bytes. A sequence # is added to the message here and the ACK \n - * bit of the sequence # is set if ACK is required per parameter. A sync byte \n - * is inserted at the beginning of the message and an 8-bit CRC is appended to \n +/*********************************************************************//** + * @brief + * The serializeMessage function serializes a given message into a given + * array of bytes. A sequence # is added to the message here and the ACK + * bit of the sequence # is set if ACK is required per parameter. A sync byte + * is inserted at the beginning of the message and an 8-bit CRC is appended to * the end of the message. The message is queued for transmission in the given buffer. - * @details - * Inputs : none - * Outputs : given data array populated with serialized message data and queued for transmit. + * @details Inputs: none + * @details Outputs: given data array populated with serialized message data and queued for transmit. * @param msg message to serialize * @param buffer outgoing buffer that message should be queued in * @param ackReq is an acknowledgement from receiver required? * @return size (in bytes) of serialized message populated in given data array. *************************************************************************/ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { - BOOL result = 0; + BOOL result = FALSE; BOOL error = FALSE; U32 msgSize = 0; U32 sizeMod, sizePad; @@ -143,14 +150,13 @@ return result; } - -/************************************************************************* - * @brief sendACKMsg - * The sendACKMsg function constructs and queues for transmit an ACK message \n + +/*********************************************************************//** + * @brief + * The sendACKMsg function constructs and queues for transmit an ACK message * for a given received message. - * @details - * Inputs : none - * Outputs : ACK message queued for transmit on broadcast CAN channel. + * @details Inputs: none + * @details Outputs: ACK message queued for transmit on broadcast CAN channel. * @param message message to send an ACK for * @return TRUE if ACK message queued successfully, FALSE if not *************************************************************************/ @@ -173,15 +179,13 @@ return result; } - -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n - * appropriate UART channel. - * @details - * Inputs : none - * Outputs : response message constructed and queued for transmit. + +/*********************************************************************//** + * @brief + * The sendTestAckResponseMsg function constructs a simple response message for + * a handled test message and queues it for transmit on the appropriate UART channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param buffer outgoing buffer that message should be queued in * @param ack TRUE if test message was handled successfully, FALSE if not @@ -203,18 +207,18 @@ return result; } + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** - -/************************************************************************* - * @brief broadcastAlarmTriggered - * The broadcastAlarmTriggered function constructs an alarm triggered msg to \n + +/*********************************************************************//** + * @brief + * The broadcastAlarmTriggered function constructs an alarm triggered msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : alarm triggered msg constructed and queued. + * @details Inputs: none + * @details Outputs: alarm triggered msg constructed and queued. * @param alarm ID of alarm triggered * @param almData1 1st data associated with alarm * @param almData2 2nd data associated with alarm @@ -242,14 +246,13 @@ return result; } - -/************************************************************************* - * @brief broadcastAlarmCleared - * The broadcastAlarmCleared function constructs an alarm cleared msg to be \n + +/*********************************************************************//** + * @brief + * The broadcastAlarmCleared function constructs an alarm cleared msg to be * broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : alarm cleared msg constructed and queued. + * @details Inputs: none + * @details Outputs: alarm cleared msg constructed and queued. * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -271,14 +274,13 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The broadcastAccelData function constructs an accelerometer data msg to \n + * The broadcastAccelData function constructs an accelerometer data msg to * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : accelerometer data broadcast msg constructed and queued. + * @details Inputs: none + * @details Outputs: accelerometer data broadcast msg constructed and queued. * @param x X axis vector magnitude (in g) * @param y Y axis vector magnitude (in g) * @param z Z axis vector magnitude (in g) @@ -319,13 +321,12 @@ return result; } -/************************************************************************* - * @brief broadcastRTCEpoch - * The broadcastRTCEpoch function constructs an epoch msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : RTC time and date in epoch +/*********************************************************************//** + * @brief + * The broadcastRTCEpoch function constructs an epoch msg to be broadcast + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: RTC time and date in epoch * @param epoch Current time and date in epoch * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ @@ -347,14 +348,13 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The broadcastDGHDOperationMode function constructs a DG operation mode \n + * The broadcastDGHDOperationMode function constructs a DG operation mode * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details - * Inputs : none - * Outputs : DG operation mode msg constructed and queued + * @details Inputs: none + * @details Outputs: DG operation mode msg constructed and queued * @param mode current operation mode of the DG. * @param subMode current sub-mode of the current operation mode of the DG. * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -379,13 +379,12 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastLoadCellData function sends out load cell data. - * @details - * Inputs : none - * Outputs : load cell data msg constructed and queued + * @details Inputs: none + * @details Outputs: load cell data msg constructed and queued * @param loadCellA1 load cell A 1 data in grams * @param loadCellA2 load cell A 2 data in grams * @param loadCellB1 load cell B 1 data in grams @@ -416,13 +415,12 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastValvesStates function sends out DG valves states. - * @details - * Inputs : none - * Outputs : Valves states msg constructed and queued + * @details Inputs: none + * @details Outputs: Valves states msg constructed and queued * @param valvesStates valves states * refer to setFPGAValveStates function in FPGA.c for details * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -445,13 +443,12 @@ return result; } - -/************************************************************************* + +/*********************************************************************//** * @brief * The broadcastHeatersData function sends out DG heaters data - * @details - * Inputs : heaters data - * Outputs : heatears data msg constructed and queued + * @details Inputs: heaters data + * @details 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 @@ -480,48 +477,39 @@ return result; } - -/************************************************************************* - * @brief - * The broadcastROPumpData function sends out RO pump data. - * @details - * Inputs : none - * Outputs : RO pump data msg constructed and queued - * @param tgtPressure target pressure for RO pump in PSI - * @param measFlow measure RO flow rate in LPM - * @param setPWM set PWM duty cycle in % - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastROPumpData( U32 tgtPressure, F32 measFlow, F32 setPWM ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - RO_PUMP_DATA_T payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RO_PUMP_DATA; - msg.hdr.payloadLen = sizeof( RO_PUMP_DATA_T ); - - payload.setROPumpPressure = tgtPressure; - payload.measROFlowRate = measFlow; - payload.roPumpPWM = setPWM; - - memcpy( payloadPtr, &payload, sizeof( RO_PUMP_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 + * @details Outputs: RO pump data msg constructed and queued + * @param pumpData which is the msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastROPumpData( RO_PUMP_DATA_T *pumpData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_RO_PUMP_DATA; + msg.hdr.payloadLen = sizeof( RO_PUMP_DATA_T ); + + memcpy( payloadPtr, pumpData, sizeof( RO_PUMP_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 broadcastDrainPumpData function sends out RO pump data. - * @details - * Inputs : none - * Outputs : Drain pump data msg constructed and queued + * The broadcastDrainPumpData function sends out drain pump data. + * @details Inputs: none + * @details Outputs: Drain pump data msg constructed and queued * @param tgtSpeed target speed for drain pump in RPM * @param dac set DAC value * @return TRUE if msg successfully queued for transmit, FALSE if not @@ -547,14 +535,42 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; -} - -/************************************************************************* +} + +/*********************************************************************//** + * @brief + * The broadcastConcentratePumpData function sends out concentrate pumps' data. + * @details Inputs: none + * @details Outputs: concentrate pump data msg constructed and queued + * @param cp1TgtSpeed target speed for concentrate pump CP1 + * @param measuredCP1Speed measured speed for concentrate pump CP1 using hall sense + * @param cp2TgtSpeed target speed for concentrate pump CP2 + * @param measuredCP2Speed measured speed for concentrate pump CP2 using hall sense + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastConcentratePumpData( void * concentratePumpDataPtr ) +{ + BOOL result; + MESSAGE_T msg; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_CONCENTRATE_PUMP_DATA; + msg.hdr.payloadLen = sizeof( CONCENTRATE_PUMP_DATA_T ); + + memcpy( &msg.payload, concentratePumpDataPtr, sizeof( CONCENTRATE_PUMP_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 broadcastPressureSensorsData function sends out DG pressure data. - * @details - * Inputs : none - * Outputs : Pressure data msg constructed and queued + * @details Inputs: none + * @details Outputs: Pressure data msg constructed and queued * @param measROIn measured RO pump inlet pressure in PSI * @param measROOut measured RO pump outlet pressure in PSI * @param measDrainIn measured Drain pump inlet pressure in PSI @@ -584,14 +600,13 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); return result; -} - -/************************************************************************* +} + +/*********************************************************************//** * @brief * The broadcastReservoirData function broadcasts the DG reservoir data. - * @details - * Inputs : none - * Outputs : Reservoir data msg constructed and queued + * @details Inputs: none + * @details Outputs: Reservoir data msg constructed and queued * @param resID ID of currently active reservoir * @param fillToVol Current target fill to volume for inactive reservoir * @param drainToVol Current target drain to volume for inactive reservoir @@ -620,14 +635,15 @@ 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 + * sensors data. + * @details Inputs: none + * @details Outputs: temperature sensors data message constructed and queued + * @param sensorsValue sensors value array + * @param byteLength payload length in bytes * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL broadcastTemperatureSensorsData ( U08 *sensorsValue, U32 byteLength ) @@ -649,34 +665,28 @@ return result; } - -/************************************************************************* +/*********************************************************************//** * @brief * The broadcastConductivityData function sends out conductivity data. - * @details - * Inputs : none - * Outputs : conductivity data msg constructed and queued - * @param cpi: water inlet conductivity data. - * @param cpo : water outlet conductivity data. + * @details Inputs: none + * @details Outputs: conductivity data message constructed and queued + * @param roRejectionRatio RO rejection ratio + * @param cpi water inlet conductivity data + * @param cpo water outlet conductivity data * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastConductivityData( F32 cpi, F32 cpo ) +BOOL broadcastConductivityData( void * conductivityDataPtr ) { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - CONDUCTIVITY_DATA_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_CONDUCTIVITY_DATA; msg.hdr.payloadLen = sizeof( CONDUCTIVITY_DATA_T ); - payload.cpi = cpi; - payload.cpo = cpo; + memcpy( &msg.payload, conductivityDataPtr, sizeof( CONDUCTIVITY_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( CONDUCTIVITY_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 ); @@ -687,14 +697,14 @@ // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** - -/************************************************************************* + + +/*********************************************************************//** * @brief - * The handlePowerOffWarning function handles a power off warning message \n + * The handlePowerOffWarning function handles a power off warning message * from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -705,39 +715,37 @@ signalPowerOffWarning(); } } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleSetDialysateTemperatureCmd function handles a dialysate temperature \n + * The handleSetDialysateTemperatureCmd function handles a dialysate temperature * set points message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetDialysateTemperatureCmd( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(TARGET_TEMPS_PAYLOAD_T) ) + if ( message->hdr.payloadLen == sizeof( TARGET_TEMPS_PAYLOAD_T ) ) { TARGET_TEMPS_PAYLOAD_T payload; result = TRUE; - memcpy( &payload, message->payload, sizeof(TARGET_TEMPS_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( TARGET_TEMPS_PAYLOAD_T ) ); setPrimaryHeaterTargetTemperature( payload.targetPrimaryHeaterTemp ); setTrimmerHeaterTargetTemperature( payload.targetTrimmerHeaterTemp ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief * The handleFWVersionCmd function handles a FW version request message. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -765,105 +773,101 @@ // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_BROADCAST, ACK_NOT_REQUIRED ); } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleSwitchReservoirCmd function handles a switch reservoirs command \n + * The handleSwitchReservoirCmd function handles a switch reservoirs command * from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSwitchReservoirCmd( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { RESERVOIR_ID_T reservoirID; U32 resID; result = TRUE; - memcpy( &resID, message->payload, sizeof(U32) ); + memcpy( &resID, message->payload, sizeof( U32 ) ); reservoirID = (RESERVOIR_ID_T)resID; setActiveReservoirCmd( reservoirID ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief * The handleFillCmd function handles a fill command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleFillCmd( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 fillToVolumeMl; result = TRUE; - memcpy( &fillToVolumeMl, message->payload, sizeof(U32) ); + memcpy( &fillToVolumeMl, message->payload, sizeof( U32 ) ); startFillCmd( fillToVolumeMl ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief * The handleDrainCmd function handles a drain command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleDrainCmd( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( DRAIN_CMD_T ) ) { - U32 drainToVolMl; + DRAIN_CMD_T drainCmd; result = TRUE; - memcpy( &drainToVolMl, message->payload, sizeof(U32) ); + memcpy( &drainCmd, message->payload, sizeof( DRAIN_CMD_T ) ); - startDrainCmd( drainToVolMl ); + startDrainCmd( drainCmd ); } sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleStartStopTreatmentMsg function handles a treatment start/stop \n + * The handleStartStopTreatmentMsg function handles a treatment start/stop * message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTreatmentMsg( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingTreatment; - memcpy( &startingTreatment, message->payload, sizeof(U32) ); + memcpy( &startingTreatment, message->payload, sizeof( U32 ) ); if ( DG_MODE_STAN == getCurrentOperationMode() && TRUE == startingTreatment ) { @@ -877,26 +881,25 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief - * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop \n + * The handleStartStopTrimmerHeaterCmd function handles a trimmer heater start/stop * command message from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleStartStopTrimmerHeaterCmd( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingHeater; - memcpy( &startingHeater, message->payload, sizeof(U32) ); + memcpy( &startingHeater, message->payload, sizeof( U32 ) ); if ( TRUE == startingHeater ) { @@ -910,13 +913,12 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief * The handleSampleWaterCmd function handles a sample water command from the HD. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -934,14 +936,13 @@ sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } - -/************************************************************************* - * @brief handleSetRTCTimestamp + +/*********************************************************************//** + * @brief * The handleSetRTCTimestamp function handles a request to write time and * date to RTC - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -954,33 +955,32 @@ U08 days = message->payload[3]; U08 months = message->payload[4]; U32 years; - memcpy(&years, &message->payload[5], sizeof(U32)); + memcpy(&years, &message->payload[5], sizeof( U32 )); result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/************************************************************************* + +/*********************************************************************//** * @brief * The handleStartStopPrimaryHeater function handles a request start or * stop the primary heater - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return result *************************************************************************/ BOOL handleStartStopPrimaryHeater( MESSAGE_T * message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(U32) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { BOOL startingHeater; - memcpy( &startingHeater, message->payload, sizeof(U32) ); + memcpy( &startingHeater, message->payload, sizeof( U32 ) ); if ( TRUE == startingHeater ) { @@ -997,19 +997,20 @@ return result; } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ + - #ifdef DEBUG_ENABLED - /************************************************************************* - * @brief sendDebugData + /*********************************************************************//** + * @brief * The sendDebugData function sends debug data out to the PC port. * @details - * Inputs : none - * Outputs : PC serial port + * @details Inputs: none + * @details Outputs: PC serial port * @param dbgData Pointer to debug data * @param len number of bytes of debug data * @return TRUE if debug data was successfully queued for transmit, FALSE if not @@ -1023,13 +1024,13 @@ return result; } - - /************************************************************************* + + /*********************************************************************//** * @brief * The sendDebugDataToUI function sends debug string to the UI for logging. * @details - * Inputs : none - * Outputs : Message constructed and queued for transmit + * @details Inputs: none + * @details Outputs: Message constructed and queued for transmit * @param str Pointer to debug string * @return none *************************************************************************/ @@ -1052,29 +1053,26 @@ } } #endif - -/************************************************************************* - * @brief isTestingActivated - * The isTestingActivated function determines whether a tester has successfully \n + +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully * logged in to activate testing functionality. - * @details - * Inputs : testerLoggedIn - * Outputs : none + * @details Inputs: testerLoggedIn + * @details Outputs: none * @return TRUE if a tester has logged in to activate testing, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) { return testerLoggedIn; } - -/************************************************************************* - * @brief sendTestAckResponseMsg - * The sendTestAckResponseMsg function constructs a simple response \n - * message for a handled test message and queues it for transmit on the \n - * appropriate UART channel. - * @details - * Inputs : none - * Outputs : response message constructed and queued for transmit. + +/*********************************************************************//** + * @brief + * The sendTestAckResponseMsg function constructs a simple response message for + * a handled test message and queues it for transmit on the appropriate UART channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to * @param ack TRUE if test message was handled successfully, FALSE if not * @return TRUE if response message successfully queued for transmit, FALSE if not @@ -1095,14 +1093,12 @@ return result; } - -/************************************************************************* - * @brief handleTesterLogInRequest - * The handleTesterLogInRequest function handles a request to login as a \n - * tester. - * @details - * Inputs : none - * Outputs : message handled + +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a tester. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ @@ -1121,297 +1117,935 @@ // respond to would be tester sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } - -/************************************************************************* - * @brief handleTestWatchdogCheckInStateOverrideRequest - * The handleTestWatchdogCheckInStateOverrideRequest function handles a \n + +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a * request to override the check-in status of a given task. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestWatchdogCheckInStateOverrideRequest, testSetWatchdogTaskCheckInOverride, testResetWatchdogTaskCheckInOverride ) - -/************************************************************************* - * @brief handleTestAlarmStateOverrideRequest - * The handleTestAlarmStateOverrideRequest function handles a request to \n +void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetWatchdogTaskCheckInOverride( payload.index, (BOOL)(payload.state.u32) ); + } + else + { + result = testResetWatchdogTaskCheckInOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestAlarmStateOverrideRequest function handles a request to * override the active status of a given alarm. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestAlarmStateOverrideRequest, testSetAlarmStateOverride, testResetAlarmStateOverride ) - -/************************************************************************* +void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetAlarmStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetAlarmStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestLoadCellOverrideRequest function handles a request to \n + * The handleTestLoadCellOverrideRequest function handles a request to * override the value read from the given load cell. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestLoadCellOverrideRequest, testSetLoadCellOverride, testResetLoadCellOverride ) - -/************************************************************************* +void handleTestLoadCellOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetLoadCellOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetLoadCellOverride( payload.index ); + } + } + + //respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleTestTemperatureSensorsOverrideRequest function handles a - * request to override a temperatures sensor's value - * @details - * Inputs : none - * Outputs : message handled + * request to override a temperatures sensor's value. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestTemperatureSensorsOverrideRequest, \ - testSetMeasuredTemperatureOverride, testResetMeasuredTemperatureOverride ) - -/************************************************************************* +void handleTestTemperatureSensorsOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredTemperatureOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetMeasuredTemperatureOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief -* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles \n -* a request to override the publish interval of temperature sensors data +* The handleTestTemperatureSensorsDataPublishOverrideRequest function handles +* a request to override the publish interval of temperature sensors data. * @details -* Inputs : none -* Outputs : message handled +* @details Inputs: none +* @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestTemperatureSensorsDataPublishOverrideRequest, \ - testSetTemperatureSensorsPublishIntervalOverride, testResetTemperatureSensorsPublishIntervalOverride ) +void handleTestTemperatureSensorsDataPublishOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetTemperatureSensorsPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetTemperatureSensorsPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} -/************************************************************************* +/*********************************************************************//** * @brief - * The handleTestHeatersDataPublishOverrideRequest function handles \n - * a request to override the publish interval of heaters data - * @details - * Inputs : none - * Outputs : message handled + * The handleTestHeatersDataPublishOverrideRequest function handles + * a request to override the publish interval of heaters data. + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestHeatersDataPublishOverrideRequest, \ - testSetHeatersPublishIntervalOverride, testResetHeatersPublishIntervalOverride ) - -/************************************************************************* +void handleTestHeatersDataPublishOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetHeatersPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetHeatersPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestLoadCellDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestLoadCellDataBroadcastIntervalOverrideRequest, testSetLoadCellDataPublishIntervalOverride, testResetLoadCellDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestLoadCellDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetLoadCellDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetLoadCellDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestPressureSensorOverrideRequest function handles a request to \n + * The handleTestPressureSensorOverrideRequest function handles a request to * override the value read from the given pressure sensor. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestPressureSensorOverrideRequest, testSetDGPressureSensorOverride, testResetDGPressureSensorOverride ) - -/************************************************************************* +void handleTestPressureSensorOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetDGPressureSensorOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetDGPressureSensorOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestPressureDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for load cell data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestPressureDataBroadcastIntervalOverrideRequest, testSetPressuresDataPublishIntervalOverride, testResetPressuresDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestPressureDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetPressuresDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetPressuresDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestROPumpSetPointOverrideRequest function handles a request to \n - * override the RO pump pressure set point (in PSI). - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestROPumpSetPointOverrideRequest, testSetTargetROPumpPressureOverride, testResetTargetROPumpPressureOverride ) - -/************************************************************************* - * @brief - * The handleTestROMeasuredFlowOverrideRequest function handles a request to \n + * The handleTestROMeasuredFlowOverrideRequest function handles a request to * override the RO flow rate. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestROMeasuredFlowOverrideRequest, testSetMeasuredROFlowRateOverride, testResetMeasuredROFlowRateOverride ) - -/************************************************************************* +void handleTestROMeasuredFlowOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredROFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestROPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for RO pump data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestROPumpDataBroadcastIntervalOverrideRequest, testSetROPumpDataPublishIntervalOverride, testResetROPumpDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestROPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetROPumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetROPumpDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDrainPumpSetPointOverrideRequest function handles a request to \n - * override the drain pump speed set point (in RPM). - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpSetPointOverrideRequest, testSetTargetDrainPumpSpeedOverride, testResetTargetDrainPumpSpeedOverride ) - -/************************************************************************* - * @brief - * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles \n + * The handleTestDrainPumpDataBroadcastIntervalOverrideRequest function handles * a request to override the broadcast interval for drain pump data. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDrainPumpDataBroadcastIntervalOverrideRequest, testSetDrainPumpDataPublishIntervalOverride, testResetDrainPumpDataPublishIntervalOverride ) - -/************************************************************************* +void handleTestDrainPumpDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetDrainPumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDrainPumpDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestValveStateOverrideRequest function handles a request to \n + * The handleTestValveStateOverrideRequest function handles a request to * override the state value read from the given valve. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_U32( BOOL, handleTestValveStateOverrideRequest, testSetValveStateOverride, testResetValveStateOverride ) - -/************************************************************************* +void handleTestValveStateOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetValveStateOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetValveStateOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestValvesStatesPublishIntervalOverrideRequest function handles \n + * The handleTestValvesStatesPublishIntervalOverrideRequest function handles * a request to override the publish interval of valves states from the given valve. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestValvesStatesPublishIntervalOverrideRequest, testSetValvesStatesPublishIntervalOverride, testResetValvesStatesPublishIntervalOverride ) - -/************************************************************************* +void handleTestValvesStatesPublishIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetValvesStatesPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetValvesStatesPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDGSafetyShutdownOverrideRequest function handles a \n + * The handleTestDGSafetyShutdownOverrideRequest function handles a * request to override the safety shutdown signal. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGSafetyShutdownOverrideRequest, testSetSafetyShutdownOverride, testResetSafetyShutdownOverride ) +void handleTestDGSafetyShutdownOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; -/************************************************************************* + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetSafetyShutdownOverride( payload.state.u32 ); + } + else + { + result = testResetSafetyShutdownOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDGAccelOverrideRequest function handles a request to \n + * The handleTestDGAccelOverrideRequest function handles a request to * override the measured accelerometer sensor readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDGAccelOverrideRequest, testSetAccelAxisOverride, testResetAccelAxisOverride ) +void handleTestDGAccelOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; -/************************************************************************* + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetAccelAxisOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelAxisOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDGAccelMaxOverrideRequest function handles a request to \n + * The handleTestDGAccelMaxOverrideRequest function handles a request to * override the measured accelerometer sensor maximum readings. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestDGAccelMaxOverrideRequest, testSetAccelMaxOverride, testResetAccelMaxOverride ) +void handleTestDGAccelMaxOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; -/************************************************************************* + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetAccelMaxOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetAccelMaxOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief - * The handleTestDGAccelBroadcastIntervalOverrideRequest function handles a \n + * The handleTestDGAccelBroadcastIntervalOverrideRequest function handles a * request to override the broadcast interval for accelerometer data messages. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestDGAccelBroadcastIntervalOverrideRequest, testSetAccelDataPublishIntervalOverride, testResetAccelDataPublishIntervalOverride ) +void handleTestDGAccelBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; -/************************************************************************* + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetAccelDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetAccelDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleSetAccelCalibration function handles a request to set * accelerometer calibration factors. - * @details - * Inputs : none - * Outputs : message handled + * @details Inputs: none + * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetAccelCalibration( MESSAGE_T *message ) { BOOL result = FALSE; - if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) + if ( message->hdr.payloadLen == sizeof( ACCEL_CAL_PAYLOAD_T ) ) { ACCEL_CAL_PAYLOAD_T payload; - memcpy( &payload, message->payload, sizeof(ACCEL_CAL_PAYLOAD_T) ); + memcpy( &payload, message->payload, sizeof( ACCEL_CAL_PAYLOAD_T ) ); result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); } // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTestSetConductivityOverrideRequest function handles a * request to override a conductivity sensor's value - * @details - * Inputs : none - * Outputs : message handled - * @param message : a pointer to the message to handle + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_ARRAY_OVERRIDE_HANDLER_FUNC_F32( F32, handleTestSetConductivityOverrideRequest, testSetConductivityOverride, testResetConductivityOverride ) +void handleTestSetConductivityOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; -/************************************************************************* + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetConductivityOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetConductivityOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleTestSetConductivityDataPublishIntervalOverrideRequest function * handles a request to override the publish interval of conductivity sensors data * @details -* Inputs : none -* Outputs : message handled -* @param message : a pointer to the message to handle +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle * @return none *************************************************************************/ -DATA_OVERRIDE_HANDLER_FUNC_U32( U32, handleTestSetConductivityDataPublishIntervalOverrideRequest, \ - testSetConductivityDataPublishIntervalOverride, testResetConductivityDataPublishIntervalOverride ) +void handleTestSetConductivityDataPublishIntervalOverrideRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetConductivityDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetConductivityDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleDGSoftwareResetRequest function handles a request to + * perform a software reset on DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGSoftwareResetRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = TRUE; // reset will prevent this from getting transmitted + systemREG1->SYSECR = ( 0x2 << 14 ); // reset processor + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleConcentratePumpMeasuredSpeedOverride function handles a request + * to override a concentrate pump measured speed value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpMeasuredSpeedOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetConcentratePumpMeasuredSpeedOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetConcentratePumpMeasuredSpeedOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSetConcentratePumpTargetSpeed function handles a request to + * override a concentrate pump's target speed value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetConcentratePumpTargetSpeed( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + result = testSetConcentratePumpTargetSpeedOverride( payload.index, payload.state.f32 ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleConcentratePumpStateChangeRequest function handles a request to + * change the concentrate pumps' state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpStateChangeRequest( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) && ( TRUE == isTestingActivated() ) ) + { + result = TRUE; + + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( ( BOOL )payload.state.u32 ) + { + requestConcentratePumpsOn( ( CONCENTRATE_PUMPS_T )payload.index ); + } + else + { + requestConcentratePumpsOff( ( CONCENTRATE_PUMPS_T )payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleConcentratePumpPublishIntervalOverride function handles a request + * to override a concentrate pump's publish interval value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleConcentratePumpPublishIntervalOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetConcentratePumpDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetConcentratePumpDataPublishIntervalOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestROPumpDutyCycleOverride function handles a request to override +* the RO pumps duty cycle. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleTestROPumpDutyCycleOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + F32 payLoad; + + memcpy( &payLoad, message->payload, sizeof( F32 ) ); + + result = testSetTargetDutyCycle( payLoad ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestROFlowRateOverride function handles a request to override +* the RO flow rate. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*******************************************************************/ +void handleTestMeasuredROFlowRateOverride( MESSAGE_T *message ) +{ + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; + BOOL result = FALSE; + + // verify payload length + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) + { + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) + { + result = testSetMeasuredROFlowRateOverride( payload.state.f32 ); + } + else + { + result = testResetMeasuredROFlowRateOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleTestROPumpTargetFlowOverride function handles a request to +* override the RO pump target flow rate. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*******************************************************************/ +void handleTestROPumpTargetFlowOverride( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + F32 payload; + + memcpy( &payload, message->payload, sizeof( F32 ) ); + result = testSetTargetROPumpFlow( payload ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleROPumpTargetPressureOverride function handles a request to +* override the RO pump target 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; + + // verify payload length + if ( sizeof( U32 ) == message->hdr.payloadLen ) + { + U32 payload; + + memcpy( &payload, message->payload, sizeof( U32 ) ); + + result = testSetTargetROPumpPressure( payload ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/**@}*/