Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r3d131237935eb36e56e0d057a713430e31dc6405 -r233034b67edaee48012bf9a5478327519e0256bb --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3d131237935eb36e56e0d057a713430e31dc6405) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 233034b67edaee48012bf9a5478327519e0256bb) @@ -22,10 +22,8 @@ #include "Accel.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" -#include "DrainPump.h" #include "FPGA.h" #include "Heaters.h" -#include "LoadCell.h" #include "ModeFlush.h" #include "ModeStandby.h" #include "ModeRecirculate.h" @@ -34,8 +32,8 @@ #include "OperationModes.h" #include "Pressures.h" #include "Reservoirs.h" -#include "ROPump.h" #include "RTC.h" +#include "Switches.h" #include "SystemComm.h" #include "SafetyShutdown.h" #include "SystemCommMessages.h" @@ -385,31 +383,22 @@ * The broadcastLoadCellData function sends out load cell data. * @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 - * @param loadCellB2 load cell B 2 data in grams + * @param loadCell which is the loadcells data structure pointer * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastLoadCellData( F32 loadCellA1, F32 loadCellA2, F32 loadCellB1, F32 loadCellB2 ) +BOOL broadcastLoadCellData( LOAD_CELL_DATA_T *loadCell ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - LOAD_CELL_DATA_T payload; // create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_LOAD_CELL_READINGS; msg.hdr.payloadLen = sizeof( LOAD_CELL_DATA_T ); - payload.loadCellA1inGram = loadCellA1; - payload.loadCellA2inGram = loadCellA2; - payload.loadCellB1inGram = loadCellB1; - payload.loadCellB2inGram = loadCellB2; + memcpy( payloadPtr, loadCell, sizeof( LOAD_CELL_DATA_T ) ); - memcpy( payloadPtr, &payload, sizeof( LOAD_CELL_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 ); @@ -772,13 +761,17 @@ *************************************************************************/ void handleAlarmClear( MESSAGE_T *message ) { + BOOL result = FALSE; + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 alarmId; + result = TRUE; memcpy(&alarmId, message->payload, sizeof( U32 ) ); clearAlarm( (ALARM_ID_T)alarmId ); } + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_DG_2_HD, result ); } /*********************************************************************//** @@ -841,6 +834,65 @@ /*********************************************************************//** * @brief + * The handleDGSerialNumberRequest function handles a request for DG serial + * number request. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @return none + *************************************************************************/ +void handleDGSerialNumberRequest( void ) +{ + MESSAGE_T msg; + DG_SYSTEM_RECORD_T system = getDGSystemRecord(); + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SERIAL_NUMBER; + + // Add 1 byte for null terminator + msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; + + // Fill message payload + memcpy( payloadPtr, &system.topLevelSN, MAX_TOP_LEVEL_SN_CHARS ); + payloadPtr += MAX_TOP_LEVEL_SN_CHARS; + *payloadPtr = 0; + + // 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_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief + * The handleDGServiceScheduleRequest function handles a request for DG + * service information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none + *************************************************************************/ +void handleDGServiceScheduleRequest( MESSAGE_T *message ) +{ + MESSAGE_T msg; + DG_SERVICE_RECORD_T payload = getDGServiceRecord(); + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + + // Fill message payload + memcpy( payloadPtr, &payload.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &payload.serviceIntervalSeconds, sizeof( U32 ) ); + + // 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_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** + * @brief * The broadcastConductivityData function sends out conductivity data. * @details Inputs: none * @details Outputs: conductivity data message constructed and queued @@ -1160,6 +1212,33 @@ /*********************************************************************//** * @brief + * The broadcastSwitchesData function sends out switches data. + * @details Inputs: none + * @details Outputs: switches data msg constructed and queued + * @param switchesData which is switches msg constructed and queued + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastSwitchesData( SWITCHES_DATA_T *switchesData ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SWITCHES_DATA; + msg.hdr.payloadLen = sizeof( SWITCHES_DATA_T ); + + memcpy( payloadPtr, switchesData, sizeof( SWITCHES_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 sendDGSystemRecord function sends out the DG system record. * @details Inputs: none * @details Outputs: DG system record msg constructed and queued @@ -2270,6 +2349,70 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/************************************************************************* + * @brief + * The handleSetSwitchesStatusOverrideRequest function handles a + * request to override the status of a switch in DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetSwitchesStatusOverrideRequest( 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 = testSetSwitchesStatusOverride( payload.index, payload.state.u32 ); + } + else + { + result = testResetSwitchesStatusOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/************************************************************************* + * @brief + * The handleTestSwitchesPublishIntervalOverrideRequest function handles a + * request to override the the switches data publish interval. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSwitchesPublishIntervalOverrideRequest( 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 = testSetSwitchesDataPublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetSwitchesDataPublishIntervalOverrid(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestDGAccelOverrideRequest function handles a request to @@ -2985,6 +3128,38 @@ /*********************************************************************//** * @brief +* The handleSetDGOpModeBroadcastIntervalOverrideRequest function handles a request +* to override the publish interval of the DG operation mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetDGOpModeBroadcastIntervalOverrideRequest( 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 = testSetDGOpModePublishIntervalOverride( payload.state.u32 ); + } + else + { + result = testResetDGOpModePublishIntervalOverride(); + } + } + + // 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 @@ -3092,6 +3267,40 @@ /*********************************************************************//** * @brief +* The handleDGPOSTResultRequest function handles a request to report DG +* POST results. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleDGPOSTResultRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + + if ( 0 == message->hdr.payloadLen ) + { + if ( TRUE == isPOSTCompleted() ) + { + status = TRUE; + if ( TRUE == isPOSTPassed() ) + { + result = TRUE; + } + sendPOSTFinalResult( result ); + } + } + // If can't respond to request, NAK the message + if ( status != TRUE ) + { + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + } +} + +/*********************************************************************//** +* @brief * The handleSetDGCalibrationRecord function handles a request to set the DG * calibration data record. * @details Inputs: none @@ -3362,6 +3571,38 @@ } /*********************************************************************//** + * @brief + * The handleFilterFlushTimePeriodOverride function handles a request + * to override the filter flush time period value. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFilterFlushTimePeriodOverride( 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 = testSetFilterFlushTimePeriodOverride( payload.state.u32 ); + } + else + { + result = testResetFilterFlushTimePeriodOverride(); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** * @brief * The handleStartStopDGChemicalDisinfect function handles a request to start * or stop DG chemical disinfect mode.