Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r4e11c80367b5ae522aa34fb137079e516c98831b -rcb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4e11c80367b5ae522aa34fb137079e516c98831b) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision cb4d35cc50df2d3cc9e828cd92e53cf456ca9b9d) @@ -24,6 +24,7 @@ #include "ConcentratePumps.h" #include "ConductivitySensors.h" #include "Fans.h" +#include "FlowSensors.h" #include "FPGA.h" #include "Heaters.h" #include "ModeFill.h" @@ -553,21 +554,19 @@ getNVRecord2Driver( GET_SRV_RECORD, (U08*)&service, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); U08 *payloadPtr = msg.payload; - if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) - { - // 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, &service.lastServiceEpochDate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); - } + // 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, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.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 ); + serializeMessage( msg, COMM_BUFFER_OUT_CAN_DG_2_HD, ACK_REQUIRED ); } /*********************************************************************//** @@ -1421,7 +1420,43 @@ return status; } +/*********************************************************************//** + * @brief + * The handleHDRequestDGUsageInfo function handles a request for DG + * usage information. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for + * transmit. + * @return none + *************************************************************************/ +void handleHDRequestDGUsageInfo( MESSAGE_T * message ) +{ + MESSAGE_T msg; + DG_USAGE_INFO_RECORD_T usageInfo; + // Get the service record. There are no arrays of service to check and also, raise no alarm since the service record + // has been already checked in POST + getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&usageInfo, sizeof( DG_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_USAGE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( BOOL ); + + // Fill message payload + memcpy( payloadPtr, &usageInfo.lastHeatDisDateEpoch, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &usageInfo.lastChemicalDisDateEpoch, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &usageInfo.isDisinfected, sizeof( BOOL ) ); + + // 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_HD, ACK_REQUIRED ); +} + + // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -1820,29 +1855,29 @@ /*********************************************************************//** * @brief - * The handleTestDialysateMeasuredFlowOverrideRequest function handles a request to - * override the Dialysate flow rate. + * The handleTestMeasuredFlowOverrideRequest function handles a request to + * override the measured flow sensor rate. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestDialysateMeasuredFlowOverrideRequest( MESSAGE_T *message ) +void handleTestMeasuredFlowOverrideRequest( MESSAGE_T *message ) { - TEST_OVERRIDE_PAYLOAD_T payload; + TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + if ( sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) == message->hdr.payloadLen ) { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_ARRAY_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetMeasuredDialysateFlowRateOverride( payload.state.f32 ); + result = testSetMeasuredFlowRateOverride( payload.index, payload.state.f32 ); } else { - result = testResetMeasuredDialysateFlowRateOverride(); + result = testResetMeasuredFlowRateOverride( payload.index ); } } @@ -1884,14 +1919,14 @@ /*********************************************************************//** * @brief - * The handleTestDialysateFlowDataBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for dialysate flow data. + * The handleTestFlowSensorsDataBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for the flow sensors data. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestDialysateFlowDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +void handleTestFlowSensorsDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -1902,11 +1937,11 @@ memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); if ( FALSE == payload.reset ) { - result = testSetDialysateFlowDataPublishIntervalOverride( payload.state.u32 ); + result = testSetFlowDataPublishIntervalOverride( payload.state.u32 ); } else { - result = testResetDialysateFlowDataPublishIntervalOverride(); + result = testResetFlowDataPublishIntervalOverride(); } }