Index: firmware/App/Controllers/DGInterface.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Controllers/DGInterface.c (.../DGInterface.c) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -7,8 +7,8 @@ * * @file DGInterface.c * -* @author (last) Dara Navaei -* @date (last) 15-Jul-2022 +* @author (last) Michael Garthwaite +* @date (last) 08-Aug-2022 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -26,6 +26,7 @@ #include "ModeTreatmentParams.h" #include "OperationModes.h" #include "PersistentAlarm.h" +#include "SystemComm.h" #include "SystemCommMessages.h" #include "Timers.h" @@ -48,8 +49,14 @@ #define DIALYSATE_TEMP_LOW_SAFETY_LIMIT_C 42.0F ///< Dialysate low safety temperature limit in C. #define DIALYSATE_TEMP_LOW_SAFETY_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Dialysate temperature low safety timeout in milliseconds. -// ********** private data ********** +#define LOAD_CELL_DATA_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Load cell freshness timeout (in ms). +// ********** private data ********** +static const U32 DIP_LOAD_CELL_DATA_MESSAGE_ALARM_THRESHOLD = ((2 * MS_PER_SECOND) / TASK_GENERAL_INTERVAL); +static const U32 DIP_TEMPERATURE_DATA_MESSAGE_ALARM_THRESHOLD = ((2 * MS_PER_SECOND) / TASK_GENERAL_INTERVAL); +static const U32 DIP_RESERVOIRS_DATA_MESSAGE_ALARM_THRESHOLD = ((2 * MS_PER_SECOND) / TASK_GENERAL_INTERVAL); +static const U32 DIP_DG_OP_MODE_DATA_MESSAGE_ALARM_THRESHOLD = ((2 * MS_PER_SECOND) / TASK_GENERAL_INTERVAL); + // DG status static DG_OP_MODE_T dgCurrentOpMode; ///< Current DG operation mode. static U32 dgSubMode; ///< Current state (sub-mode) of current DG operation mode. @@ -61,7 +68,7 @@ static U32 timeStartMS = 0; // TODO is this needed? // DG sensor data -static F32 dgDialysateTemp; ///< Dialysate temperature reported by the DG. +static F32 dgDialysateTemp; ///< Dialysate temperature reported by the DG. static F32 dgRedundantDialysateTemp = 0.0; ///< Redundant dialysate temperature reported by the DG. static F32 dgPrimaryTemp = 0.0; ///< Latest RO water temperature reported by the DG. static F32 dgTrimmerTempSet; ///< Trimmer heater target temperature commanded. @@ -81,8 +88,16 @@ static F32 lgLoadCellBackupReadingsTotal[ NUM_OF_DG_RESERVOIRS ]; ///< Rolling total - used to calc large load cell moving average. // DG Dialysate flow rate -static F32 dgDialysateFlowRateMlMin; ///< Latest dialysate flow rate reported by the DG. -static BOOL dgDialysateFlowDataFreshFlag; ///< Flag to signal the execDialInFlowMonitor() to process fresh flow rate data +static F32 dgDialysateFlowRateMlMin = 0.0; ///< Latest dialysate flow rate reported by the DG. +static BOOL dgDialysateFlowDataFreshFlag = FALSE; ///< Flag to signal the execDialInFlowMonitor() to process fresh flow rate data +static BOOL dgLoadCellDataFreshFlag = FALSE; ///< Flag to signal the handleLoadCellReadingsFromDG() to process fresh load cell data +static BOOL dgDialysateTemperatureDataFreshFlag = FALSE; ///< Flag to signal the handleTemperatureReadingsFromDG() to process fresh temperature data +static BOOL dgReservoirsDataFreshFlag = FALSE; ///< Flag to signal the handleDGReservoirData() to process fresh reservoirs data +static BOOL dgOpModeDataFreshFlag = FALSE; ///< Flag to signal the handleDGOpMode() to process fresh dg op mode data +static U32 loadcellDataMessageFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh load cell data message is received +static U32 temperatureDataMessageFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh temperature data message is received +static U32 reservoirsDataMessageFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh reservoirs data message is received +static U32 dgOpModeDataMessageFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh dg op mode data message is received // Reservoir data static DG_RESERVOIR_ID_T dgActiveReservoir; ///< Latest active reservoir reported by the DG. @@ -171,7 +186,42 @@ initPersistentAlarm( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS, DIALYSATE_TEMP_OUT_OF_TARGET_TIMEOUT_MS ); + + initPersistentAlarm( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, LOAD_CELL_DATA_TIMEOUT_MS, LOAD_CELL_DATA_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_HD_NEW_DIALYSATE_TEMPERATURE_DATA_MESSAGE_NOT_RECEIVE, LOAD_CELL_DATA_TIMEOUT_MS, LOAD_CELL_DATA_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, LOAD_CELL_DATA_TIMEOUT_MS, LOAD_CELL_DATA_TIMEOUT_MS ); + initPersistentAlarm( ALARM_ID_HD_NEW_DG_OPERATION_MODE_MESSAGE_NOT_RECEIVE, LOAD_CELL_DATA_TIMEOUT_MS, LOAD_CELL_DATA_TIMEOUT_MS ); } + +/**********************************************************************//** + * @brief + * The checkDGDataFreshness function checks the condition + * for triggering an alarm if the DG fresh data is not received for 2 seconds. + * @details Inputs: none + * @details Outputs: an alarm is triggered or an alarm condition is cleared + * @param alarm ID of alarm to check + * @param flag to signal the fresh data processing + * @return None + *************************************************************************/ +void checkDGDataFreshness( ALARM_ID_T alarmID, BOOL *dgFreshDataFlag ) +{ + if ( TRUE == *dgFreshDataFlag ) + { + *dgFreshDataFlag = FALSE; + checkPersistentAlarm( alarmID, FALSE, 0.0, 0.0 ); + } + else + { // Alarm if not receiving DG fresh data message in timely manner + if ( TRUE == isDGCommunicating() ) + { + checkPersistentAlarm( alarmID, TRUE, 0.0, 0.0 ); + } + else + { + checkPersistentAlarm( alarmID, FALSE, 0.0, 0.0 ); + } + } +} /*********************************************************************//** * @brief @@ -183,9 +233,20 @@ *************************************************************************/ void execDGInterfaceMonitor( void ) { - // TODO - make sure DG sensor/state data is coming in timely manner (e.g. load cells s/b every 100 ms) + // Trigger alarm if not receiving new load cell data message in timely manner + /*checkDGDataFreshness( ALARM_ID_HD_NEW_LOAD_CELL_DATA_MESSAGE_NOT_RECEIVE, &dgLoadCellDataFreshFlag ); - // Check to see if DG has restarted + // Trigger alarm if not receiving new dialysate temperature data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMPERATURE_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); + + // Trigger alarm if not receiving new reservoirs data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_RESERVOIRS_DATA_MESSAGE_NOT_RECEIVE, &dgReservoirsDataFreshFlag ); + + // Trigger alarm if not receiving new reservoirs data message in timely manner + checkDGDataFreshness( ALARM_ID_HD_NEW_DG_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); + + // Check to see if DG has restarted*/ + checkDGRestart(); // Check the status of the trimmer heater @@ -299,6 +360,74 @@ return result; } + +/*********************************************************************//** + * @brief + * The getLoadCellDataFreshFlag function returns a flag to indicate + * if the load cell data message reported by the DG is fresh or stale data. + * @details Inputs: dgLoadCellDataFreshFlag + * @details Outputs: dgLoadCellDataFreshFlag + * @return T/F flag to indicate fresh/stale status of load cell data. + *************************************************************************/ +BOOL getLoadCellDataFreshFlag( void ) +{ + BOOL result = dgLoadCellDataFreshFlag; + + dgLoadCellDataFreshFlag = FALSE; + + return result; +} + +/*********************************************************************//** + * @brief + * The getTemperatureDataFreshFlag function returns a flag to indicate + * if the temperature data message reported by the DG is fresh or stale data. + * @details Inputs: dgDialysateTemperatureDataFreshFlag + * @details Outputs: dgDialysateTemperatureDataFreshFlag + * @return T/F flag to indicate fresh/stale status of load cell data. + *************************************************************************/ +BOOL getTemperatureDataFreshFlag( void ) // DN-19AUG2022 +{ + BOOL result = dgDialysateTemperatureDataFreshFlag; + + dgDialysateTemperatureDataFreshFlag = FALSE; + + return result; +} + +/*********************************************************************//** + * @brief + * The getReservoirsDataFreshFlag function returns a flag to indicate + * if the reservoirs data message reported by the DG is fresh or stale data. + * @details Inputs: dgReservoirsDataFreshFlag + * @details Outputs: dgReservoirsDataFreshFlag + * @return T/F flag to indicate fresh/stale status of load cell data. + *************************************************************************/ +BOOL getReservoirsDataFreshFlag( void ) // DN-22AUG2022 +{ + BOOL result = dgReservoirsDataFreshFlag; + + dgReservoirsDataFreshFlag = FALSE; + + return result; +} + +/*********************************************************************//** + * @brief + * The getDGOpModeDataFreshFlag function returns a flag to indicate + * if the dg op mode data message reported by the DG is fresh or stale data. + * @details Inputs: dgOpModeDataFreshFlag + * @details Outputs: dgOpModeDataFreshFlag + * @return T/F flag to indicate fresh/stale status of load cell data. + *************************************************************************/ +BOOL getDgOpModeDataFreshFlag( void ) // DN-22AUG2022 +{ + BOOL result = dgOpModeDataFreshFlag; + + dgOpModeDataFreshFlag = FALSE; + + return result; +} /*********************************************************************//** * @brief @@ -391,26 +520,26 @@ /*********************************************************************//** * @brief - * The getDialysateTemperature function gets the latest dialysate temperature. - * @details Inputs: dgDialysateTemp + * The getDGDisinfectsStates function returns the DG disinfects readings. + * @details Inputs: none * @details Outputs: none - * @return the current dialysate temperature + * @return the current DG disinfects readings *************************************************************************/ -F32 getDialysateTemperature( void ) +DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) { - return dgDialysateTemp; + return disinfectsStatus; } /*********************************************************************//** * @brief - * The getDGDisinfectsStates function returns the DG disinfects readings. - * @details Inputs: none + * The getDialysateTemperature function gets the latest dialysate temperature. + * @details Inputs: dgDialysateTemp * @details Outputs: none - * @return the current DG disinfects readings + * @return the current dialysate temperature *************************************************************************/ -DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ) +F32 getDialysateTemperature( void ) { - return disinfectsStatus; + return dgDialysateTemp; } /*********************************************************************//** @@ -452,7 +581,7 @@ * @return none *************************************************************************/ void setDGOpMode( U32 opMode, U32 subMode ) -{ +{ if ( opMode < NUM_OF_DG_MODES ) { dgCurrentOpMode = (DG_OP_MODE_T)opMode; @@ -461,7 +590,9 @@ else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_DG_OPERATING_MODE, opMode ); - } + } + + dgOpModeDataFreshFlag = TRUE; } /*********************************************************************//** @@ -475,9 +606,11 @@ * @return none *************************************************************************/ void setDialysateTemperatureReadings( F32 temp1, F32 temp2 ) -{ - dgDialysateTemp = temp1; - dgRedundantDialysateTemp = temp2; +{ + dgDialysateTemp = temp1; + dgRedundantDialysateTemp = temp2; + + dgDialysateTemperatureDataFreshFlag = TRUE; } /*********************************************************************//** @@ -492,7 +625,7 @@ * @return none *************************************************************************/ void setDGReservoirsData( DG_RESERVOIR_ID_T resID, U32 fillVol, U32 drainVol ) -{ +{ if ( resID < NUM_OF_DG_RESERVOIRS ) { dgActiveReservoir = resID; @@ -502,7 +635,9 @@ else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_RESERVOIR_ID, resID ); - } + } + + dgReservoirsDataFreshFlag = TRUE; } /*********************************************************************//** @@ -570,6 +705,8 @@ // Update Dialysis sub-mode with new reservoir volumes updateReservoirVolumes( res1Primary, res2Primary ); + + dgLoadCellDataFreshFlag = TRUE; } /*********************************************************************//** @@ -949,6 +1086,19 @@ /*********************************************************************//** * @brief + * The cmdSetDGToServiceMode function sends a request to DG to transition + * to service mode. + * @details Inputs: none + * @details Outputs: none + * @return none + *************************************************************************/ +void cmdSetDGToServiceMode( void ) +{ + sendDGServiceModeRequest(); +} + +/*********************************************************************//** + * @brief * The handleDGCommandResponse function processes the latest DG command response. * @details Inputs: none * @details Outputs: process command response from DG Index: firmware/App/Controllers/DGInterface.h =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Controllers/DGInterface.h (.../DGInterface.h) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -7,8 +7,8 @@ * * @file DGInterface.h * -* @author (last) Dara Navaei -* @date (last) 15-Jul-2022 +* @author (last) Michael Garthwaite +* @date (last) 08-Aug-2022 * * @author (original) Sean * @date (original) 08-Apr-2020 @@ -138,13 +138,15 @@ DG_RESERVOIR_ID_T getDGInactiveReservoir( void ); BOOL hasDGCompletedReservoirSwitch( void ); BOOL getDialysateFlowDataFreshFlag( void ); +BOOL getLoadCellDataFreshFlag( void ); F32 getDGDialysateFlowRateLMin( void ); F32 getLoadCellWeight( LOAD_CELL_ID_T loadCellID ); F32 getReservoirWeight( DG_RESERVOIR_ID_T resID ); F32 getReservoirWeightLargeFilter( DG_RESERVOIR_ID_T resID ); F32 getReservoirBackupWeightLargeFilter( DG_RESERVOIR_ID_T resID ); F32 getDialysateTemperature( void ); DG_DISINFECT_UI_STATES_T getDGDisinfectsStates( void ); +F32 getDialysateTemperature( void ); DG_MIXING_RATIOS_T getDGMixingRatios( void ); void getHDVersionDGServiceAndUsageData( DG_SERVICE_AND_USAGE_DATA_T* data ); @@ -177,6 +179,7 @@ void cmdStartDGChemicalDisinfect( void ); void cmdStopDGChemicalDisinfect( void ); void cmdRequestDGMixingRatios( void ); +void cmdSetDGToServiceMode( void ); void handleDGCommandResponse( DG_CMD_RESPONSE_T *dgCmdRespPtr ); BOOL getDGCommandResponse( U32 commandID, DG_CMD_RESPONSE_T *cmdRespPtr ); Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -117,6 +117,8 @@ *************************************************************************/ U32 transitionToStandbyMode( void ) { + HD_OP_MODE_T previousOpMode = getPreviousOperationMode(); + // Re-initialize when transitioning to standby mode initStandbyMode(); initDGInterface(); @@ -143,6 +145,11 @@ setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); + // If we just exited Post Treatment Mode, goto disinfect sub state. + if ( MODE_POST == previousOpMode ) + { + currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; + } // Request DG service record and usage information from DG sendDGServiceRequestToDG(); sendDGUsageInfoRequestToDG(); @@ -420,28 +427,49 @@ * initiation of setting the disinfects submode. * @details Inputs: currentStandbyState * @details Outputs: currentStandbyState + * @param cmd initiate (1) or cancel (0) * @return TRUE if signal accepted, FALSE if not *************************************************************************/ -BOOL signalInitiateStandbyDisinfectSubmode( void ) +BOOL signalInitiateStandbyDisinfectSubmode( U32 cmd ) { BOOL result = FALSE; REQUEST_REJECT_REASON_CODE_T rejReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; - if ( ( MODE_STAN == getCurrentOperationMode() ) && ( STANDBY_WAIT_FOR_TREATMENT_STATE == currentStandbyState ) ) + if ( cmd == 0 ) { - if ( TRUE == isDGCommunicating() ) + // Cancel Disinfect command + if ( STANDBY_WAIT_FOR_DISINFECT_STATE == currentStandbyState ) { - currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; + currentStandbyState = STANDBY_WAIT_FOR_TREATMENT_STATE; result = TRUE; rejReason = REQUEST_REJECT_REASON_NONE; } else { - rejReason = REQUEST_REJECT_REASON_DG_COMM_LOST; + result = FALSE; + rejReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; } } + else + { + // Initiate Disinfect command + if ( ( MODE_STAN == getCurrentOperationMode() ) && ( STANDBY_WAIT_FOR_TREATMENT_STATE == currentStandbyState ) ) + { + if ( TRUE == isDGCommunicating() ) + { + currentStandbyState = STANDBY_WAIT_FOR_DISINFECT_STATE; + result = TRUE; + rejReason = REQUEST_REJECT_REASON_NONE; + } + else + { + result = FALSE; + rejReason = REQUEST_REJECT_REASON_DG_COMM_LOST; + } + } + } - sendDisinfectConfirmResponse( result, rejReason ); + handleSetHDStandbyDisinfectSubmodeResponse( result, rejReason ); return result; } @@ -636,6 +664,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_DG_FLUSH_IN_PROGRESS_STATE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DISINFECT_FLUSH, 0 ); } return state; @@ -657,6 +686,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_WAIT_FOR_TREATMENT_STATE; + clearAlarm( ALARM_ID_HD_DISINFECT_FLUSH ); } publishDisinfectData(); @@ -712,6 +742,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_DG_HEAT_DISINFECT_IN_PROGRESS_STATE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DISINFECT_HEAT, 0 ); } return state; @@ -733,6 +764,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_WAIT_FOR_TREATMENT_STATE; + clearAlarm( ALARM_ID_HD_DISINFECT_HEAT ); } publishDisinfectData(); @@ -789,6 +821,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_DG_CHEM_DISINFECT_IN_PROGRESS_STATE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DISINFECT_CHEM, 0 ); } return state; @@ -810,6 +843,7 @@ { dgDisinfectState = DG_DISINFECT_NOT_RUNNING_STATE; state = STANDBY_WAIT_FOR_TREATMENT_STATE; + clearAlarm( ALARM_ID_HD_DISINFECT_CHEM ); } publishDisinfectData(); Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -7,8 +7,8 @@ * * @file SystemComm.c * -* @author (last) Dara Navaei -* @date (last) 03-Aug-2022 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -55,7 +55,7 @@ #define MSG_NOT_ACKED_MAX_RETRIES 20 ///< Maximum number of times a message that requires ACK that was not ACK'd can be re-sent before alarm #define PENDING_ACK_LIST_SIZE 25 ///< Maximum number of Denali messages that can be pending ACK at any given time - + #pragma pack(push, 1) /// Record for transmitted message that is pending acknowledgment from receiver. @@ -95,6 +95,7 @@ COMM_BUFFER_IN_CAN_UI_BROADCAST, COMM_BUFFER_IN_CAN_PC, }; +//extern U32 loadcellDataMessageFreshStatusCounter = 0; ///< Counter use to trigger alarm if no fresh load cell data message is received - DN-22AUG2022 static U08 lastCANPacketSent[ CAN_MESSAGE_PAYLOAD_SIZE ]; ///< Keep last packet sent on CAN bus in case we need to re-send. static CAN_MESSAGE_BOX_T lastCANPacketSentChannel = (CAN_MESSAGE_BOX_T)0; ///< Keep channel last packet was sent on CAN bus in case we need to re-send. @@ -256,7 +257,7 @@ * @return none *************************************************************************/ void execSystemCommRx( void ) -{ +{ // Parse messages from comm buffers and queue them processIncomingData(); @@ -698,7 +699,7 @@ { BOOL isThereMsgRcvd = TRUE; // Assume TRUE at first to get into while loop MESSAGE_WRAPPER_T message; - + while ( TRUE == isThereMsgRcvd ) { // See if any messages received @@ -1622,10 +1623,6 @@ handleTestSyringePumpHeprinBolusTargetRateOverrideRequest( message ); break; - case MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS: - handleTestCurrentTreamtmentParametersRequest( message ); - break; - case MSG_ID_HD_FANS_DUTY_CYCLE_OVERRIDE: handleSetFansDutyCycleOverrideRequest( message ); break; @@ -1658,10 +1655,11 @@ handleSetBloodLeakEmbeddedModeCommand( message ); break; - case MSG_ID_HD_SEND_ALARMS_COMMAND: - handleResendAllAlarmsCommand( message ); + case MSG_ID_HD_REQ_CURRENT_TREATMENT_PARAMETERS: + handleTestCurrentTreamtmentParametersRequest( message ); break; + // The default cannot be reached in VectorCAST since the cases are run in a for loop default: // Unrecognized message ID received - ignore Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.c * -* @author (last) Bill Bracken -* @date (last) 22-Aug-2022 +* @author (last) Michael Garthwaite +* @date (last) 07-Sep-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -43,7 +43,10 @@ #include "Valves.h" #include "WatchdogMgmt.h" #include "HDDefs.h" +#include "TaskPriority.h" +#include "TaskPriority.h" + /** * @addtogroup SystemCommMessages * @{ @@ -62,9 +65,9 @@ #pragma pack(pop) // ********** private data ********** - static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. + /// List of message IDs that are requested not to be transmitted. static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -889,24 +892,26 @@ /*********************************************************************//** * @brief - * The handleSetHDStandbyDisinfectSubmode function handles setting the + * The handleSetHDStandbyDisinfectSubmodeRequest function handles setting the * standby submode to wait for disisnfect state. - * @details Inputs: none + * @details Inputs: 1=initiate, 0=cancel * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleSetHDStandbyDisinfectSubmodeRequest( MESSAGE_T *message ) { - BOOL result = FALSE; + U32 cmd; - // The payload should be 0 in this case because there is mode in this command - if ( 0 == message->hdr.payloadLen ) + if ( sizeof( U32 ) == message->hdr.payloadLen ) { - signalInitiateStandbyDisinfectSubmode(); + memcpy( &cmd, &message->payload[0], sizeof( U32 ) ); + signalInitiateStandbyDisinfectSubmode( cmd ); } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); + else + { + handleSetHDStandbyDisinfectSubmodeResponse( FALSE, REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT ); + } } /*********************************************************************//** @@ -2349,13 +2354,13 @@ { TEMPERATURE_SENSORS_DATA_T payload; - memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); - } - // TODO - what to do if invalid payload length? - // TODO - how to know if DG stops sending these? -} - + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + } + // TODO - what to do if invalid payload length? + // TODO - how to know if DG stops sending these? +} + /*********************************************************************//** * @brief * The handleDialysateFlowData function handles dialysate flow data broadcast @@ -5148,6 +5153,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); @@ -7023,15 +7029,26 @@ { BOOL status = FALSE; HD_OP_MODE_T currentMode = getCurrentOperationMode(); + DG_OP_MODE_T currentDGMode = getDGOpMode(); REQUEST_REJECT_REASON_CODE_T reject; if ( 0 == message->hdr.payloadLen ) { if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) { - status = TRUE; + requestNewOperationMode( MODE_SERV ); - reject = REQUEST_REJECT_REASON_NONE; + + if ( (DG_MODE_STAN == currentDGMode) || (DG_MODE_FAUL == currentDGMode) ) + { + status = TRUE; + cmdSetDGToServiceMode(); + reject = REQUEST_REJECT_REASON_NONE; + } + else + { + reject = REQUEST_REJECT_REASON_DG_NOT_IN_STANDBY_IDLE_STATE; + } } else { @@ -7399,4 +7416,28 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } +/*********************************************************************//** + * @brief + * The sendDGServiceModeRequest function constructs a service mode request msg + * to the DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG Service mode request msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGServiceModeRequest() +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_REQUEST_DG_SERVICE_MODE; + msg.hdr.payloadLen = 0; + + // 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_HD_2_DG, ACK_REQUIRED ); + + return result; +} + /**@}*/ Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500 -r2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 0bce81180c0ba2b25f5d501ed6aa6b2f9a8b2500) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 2cb4ff0f8a0ad74826c5c9b4d0e84c6334c960d6) @@ -7,8 +7,8 @@ * * @file SystemCommMessages.h * -* @author (last) Dara Navaei -* @date (last) 03-Aug-2022 +* @author (last) Michael Garthwaite +* @date (last) 08-Aug-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -398,6 +398,15 @@ // MSG_ID_DG_START_STOP_CHEM_DISINFECT BOOL sendDGStartChemicalDisinfectModeCommand( BOOL start ); +// MSG_ID_HD_RESPONSE_SERVICE_MODE_REQUEST +void sendUIServiceModeResponse( BOOL accepted, U32 rejCode ); + +// MSG_ID_HD_REQUEST_DG_SERVICE_MODE +BOOL sendDGServiceModeRequest( void ); + +// MSG_ID_UI_REQUEST_SERVICE_MODE +void handleUIServiceModeRequest( MESSAGE_T *message ); + // MSG_ID_ALARM_STATUS BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ); @@ -425,9 +434,6 @@ // MSG_ID_HD_SET_SW_CONFIG_RECORD void handleSetHDSoftwareConfigRecord( MESSAGE_T *message ); -// MSG_ID_UI_REQUEST_SERVICE_MODE -void handleUIServiceModeRequest( MESSAGE_T *message ); -void sendUIServiceModeResponse( BOOL accepted, U32 rejCode ); // MSG_ID_HD_REQUEST_DG_ALARMS BOOL sendRequestForDGResendAlarms( void );