Index: firmware/App/Controllers/BloodLeak.c =================================================================== diff -u -radde281467e093774f5fa84419a1476b5b2bf52c -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision adde281467e093774f5fa84419a1476b5b2bf52c) +++ firmware/App/Controllers/BloodLeak.c (.../BloodLeak.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -8,7 +8,7 @@ * @file BloodLeak.c * * @author (last) Dara Navaei -* @date (last) 13-Sep-2023 +* @date (last) 10-Oct-2023 * * @author (original) Peman Montazemi * @date (original) 18-Mar-2021 @@ -1142,43 +1142,42 @@ U08 expChar1 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar1; U08 expChar2 = bloodLeakEmbModeCmd[ bloodLeakEmbModeRqstedCmd ].expChar2; - if ( ( expChar1 != NU_EMB_MODE_CMD ) && ( NU_EMB_MODE_CMD == expChar2 ) ) + if ( expChar1 != NU_EMB_MODE_CMD ) { // This is the case that there is a start character. If current character buffer index is less than the // length of the expected response of the command. if ( bloodLeakEmbModeRespIndex < length ) { - // Check if the expected char is received and the response buffer is empty because the index is 0, - // insert the buffer data - if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + if ( NU_EMB_MODE_CMD == expChar2 ) { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; + // Check if the expected char is received and the response buffer is empty because the index is 0, + // insert the buffer data + if ( ( expChar1 == data ) && ( 0 == bloodLeakEmbModeRespIndex ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } + // Check if the buffer index is cd ve> 0 so the first char has been inserted and the rest is data but it is not the echo of the command + // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. + else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } } - // Check if the buffer index is > 0 so the first char has been inserted and the rest is data but it is not the echo of the command - // For instance, V has been inserted and XXXX is inserted that is followed by V. So V123 and not VVV12. - else if ( ( bloodLeakEmbModeRespIndex > 0 ) && ( data != expChar1 ) ) + else { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; + // Check if either of the expected chars are received and if they are insert it into the response buffer + if ( ( expChar1 == data ) || ( expChar2 == data ) ) + { + bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; + bloodLeakEmbModeRespIndex++; + } } } } - else if ( ( expChar1 != NU_EMB_MODE_CMD ) && ( expChar2 != NU_EMB_MODE_CMD ) ) + else { - // This is the case that both expected chars are not null. Either of the chars are accepted like P or F - if ( bloodLeakEmbModeRespIndex < length ) - { - // Check if either of the expected chars are received and if they are insert it into the response buffer - if ( ( expChar1 == data ) || ( expChar2 == data ) ) - { - bloodLeakEmbModeRespBuffer[ bloodLeakEmbModeRespIndex ] = data; - bloodLeakEmbModeRespIndex++; - } - } - } - else if ( ( NU_EMB_MODE_CMD == expChar1 ) && ( NU_EMB_MODE_CMD == expChar2 ) ) - { // This is the case that there are no expected characters and the received value are numbers if ( bloodLeakEmbModeRespIndex < length ) { Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -raea9486b1cc38cf96f6ebd983ecd411ba45229bf -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision aea9486b1cc38cf96f6ebd983ecd411ba45229bf) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -166,10 +166,12 @@ #define SYRINGE_PUMP_STALL_SPEED_THRESHOLD 0.05F ///< Minimum syringe pump speed to be considered not stalled. #define SYRINGE_PUMP_ADC_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Syringe pump ADC FPGA error timeout in milliseconds. + #define SYRINGE_PUMP_DAC_MAX_RETRIES 5 ///< Syringe pump DAC retries to write. #define SYRINGE_PUMP_DAC_TIMER ( 200 / TASK_PRIORITY_INTERVAL ) ///< Syringe pump DAC timer between retries. #define SYRINGE_PUMP_OCCLUSION_PERSISTENCE 50 ///< Syringe pump occlusion persistence timer in milliseconds. #define SYRINGE_PUMP_EMPTY_FORCE_COUNT 5 ///< Syringe pump empty force voltage count persistence. + /// Defined states for the syringe pump control state machine. typedef enum SyringePump_States { @@ -349,6 +351,7 @@ initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_CONTROLLER_DIRECTION_ERROR, 0, SYRINGE_PUMP_DIR_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR, 0, SYRINGE_PUMP_OFF_ALARM_PERSISTENCE ); initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_SPEED_ERROR, 0, SYRINGE_PUMP_RATE_ALARM_PERSISTENCE ); + initPersistentAlarm( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION, 0, SYRINGE_PUMP_OCCLUSION_PERSISTENCE); initTimeWindowedCount( TIME_WINDOWED_COUNT_SYRINGE_PUMP_OFF_ERROR, SYRINGE_PUMP_OFF_ERROR_MAX_CNT, SYRINGE_PUMP_OFF_ERROR_TIME_WIN_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_SYRINGE_PUMP_ADC, ALARM_ID_HD_SYRINGE_PUMP_FPGA_ADC_FAULT, Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -raea9486b1cc38cf96f6ebd983ecd411ba45229bf -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision aea9486b1cc38cf96f6ebd983ecd411ba45229bf) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -1203,31 +1203,34 @@ maxDeviation = MAX_DEVIATION_FROM_TRAGET_IN_POS_B; } - // Check if the current position has deviated from the position it is supposed to be in - // For more than a certain amount of time. If it has, raise an alarm - // Absolute value is used for comparison to cover +/- from the commanded position - if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + if ( FALSE == isACPowerLost() ) { - valvesStatus[ valve ].positionOutOfRangeCounter++; - } + // Check if the current position has deviated from the position it is supposed to be in + // For more than a certain amount of time. If it has, raise an alarm + // Absolute value is used for comparison to cover +/- from the commanded position + if ( abs( currentPosition - commandedPosition ) > maxDeviation ) + { + valvesStatus[ valve ].positionOutOfRangeCounter++; + } - if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) - { - // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. - // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here - // because this is a monitor function that is called in the controller function. - valvesStatus[ valve ].execState = VALVE_STATE_IDLE; - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); + if ( valvesStatus[ valve ].positionOutOfRangeCounter > MAX_POS_DEVIATION_TIME_INTERVAL_COUNTER ) + { + // If the valve's deviation from target was more than the counts for the define period of time trigger the alarm. + // Also, set the state to Idle so in the fault mode, the valve can transition to Pos C. The exec state is directly set here + // because this is a monitor function that is called in the controller function. + valvesStatus[ valve ].execState = VALVE_STATE_IDLE; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_VALVE_POSITION_OUT_OF_RANGE, (U32)valve, currentPosition ); - if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + if ( VALVE_POSITION_C_CLOSE == valvesStatus[ valve ].commandedPosition ) + { + activateSafetyShutdown(); + } + } + else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) { - activateSafetyShutdown(); + valvesStatus[ valve ].positionOutOfRangeCounter = 0; } } - else if ( ( TRUE == isValveCloseToCommandedPosition( valve, commandedPositionEnum ) ) && ( valvesStatus[ valve ].positionOutOfRangeCounter > 0 ) ) - { - valvesStatus[ valve ].positionOutOfRangeCounter = 0; - } } else { Index: firmware/App/Drivers/Battery.c =================================================================== diff -u -raea9486b1cc38cf96f6ebd983ecd411ba45229bf -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Drivers/Battery.c (.../Battery.c) (revision aea9486b1cc38cf96f6ebd983ecd411ba45229bf) +++ firmware/App/Drivers/Battery.c (.../Battery.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -204,6 +204,7 @@ if ( TRUE == didTimeout( lastBatteryMonitorTime, BATTERY_MONITOR_INTERVAL_MS ) ) { lastBatteryMonitorTime = getMSTimerCount(); + getBatteryManagementData(); } } Index: firmware/App/HDCommon.h =================================================================== diff -u -r8d632beee12193c2ae9aa899263b39e310bcdbf7 -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/HDCommon.h (.../HDCommon.h) (revision 8d632beee12193c2ae9aa899263b39e310bcdbf7) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -10,8 +10,8 @@ * @author (last) Sean Nash * @date (last) 24-Aug-2023 * -* @author (original) Sean -* @date (original) 27-Feb-2020 +* @author (original) Sean +* @date (original) 27-Feb-2020 * ***************************************************************************/ @@ -25,7 +25,7 @@ #define HD_VERSION_MAJOR 0 #define HD_VERSION_MINOR 9 #define HD_VERSION_MICRO 0 -#define HD_VERSION_BUILD 276 +#define HD_VERSION_BUILD 780 // ********** development build switches ********** Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -raea9486b1cc38cf96f6ebd983ecd411ba45229bf -rd75fca5ec82e1dfe92df0c712b21dc3a98829d0e --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision aea9486b1cc38cf96f6ebd983ecd411ba45229bf) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d75fca5ec82e1dfe92df0c712b21dc3a98829d0e) @@ -76,6 +76,9 @@ /// Interval (in task intervals) at which to publish standby mode data to CAN bus. static OVERRIDE_U32_T standbyModePublishInterval = { DISINFECTS_DATA_PUB_INTERVAL, DISINFECTS_DATA_PUB_INTERVAL, DISINFECTS_DATA_PUB_INTERVAL, 0 }; +static const U32 SERVICE_TIME_INTERVAL_S = (U32)( 365 * 0.5 * SECONDS_IN_A_DAY ); ///< HD/DG 6-month service interval in seconds. +static BOOL homingInitiated; ///< Flag indicates actuator homing has been initiated from standby mode. + // ********** private function prototypes ********** static HD_STANDBY_STATE_T handleStandbyModeStartState( void );