Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r3b70632c04247a6973960e1f37ae73eb4384a6b7 -rfc11115c26447a2da7b12f5f38ff0d4af06c579b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 3b70632c04247a6973960e1f37ae73eb4384a6b7) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision fc11115c26447a2da7b12f5f38ff0d4af06c579b) @@ -23,7 +23,6 @@ #include "Compatible.h" #include "ConcentratePumps.h" #include "ConductivitySensors.h" -#include "Fans.h" #include "FPGA.h" #include "Heaters.h" #include "ModeFill.h" @@ -301,6 +300,9 @@ payloadPtr += sizeof( U32 ); data = almData2.data.uInt.data; memcpy( payloadPtr, &data, sizeof( U32 ) ); + // Pad with space for 3 U32s - set to zero - unused for DG + payloadPtr += ( sizeof( U32) * 3 ); + memset( payloadPtr, 0, sizeof( U32) * 3 ); // 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_ALARM, ACK_REQUIRED ); @@ -365,7 +367,6 @@ return result; } - // *********************************************************************** // **************** Message Handling Helper Functions ******************** // *********************************************************************** @@ -390,6 +391,30 @@ /*********************************************************************//** * @brief + * The handleRTCSyncFromHD function handles an HD date/time broadcast message + * from the HD. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleRTCSyncFromHD( MESSAGE_T *message ) +{ + // Only sync RTC to HD date/time when ... + if ( TRUE == syncDG2HDDateTime() ) + { + if ( sizeof( RTC_DATA_T ) == message->hdr.payloadLen ) + { + RTC_DATA_T epoch; + + memcpy( &epoch, message->payload, sizeof( RTC_DATA_T ) ); + setRTCEpoch( epoch.epochTime ); + } + } +} + +/*********************************************************************//** + * @brief * The handleAlarmClear function handles a clear alarm message from the HD. * @details Inputs: none * @details Outputs: message handled @@ -427,7 +452,6 @@ if ( message->hdr.payloadLen == sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ) { DG_CMD_DIALYSATE_HEATING_PARAMS_T payload; - result = TRUE; memcpy( &payload, message->payload, sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ); setDialysateHeatingParameters( payload ); @@ -556,14 +580,15 @@ void handleDGSendConcentrateMixingRatios( MESSAGE_T *message ) { MESSAGE_T msg; - - DG_ACID_CONCENTRATES_RECORD_T acid = getAcidConcentrateCalRecord(); - DG_BICARB_CONCENTRATES_RECORD_T bicarb = getBicarbConcentrateCalRecord(); + DG_ACID_CONCENTRATES_RECORD_T acid; + DG_BICARB_CONCENTRATES_RECORD_T bicarb; // By the time these are requested, the prepare time is no longer needed since the concentrate lines are // primed before the actual treatment starts - U32 fillPrepTimeMS = 0; + U32 fillPrepTimeMS = 0; + U08 *payloadPtr = msg.payload; - U08 *payloadPtr = msg.payload; + getAcidConcentrateCalRecord( &acid ); + getBicarbConcentrateCalRecord( &bicarb ); // Create a message record blankMessage( &msg ); @@ -863,7 +888,7 @@ msg.hdr.msgID = MSG_ID_DG_SCHEDULED_RUNS_DATA; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // TODO this message is for Phase 1B. + // Do nothing this message is for Phase 1B. // 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 ); @@ -1103,7 +1128,7 @@ if ( TRUE == heaterCmd.startHeater ) { - BOOL isSet = setHeaterTargetTemperature( DG_TRIMMER_HEATER, heaterCmd.targetTemp ); + BOOL isSet = setHeaterTargetTemperature( DG_TRIMMER_HEATER, getTrimmerHeaterTargetTemperature() ); if ( TRUE == isSet ) { @@ -1431,12 +1456,13 @@ if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) { U32 mode; + U32 subMode; - // NOTE: the HD operations modes broadcast message contains the mode and submode states - // In this case, only the mode is needed. The mode is received to check if HD is in treatment - // and therefore, DG can void the last disinfect. memcpy( payloadPtr, &mode, sizeof( U32 ) ); - setHDOperationMode( mode ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &subMode, sizeof( U32 ) ); + + setHDOperationMode( mode, subMode ); status = TRUE; } @@ -3203,37 +3229,6 @@ } /*********************************************************************//** - * @brief - * The handleFansRPMOverride function handles a request to override a fans RPM value. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleFansRPMOverride( 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 = testSetFanRPMOverride( payload.index, payload.state.f32 ); - } - else - { - result = testResetFanRPMOverride( payload.index ); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** * @brief * The handleStopDGRTCClock function handles a request to stop the RTC clock. * @details Inputs: none @@ -3372,10 +3367,41 @@ /*********************************************************************//** * @brief - * The handleTestFansRPMAlarmStartTimeOffsetRequest function handles a - * request to set the fans RPM alarm start time offset. + * The handleFansRPMOverride function handles a request to override a fans RPM value. * @details Inputs: none * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleFansRPMOverride( 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 = testSetFanRPMOverride( payload.index, payload.state.f32 ); + } + else + { + result = testResetFanRPMOverride( payload.index ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestFansRPMAlarmStartTimeOverrideRequest function handles a + * request to override the fan RPM alarm start time. + * @details Inputs: none + * @details Outputs: message handled * @param message : a pointer to the message to handle * @return none *************************************************************************/ @@ -3398,7 +3424,6 @@ } /*********************************************************************//** - * @brief * The handleTestUsedAcidVolumeMLOverrideRequest function handles a * request to override the acid volume. * @details Inputs: none @@ -3758,4 +3783,29 @@ return result; } +/*********************************************************************//** + * @brief + * The sendUIServiceModeResponse function sends out the DG response to a + * UI request to go to service mode. + * @details Inputs: none + * @details Outputs: Service mode request response msg constructed and queued + * @param accepted TRUE if request was accepted, FALSE if not + * @param rejCode Reject reason code explaining why request was rejected + * @return none + *************************************************************************/ +void handleResendAllAlarmsCommand( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + handleResendActiveAlarmsRequest(); + result = TRUE; + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /**@}*/