Index: firmware/App/Controllers/BloodFlow.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/BloodFlow.h (.../BloodFlow.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -14,88 +14,88 @@ * @date (original) 07-Nov-2019 * ***************************************************************************/ - -#ifndef __BLOOD_FLOW_H__ -#define __BLOOD_FLOW_H__ - -#include "HDCommon.h" - -/** - * @defgroup BloodFlow BloodFlow - * @brief Blood Pump & Blood Flow controller/monitor module. Monitors the - * blood flow rate and controls the blood pump. - * - * @addtogroup BloodFlow - * @{ - */ - -// ********** public definitions ********** - -#define MAX_SET_BLOOD_FLOW_RATE 500 ///< Maximum blood flow rate (in mL/min). + +#ifndef __BLOOD_FLOW_H__ +#define __BLOOD_FLOW_H__ + +#include "HDCommon.h" + +/** + * @defgroup BloodFlow BloodFlow + * @brief Blood Pump & Blood Flow controller/monitor module. Monitors the + * blood flow rate and controls the blood pump. + * + * @addtogroup BloodFlow + * @{ + */ + +// ********** public definitions ********** + +#define MAX_SET_BLOOD_FLOW_RATE 500 ///< Maximum blood flow rate (in mL/min). #define MIN_SET_BLOOD_FLOW_RATE 100 ///< Minimum blood flow rate (in mL/min). #define SALINE_BOLUS_FLOW_RATE 150 ///< Saline bolus flow rate (in mL/min). -#define VOLUME_PER_BP_MOTOR_REV_ML 0.216F ///< Theoretical volume (mL) of blood/saline volume per motor revolution. +#define VOLUME_PER_BP_MOTOR_REV_ML 0.216F ///< Theoretical volume (mL) of blood/saline volume per motor revolution. #define BP_HALL_EDGE_COUNTS_PER_REV 48 ///< Number of hall sensor edge counts per motor revolution. - + /// Payload record structure for a blood pump data message. typedef struct { - S32 setPoint; - F32 measFlow; - F32 measRotorSpd; - F32 measPumpSpd; - F32 measMCSpd; - F32 measMCCurr; - F32 pwmDC; - U32 rotorCount; - U32 presFlow; - U32 rotorHall; + S32 setPoint; ///< Set point. + F32 measFlow; ///< Measured flow in mL/min. + F32 measRotorSpd; ///< Measured rotor speed in RPM. + F32 measPumpSpd; ///< Measured pump speed in RPM. + F32 measMCSpd; ///< Measured motor speed in RPM. + F32 measMCCurr; ///< Measure motor current in Amps. + F32 pwmDC; ///< Duty cycle. + U32 rotorCount; ///< Rotor count. + U32 presFlow; ///< Blood flow in mL/min. + U32 rotorHall; ///< Rotor hall in counts. } BLOOD_PUMP_STATUS_PAYLOAD_T; -// ********** public function prototypes ********** - -void initBloodFlow( void ); -void execBloodFlowMonitor( void ); -void execBloodFlowController( void ); - +// ********** public function prototypes ********** + +void initBloodFlow( void ); +void execBloodFlowMonitor( void ); +void execBloodFlowController( void ); + BOOL setBloodPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); -BOOL setBloodPumpTargetRPM( U32 rpm, MOTOR_DIR_T dir ); -void signalBloodPumpHardStop( void ); -void signalBloodPumpRotorHallSensor( void ); +BOOL setBloodPumpTargetRPM( U32 rpm, MOTOR_DIR_T dir ); +void signalBloodPumpHardStop( void ); +void signalBloodPumpRotorHallSensor( void ); BOOL homeBloodPump( void ); U32 getBloodPumpMotorCount( void ); U32 getBloodPumpRotorCount( void ); BOOL isBloodPumpRunning( void ); BOOL isBloodPumpRampComplete( void ); -void resetBloodPumpRotorCount( void ); - -SELF_TEST_STATUS_T execBloodFlowTest( void ); +void resetBloodPumpRotorCount( void ); -S32 getTargetBloodFlowRate( void ); -F32 getMeasuredBloodFlowRate( void ); +SELF_TEST_STATUS_T execBloodFlowTest( void ); + +S32 getTargetBloodFlowRate( void ); +F32 getMeasuredBloodFlowRate( void ); F32 getMeasuredBloodPumpRotorSpeed( void ); F32 getMeasuredBloodPumpSpeed( void ); F32 getMeasuredBloodPumpMCSpeed( void ); F32 getMeasuredBloodPumpMCCurrent( void ); -BOOL testSetBloodFlowDataPublishIntervalOverride( U32 value ); -BOOL testResetBloodFlowDataPublishIntervalOverride( void ); -BOOL testSetTargetBloodFlowRateOverride( S32 value, U32 bloodPumpControlMode ); -BOOL testSetMeasuredBloodFlowRateOverride( F32 value ); -BOOL testResetMeasuredBloodFlowRateOverride( void ); -BOOL testSetMeasuredBloodPumpRotorSpeedOverride( F32 value ); -BOOL testResetMeasuredBloodPumpRotorSpeedOverride( void ); -BOOL testSetMeasuredBloodPumpSpeedOverride( F32 value ); -BOOL testResetMeasuredBloodPumpSpeedOverride( void ); -BOOL testSetMeasuredBloodPumpMCSpeedOverride( F32 value ); -BOOL testResetMeasuredBloodPumpMCSpeedOverride( void ); -BOOL testSetMeasuredBloodPumpMCCurrentOverride( F32 value ); -BOOL testResetMeasuredBloodPumpMCCurrentOverride( void ); +BOOL testSetBloodFlowDataPublishIntervalOverride( U32 value ); +BOOL testResetBloodFlowDataPublishIntervalOverride( void ); +BOOL testSetTargetBloodFlowRateOverride( S32 value, U32 bloodPumpControlMode ); +BOOL testSetMeasuredBloodFlowRateOverride( F32 value ); +BOOL testResetMeasuredBloodFlowRateOverride( void ); +BOOL testSetMeasuredBloodPumpRotorSpeedOverride( F32 value ); +BOOL testResetMeasuredBloodPumpRotorSpeedOverride( void ); +BOOL testSetMeasuredBloodPumpSpeedOverride( F32 value ); +BOOL testResetMeasuredBloodPumpSpeedOverride( void ); +BOOL testSetMeasuredBloodPumpMCSpeedOverride( F32 value ); +BOOL testResetMeasuredBloodPumpMCSpeedOverride( void ); +BOOL testSetMeasuredBloodPumpMCCurrentOverride( F32 value ); +BOOL testResetMeasuredBloodPumpMCCurrentOverride( void ); BOOL testSetBloodPumpRotorCountOverride( U32 value ); BOOL testResetBloodPumpRotorCountOverride( void ); BOOL testSetBloodPumpTargetDutyCycle( F32 value ); - -/**@}*/ - -#endif + +/**@}*/ + +#endif Index: firmware/App/Controllers/BloodLeak.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/BloodLeak.h (.../BloodLeak.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -14,33 +14,33 @@ * @date (original) 18-Mar-2021 * ***************************************************************************/ - -#ifndef __BLOOD_LEAK_H__ -#define __BLOOD_LEAK_H__ - -#include "HDCommon.h" - -/** - * @defgroup BloodLeak BloodLeak - * @brief Blood Leak detector monitor module. Monitors the - * blood leak detector. + +#ifndef __BLOOD_LEAK_H__ +#define __BLOOD_LEAK_H__ + +#include "HDCommon.h" + +/** + * @defgroup BloodLeak BloodLeak + * @brief Blood Leak detector monitor module. Monitors the + * blood leak detector. * * INTROTEK - Blood Component Detector Part No. 105-0002 - * - * @addtogroup BloodLeak - * @{ - */ - -// ********** public definitions ********** - -/// Enumeration of blood leak detector status. -typedef enum BloodLeakDetectorStatus -{ - BLOOD_LEAK_DETECTED = 0, ///< Blood leak detector senses blood - BLOOD_LEAK_NOT_DETECTED, ///< Blood leak detector does not sense any blood - NUM_OF_BLOOD_LEAK_STATUS ///< Number of blood leak detector status -} BLOOD_LEAK_STATUS_T; + * + * @addtogroup BloodLeak + * @{ + */ +// ********** public definitions ********** + +/// Enumeration of blood leak detector status. +typedef enum BloodLeakDetectorStatus +{ + BLOOD_LEAK_DETECTED = 0, ///< Blood leak detector senses blood. + BLOOD_LEAK_NOT_DETECTED, ///< Blood leak detector does not sense any blood. + NUM_OF_BLOOD_LEAK_STATUS ///< Number of blood leak detector status. +} BLOOD_LEAK_STATUS_T; + /// Blood leak detector data publish typedef struct { @@ -50,8 +50,8 @@ U32 bloodLeakSerialCommState; ///< Blood leak detector serial communication state. } BLOOD_LEAK_DATA_T; -// ********** public function prototypes ********** - +// ********** public function prototypes ********** + void initBloodLeak( void ); void execBloodLeak( void ); void execBloodLeakEmbModeCommand( void ); @@ -62,19 +62,19 @@ void exitBloodLeakNormalState( void ); SELF_TEST_STATUS_T execBloodLeakSelfTest( void ); - + BLOOD_LEAK_STATUS_T getBloodLeakStatus( void ); SELF_TEST_STATUS_T getBloodLeakSelfTestStatus( void ); -BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ); +BOOL testSetBloodLeakDataPublishIntervalOverride( U32 value ); BOOL testResetBloodLeakDataPublishIntervalOverride( void ); - -BOOL testSetBloodLeakStatusOverride( BLOOD_LEAK_STATUS_T status ); + +BOOL testSetBloodLeakStatusOverride( BLOOD_LEAK_STATUS_T status ); BOOL testResetBloodLeakStatusOverride( void ); BOOL testSetBloodLeak2EmbeddedMode( void ); BOOL testSetBloodLeakEmbeddedModeCommand( U08 command, U16 setPointPayload ); -/**@}*/ - -#endif +/**@}*/ + +#endif Index: firmware/App/Controllers/DialInFlow.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/DialInFlow.h (.../DialInFlow.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -14,86 +14,86 @@ * @date (original) 16-Dec-2019 * ***************************************************************************/ - -#ifndef __DIALYSATE_IN_FLOW_H__ -#define __DIALYSATE_IN_FLOW_H__ - -#include "HDCommon.h" - -/** - * @defgroup DialysateInletFlow DialysateInletFlow - * @brief Dialysate Inlet Pump & Dialysate Flow controller/monitor module. - * Monitors the dialysate flow rate and controls the dialysate inlet pump. - * - * @addtogroup DialysateInletFlow - * @{ - */ - -// ********** public definitions ********** - -#define MAX_DIAL_IN_FLOW_RATE 600 ///< Maximum dialysate inlet flow rate (in mL/min). -#define MIN_DIAL_IN_FLOW_RATE 100 ///< Minimum dialysate inlet flow rate (in mL/min). + +#ifndef __DIALYSATE_IN_FLOW_H__ +#define __DIALYSATE_IN_FLOW_H__ + +#include "HDCommon.h" + +/** + * @defgroup DialysateInletFlow DialysateInletFlow + * @brief Dialysate Inlet Pump & Dialysate Flow controller/monitor module. + * Monitors the dialysate flow rate and controls the dialysate inlet pump. + * + * @addtogroup DialysateInletFlow + * @{ + */ + +// ********** public definitions ********** + +#define MAX_DIAL_IN_FLOW_RATE 600 ///< Maximum dialysate inlet flow rate (in mL/min). +#define MIN_DIAL_IN_FLOW_RATE 100 ///< Minimum dialysate inlet flow rate (in mL/min). #define DIALYSATE_FLOW_RATE_FOR_RECIRC 250 ///< Dialysate recirculation flow rate (in mL/min). - + /// Payload record structure for a dialysate inlet pump data message. typedef struct { - S32 setPoint; - F32 measFlow; - F32 measRotorSpd; - F32 measPumpSpd; - F32 measMCSpd; - F32 measMCCurr; - F32 pwmDC; - U32 rotorCount; - U32 presFlow; - U32 rotorHall; + S32 setPoint; ///< Set point. + F32 measFlow; ///< Measured flow in mL/min. + F32 measRotorSpd; ///< Measured rotor speed in RPM. + F32 measPumpSpd; ///< Measured pump speed in RPM. + F32 measMCSpd; ///< Measured motor speed in RPM. + F32 measMCCurr; ///< Measure motor current in Amps. + F32 pwmDC; ///< Duty cycle. + U32 rotorCount; ///< Rotor count. + U32 presFlow; ///< Dialysate in flow in mL/min. + U32 rotorHall; ///< Rotor hall in counts. } DIALIN_PUMP_STATUS_PAYLOAD_T; -// ********** public function prototypes ********** - -void initDialInFlow( void ); -void execDialInFlowMonitor( void ); -void execDialInFlowController( void ); - -BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); +// ********** public function prototypes ********** + +void initDialInFlow( void ); +void execDialInFlowMonitor( void ); +void execDialInFlowController( void ); + +BOOL setDialInPumpTargetFlowRate( U32 flowRate, MOTOR_DIR_T dir, PUMP_CONTROL_MODE_T mode ); BOOL setDialInPumpTargetRPM( U32 rpm, MOTOR_DIR_T dir ); -void signalDialInPumpHardStop( void ); +void signalDialInPumpHardStop( void ); void signalDialInPumpRotorHallSensor( void ); -BOOL homeDialInPump( void ); +BOOL homeDialInPump( void ); BOOL isDialInPumpRunning( void ); BOOL isDialInPumpRampComplete( void ); void resetDialInPumpRotorCount( void ); - -SELF_TEST_STATUS_T execDialInFlowTest( void ); - -S32 getTargetDialInFlowRate( void ); + +SELF_TEST_STATUS_T execDialInFlowTest( void ); + +S32 getTargetDialInFlowRate( void ); F32 getMeasuredDialInFlowRate( void ); -F32 getMeasuredDialInPumpRotorSpeed( void ); -F32 getMeasuredDialInPumpSpeed( void ); -F32 getMeasuredDialInPumpMCSpeed( void ); +F32 getMeasuredDialInPumpRotorSpeed( void ); +F32 getMeasuredDialInPumpSpeed( void ); +F32 getMeasuredDialInPumpMCSpeed( void ); F32 getMeasuredDialInPumpMCCurrent( void ); F32 getDialInPumpPWMDutyCyclePct( BOOL init ); U32 getDialInPumpRotorCount( void ); U32 getPumpRotorErrorPersistTime( F32 mtr_speed, F32 gear_ratio ); - -BOOL testSetDialInFlowDataPublishIntervalOverride( U32 value ); -BOOL testResetDialInFlowDataPublishIntervalOverride( void ); -BOOL testSetTargetDialInFlowRateOverride( S32 value, U32 ctrlMode ); -BOOL testSetMeasuredDialInFlowRateOverride( F32 value ); -BOOL testResetMeasuredDialInFlowRateOverride( void ); -BOOL testSetMeasuredDialInPumpRotorSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpRotorSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpMCSpeedOverride( F32 value ); -BOOL testResetMeasuredDialInPumpMCSpeedOverride( void ); -BOOL testSetMeasuredDialInPumpMCCurrentOverride( F32 value ); + +BOOL testSetDialInFlowDataPublishIntervalOverride( U32 value ); +BOOL testResetDialInFlowDataPublishIntervalOverride( void ); +BOOL testSetTargetDialInFlowRateOverride( S32 value, U32 ctrlMode ); +BOOL testSetMeasuredDialInFlowRateOverride( F32 value ); +BOOL testResetMeasuredDialInFlowRateOverride( void ); +BOOL testSetMeasuredDialInPumpRotorSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpRotorSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpMCSpeedOverride( F32 value ); +BOOL testResetMeasuredDialInPumpMCSpeedOverride( void ); +BOOL testSetMeasuredDialInPumpMCCurrentOverride( F32 value ); BOOL testResetMeasuredDialInPumpMCCurrentOverride( void ); BOOL testSetDialInPumpTargetDutyCycle( F32 value ); BOOL testSetDialysateInPumpRotorCountOverride( U32 value ); -BOOL testResetDialysateInPumpRotorCountOverride( void ); - -/**@}*/ - -#endif +BOOL testResetDialysateInPumpRotorCountOverride( void ); + +/**@}*/ + +#endif Index: firmware/App/Controllers/DialOutFlow.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Controllers/DialOutFlow.h (.../DialOutFlow.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/DialOutFlow.h (.../DialOutFlow.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -35,7 +35,7 @@ #pragma pack(push, 1) /// Dialysate outlet pump broadcast record -typedef struct DialOutBroadcastingRecord +typedef struct { F32 refUFVolMl; ///< Reference ultrafiltration volume in mL. F32 measUFVolMl; ///< Total measured ultrafiltration volume in mL. Index: firmware/App/Controllers/SyringePump.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -50,25 +50,25 @@ /// Payload record structure for the syringe pump operation request message. typedef struct { - U32 syringePumpOp; - F32 rate; - F32 volume; + U32 syringePumpOp; ///< Syringe pump operation. + F32 rate; ///< Syringe pump rate. + F32 volume; ///< Syringe pump volume. } SYRINGE_PUMP_OP_PAYLOAD_T; /// Payload record structure for the syringe pump data message. typedef struct { - U32 syringePumpState; - U32 heparinDeliveryState; - F32 syringePumpSetRate; - F32 syringePumpMeasRate; - S32 syringePumpPosition; - F32 syringePumpVolumeDelivered; - F32 syringePumpMeasHome; - F32 syringePumpMeasSwitch; - F32 syringePumpMeasForce; - F32 syringePumpSafetyVolume; - U32 syringePumpStatus; + U32 syringePumpState; ///< Syringe pump state. + U32 heparinDeliveryState; ///< Heparin delivery state. + F32 syringePumpSetRate; ///< Syringe pump set rate. + F32 syringePumpMeasRate; ///< Syringe pump measured rate. + S32 syringePumpPosition; ///< Syringe pump position. + F32 syringePumpVolumeDelivered; ///< Syringe pump volume delivered. + F32 syringePumpMeasHome; ///< Syringe pump measured home. + F32 syringePumpMeasSwitch; ///< Syringe pump measured switch. + F32 syringePumpMeasForce; ///< Syringe pump measured force. + F32 syringePumpSafetyVolume; ///< Syringe pump safety volume. + U32 syringePumpStatus; ///< Syringe pump status. } SYRINGE_PUMP_DATA_PAYLOAD_T; /// Heparin publish data structure Index: firmware/App/HDCommon.h =================================================================== diff -u -rbb3108b1103a861e1b6603978c6d91535cc8019b -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/HDCommon.h (.../HDCommon.h) (revision bb3108b1103a861e1b6603978c6d91535cc8019b) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -58,59 +58,59 @@ /// Payload record structure for an HD versions message. typedef struct { - U08 major; - U08 minor; - U08 micro; - U16 build; - U08 fpgaId; - U08 fpgaMajor; - U08 fpgaMinor; - U08 fpgaLab; - U32 compatibilityRev; + U08 major; ///< HD version major revision. + U08 minor; ///< HD version minor revision. + U08 micro; ///< HD version micro revision. + U16 build; ///< HD build version. + U08 fpgaId; ///< HD FPGA ID. + U08 fpgaMajor; ///< HD FPGA major revision. + U08 fpgaMinor; ///< HD FPGA minor revision. + U08 fpgaLab; ///< HD FPGA lab revision. + U32 compatibilityRev; ///< HD compatibility revision. } HD_VERSIONS_T; /// DG version struct. typedef struct { - U08 major; ///< DG version major revision - U08 minor; ///< DG version major revision - U08 micro; ///< DG version micro revision - U16 build; ///< DG build version - U08 fpgaId; ///< DG FPGA ID - U08 fpgaMajor; ///< DG FPGA major revision - U08 fpgaMinor; ///< DG FPGA minor revision - U08 fpgaLab; ///< DG FPGA lab revision - U32 compatibilityRev; ///< DG compatibility revision + U08 major; ///< DG version major revision. + U08 minor; ///< DG version major revision. + U08 micro; ///< DG version micro revision. + U16 build; ///< DG build version. + U08 fpgaId; ///< DG FPGA ID. + U08 fpgaMajor; ///< DG FPGA major revision. + U08 fpgaMinor; ///< DG FPGA minor revision. + U08 fpgaLab; ///< DG FPGA lab revision. + U32 compatibilityRev; ///< DG compatibility revision. } DG_VERSIONS_T; /// Record defining the fields in a UI version request message. typedef struct { - U08 major; ///< Major version for UI software - U08 minor; ///< Minor version for UI software - U08 micro; ///< Micro version for UI software - U16 build; ///< Build number for UI software - U32 compatibility; ///< Compatibility revision + U08 major; ///< Major version for UI software. + U08 minor; ///< Minor version for UI software. + U08 micro; ///< Micro version for UI software. + U16 build; ///< Build number for UI software. + U32 compatibility; ///< Compatibility revision. } UI_VERSIONS_T; /// Payload record structure for a peristaltic pump data message. typedef struct { - U32 setPoint; - F32 measFlow; - F32 measRotorSpd; - F32 measPumpSpd; - F32 measMCSpd; - F32 measMCCurr; - F32 pwmDC; + U32 setPoint; ///< Set point. + F32 measFlow; ///< Measured flow in mL/min. + F32 measRotorSpd; ///< Measured rotor speed in RPM. + F32 measPumpSpd; ///< Measured pump speed in RPM. + F32 measMCSpd; ///< Measured motor speed in RPM. + F32 measMCCurr; ///< Measured motor current in Amps. + F32 pwmDC; ///< Duty cycle. } PERISTALTIC_PUMP_STATUS_PAYLOAD_T; /// Payload record structure for a pump set point override message. typedef struct { - BOOL reset; - S32 setPt; - U32 ctrlMode; + BOOL reset; ///< Reset. + S32 setPt; ///< Set point. + U32 ctrlMode; ///< Control mode. } OVERRIDE_PUMP_SET_PT_PAYLOAD_T; #pragma pack(pop) Index: firmware/App/Modes/BloodPrime.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Modes/BloodPrime.h (.../BloodPrime.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Modes/BloodPrime.h (.../BloodPrime.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -41,8 +41,8 @@ /// Payload record structure for a blood prime data broadcast message. typedef struct { - F32 targetBloodPrimeVolumeMl; - F32 deliveredBloodPrimeVolumeMl; + F32 targetBloodPrimeVolumeMl; ///< Target blood prime volume in mL. + F32 deliveredBloodPrimeVolumeMl; ///< Delivered blood prime volume in mL. } BLOOD_PRIME_DATA_PAYLOAD_T; // ********** public function prototypes ********** Index: firmware/App/Modes/Dialysis.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Modes/Dialysis.h (.../Dialysis.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -41,9 +41,9 @@ /// Payload record structure for a saline bolus data broadcast message. typedef struct { - U32 tgtSalineVolumeMl; - F32 cumSalineVolumeMl; - F32 bolSalineVolumeMl; + U32 tgtSalineVolumeMl; ///< Target saline volume in mL. + F32 cumSalineVolumeMl; ///< Cumulative saline volume in mL. + F32 bolSalineVolumeMl; ///< Bolus saline volume in mL. } SALINE_BOLUS_DATA_PAYLOAD_T; #pragma pack(pop) Index: firmware/App/Modes/ModeTreatment.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Modes/ModeTreatment.h (.../ModeTreatment.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -36,59 +36,59 @@ /// Payload record structure for a treatment time status message. typedef struct { - U32 treatmentTimePrescribedinSec; - U32 treatmentTimeElapsedinSec; - U32 treatmentTimeRemaininginSec; + U32 treatmentTimePrescribedinSec; ///< Treatment time prescribed in seconds. + U32 treatmentTimeElapsedinSec; ///< Treatment time elapsed in seconds. + U32 treatmentTimeRemaininginSec; ///< Treatment time remaining in seconds. } TREATMENT_TIME_DATA_T; /// Payload record structure for a treatment state message. typedef struct { - U32 treatmentSubMode; - U32 uFState; - U32 salineBolusState; - U32 heparinState; - U32 rinsebackState; - U32 txRecircState; - U32 bldPrimeState; - U32 txEndState; - U32 txStopState; - U32 dialysisState; + U32 treatmentSubMode; ///< Treatment submode. + U32 uFState; ///< Ultrafiltration state. + U32 salineBolusState; ///< Saline bolus state. + U32 heparinState; ///< Heparin state. + U32 rinsebackState; ///< Rinse back state. + U32 txRecircState; ///< Treatment recirc state. + U32 bldPrimeState; ///< Blood prime state. + U32 txEndState; ///< Treatment end state. + U32 txStopState; ///< Treatment stop state. + U32 dialysisState; ///< Dialysis state. } TREATMENT_STATE_DATA_T; /// Payload record structure for an ultrafiltration volume change confirmation message. typedef struct { - F32 volume_mL; - U32 adjustType; + F32 volume_mL; ///< Volume in mL. + U32 adjustType; ///< Adjust type. } UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T; /// Payload record structure for the in-line pressure limits change request. typedef struct { - S32 artPresLimitWindowmmHg; - S32 venPresLimitWindowmmHg; - S32 venPresLimitAsymmetricmmHg; + S32 artPresLimitWindowmmHg; ///< Arterial pressure limit window in mmHg. + S32 venPresLimitWindowmmHg; ///< Venous pressure limit window in mmHg. + S32 venPresLimitAsymmetricmmHg; ///< Venous pressure limit asymmetric in mmHg. } PRESSURE_LIMIT_CHANGE_REQUEST_T; /// Payload record structure for the in-line pressure limits change response. typedef struct { - BOOL accepted; - U32 rejReasonCode; - S32 artPresLimitWindowmmHg; - S32 venPresLimitWindowmmHg; - S32 venPresLimitAsymmetricmmHg; + BOOL accepted; ///< Accepted. + U32 rejReasonCode; ///< Rejection reason code number. + S32 artPresLimitWindowmmHg; ///< Arterial pressure limit window in mmHg. + S32 venPresLimitWindowmmHg; ///< Venous pressure limit window in mmHg. + S32 venPresLimitAsymmetricmmHg; ///< Venous pressure limit asymmetric in mmHg. } PRESSURE_LIMIT_CHANGE_RESPONSE_T; /// Payload record structure for the treatment log 30 minutes periodic data. typedef struct { - F32 avgBloodFlowRate; - F32 avgDialysateFlowRate; - F32 avgUFRate; - F32 avgArterialPressure; - F32 avgVenousPressure; + F32 avgBloodFlowRate; ///< Average blood flow rate in mL/min. + F32 avgDialysateFlowRate; ///< Average dialysate flow rate in mL/min. + F32 avgUFRate; ///< Average ultrafiltration rate. + F32 avgArterialPressure; ///< Average arterial pressure in mmHg. + F32 avgVenousPressure; ///< Average venous pressure in mmHg. } TREATMENT_LOG_DATA_PERIODIC_T; /// Maximum time in this mode before blood sitting alarm given (in general task intervals). Index: firmware/App/Modes/Rinseback.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Modes/Rinseback.h (.../Rinseback.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Modes/Rinseback.h (.../Rinseback.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -39,12 +39,12 @@ /// Payload record structure for a rinseback data broadcast message. typedef struct { - F32 targetRinsebackVolumeMl; - F32 deliveredRinsebackVolumeMl; - U32 rinsebackFlowRateMlMin; - U32 timeout; - U32 countdown; - BOOL isCompleted; + F32 targetRinsebackVolumeMl; ///< Target rinse back volume in mL. + F32 deliveredRinsebackVolumeMl; ///< Delivered rinse back volume in mL. + U32 rinsebackFlowRateMlMin; ///< Rinse back flow rate in mL/min. + U32 timeout; ///< Timeout in milliseconds. + U32 countdown; ///< Countdown. + BOOL isCompleted; ///< Is completed. } RINSEBACK_DATA_PAYLOAD_T; #pragma pack(pop) Index: firmware/App/Services/Reservoirs.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Services/Reservoirs.h (.../Reservoirs.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -40,12 +40,12 @@ { U32 reservoirsExecState; ///< Reservoirs exec state. F32 activeReservoirUFVolML; ///< Active reservoir ultrafiltration volume milliliters. - F32 activeReservoirVolSpentML; - F32 dilLevelPct; - F32 recircLevelPct; - U32 timeDepletionMS; - U32 timeWaitFillMS; - F32 tempRemoveTargetFillFlow; + F32 activeReservoirVolSpentML; ///< Active reservoir volume spent in milliliters. + F32 dilLevelPct; ///< Dilution level in percent. + F32 recircLevelPct; ///< Recirculation level in percent. + U32 timeDepletionMS; ///< Time depletion in milliseconds. + U32 timeWaitFillMS; ///< Time wait to fill in milliseconds. + F32 tempRemoveTargetFillFlow; ///< Temperature target fill flow in C. } RESERVOIRS_MANAGEMENT_DATA_T; // ********** public function prototypes ********** Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -14,236 +14,236 @@ * @date (original) 05-Nov-2019 * ***************************************************************************/ - -#include // For memcpy() - -#include "can.h" -#include "sci.h" -#include "sys_dma.h" - -#include "Comm.h" -#include "Interrupts.h" + +#include // For memcpy() + +#include "can.h" +#include "sci.h" +#include "sys_dma.h" + +#include "Comm.h" +#include "Interrupts.h" #include "OperationModes.h" #include "SystemComm.h" #include "SystemCommMessages.h" #include "Interrupts.h" -#include "OperationModes.h" -#include "Timers.h" -#include "Utilities.h" - +#include "OperationModes.h" +#include "Timers.h" +#include "Utilities.h" + /** * @addtogroup SystemComm * @{ */ -// ********** private definitions ********** - -#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 7 ///< Number of CAN buffers for receiving +// ********** private definitions ********** + +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 7 ///< Number of CAN buffers for receiving #define NUM_OF_MSG_IN_BUFFERS 7 ///< Number of Msg buffers for receiving - -#define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< If transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on + +#define CAN_XMIT_PACKET_TIMEOUT_MS 200 ///< If transmitted CAN frame does not cause a transmit complete interrupt within this time, re-send or move on #define MAX_XMIT_RETRIES 5 ///< Maximum number of retries on no transmit complete interrupt timeout - + #define UI_COMM_TIMEOUT_IN_MS 7500 ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD. -#define UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS (2 * SEC_PER_MIN * MS_PER_SECOND) ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD when in service mode. -#define DG_COMM_TIMEOUT_IN_MS 1000 ///< DG has not checked in for this much time - -#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm -#define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window - -#define MSG_NOT_ACKED_TIMEOUT_MS 250 ///< Maximum time for a Denali message that requires ACK to be ACK'd +#define UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS (2 * SEC_PER_MIN * MS_PER_SECOND) ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD when in service mode. +#define DG_COMM_TIMEOUT_IN_MS 1000 ///< DG has not checked in for this much time -#define MSG_NOT_ACKED_MAX_RETRIES 10 ///< 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 +#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window +#define MSG_NOT_ACKED_TIMEOUT_MS 250 ///< Maximum time for a Denali message that requires ACK to be ACK'd + +#define MSG_NOT_ACKED_MAX_RETRIES 10 ///< 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 + #define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm #define MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< FPGA clock speed error window #define PENDING_ACK_LIST_OVERRIDE_UI_CHANNEL 1 ///< Value for determining UI channel when Pending ACKs are overriden. #define PENDING_ACK_LIST_OVERRIDE_DG_CHANNEL 2 ///< Value for determining DG channel when Pending ACKs are overriden. -#pragma pack(push, 1) - +#pragma pack(push, 1) + /// Record for transmitted message that is pending acknowledgment from receiver. -typedef struct -{ - BOOL used; - U16 seqNo; - U16 retries; - U32 timeStamp; - COMM_BUFFER_T channel; - U32 msgSize; - U08 msg[ MAX_ACK_MSG_SIZE ]; -} PENDING_ACK_RECORD_T; - -#pragma pack(pop) - -// ********** private data ********** - +typedef struct +{ + BOOL used; ///< Used. + U16 seqNo; ///< Message sequence number. + U16 retries; ///< Number of retries. + U32 timeStamp; ///< Time stamp. + COMM_BUFFER_T channel; ///< Channel ID. + U32 msgSize; ///< Message size. + U08 msg[ MAX_ACK_MSG_SIZE ]; ///< Message. +} PENDING_ACK_RECORD_T; + +#pragma pack(pop) + +// ********** private data ********** + /// Array of out-going CAN buffers. -const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = -{ - COMM_BUFFER_OUT_CAN_HD_ALARM, - COMM_BUFFER_OUT_CAN_HD_2_DG, - COMM_BUFFER_OUT_CAN_HD_2_UI, - COMM_BUFFER_OUT_CAN_HD_BROADCAST, - COMM_BUFFER_OUT_CAN_PC -}; - +const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = +{ + COMM_BUFFER_OUT_CAN_HD_ALARM, + COMM_BUFFER_OUT_CAN_HD_2_DG, + COMM_BUFFER_OUT_CAN_HD_2_UI, + COMM_BUFFER_OUT_CAN_HD_BROADCAST, + COMM_BUFFER_OUT_CAN_PC +}; + /// Array of in-coming CAN buffers. -const COMM_BUFFER_T MSG_IN_BUFFERS[ NUM_OF_MSG_IN_BUFFERS ] = -{ - COMM_BUFFER_IN_CAN_DG_ALARM, - COMM_BUFFER_IN_CAN_UI_ALARM, - COMM_BUFFER_IN_CAN_DG_2_HD, - COMM_BUFFER_IN_CAN_DG_BROADCAST, - COMM_BUFFER_IN_CAN_UI_2_HD, - COMM_BUFFER_IN_CAN_UI_BROADCAST, - COMM_BUFFER_IN_CAN_PC, -}; - -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. -static U32 lastCANPacketSentTimeStamp = 0; ///< Keep time last packet sent on CAN bus so we can timeout on transmission attempt. - -static volatile PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< List of outgoing messages that are awaiting an ACK - +const COMM_BUFFER_T MSG_IN_BUFFERS[ NUM_OF_MSG_IN_BUFFERS ] = +{ + COMM_BUFFER_IN_CAN_DG_ALARM, + COMM_BUFFER_IN_CAN_UI_ALARM, + COMM_BUFFER_IN_CAN_DG_2_HD, + COMM_BUFFER_IN_CAN_DG_BROADCAST, + COMM_BUFFER_IN_CAN_UI_2_HD, + COMM_BUFFER_IN_CAN_UI_BROADCAST, + COMM_BUFFER_IN_CAN_PC, +}; + +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. +static U32 lastCANPacketSentTimeStamp = 0; ///< Keep time last packet sent on CAN bus so we can timeout on transmission attempt. + +static volatile PENDING_ACK_RECORD_T pendingAckList[ PENDING_ACK_LIST_SIZE ]; ///< List of outgoing messages that are awaiting an ACK + static volatile BOOL hdIsOnlyCANNode = TRUE; ///< Flag indicating whether HD is alone on CAN bus. static U32 canXmitRetryCtr = 0; ///< Counter for CAN transmit retries. -static volatile BOOL dgIsCommunicating = FALSE; ///< Has DG sent a message since last check -static U32 timeOfLastDGCheckIn = 0; ///< Last time DG checked in -static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check -static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in +static volatile BOOL dgIsCommunicating = FALSE; ///< Has DG sent a message since last check +static U32 timeOfLastDGCheckIn = 0; ///< Last time DG checked in +static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check +static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in static volatile BOOL uiDidCommunicate = FALSE; ///< Has UI every sent a message -static OVERRIDE_U32_T pendingACKOverride = { 0, 0, 0, 0 }; ///< Pending ACK override data structure. - -// ********** private function prototypes ********** - -static void clearCANXmitBuffers( void ); - -static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ); -static U32 transmitNextCANPacket( void ); - -static void processIncomingData( void ); -static S32 parseMessageFromBuffer( U08 *data, U32 len ); -static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ); -static void processReceivedMessages( void ); -static void processReceivedMessage( MESSAGE_T *message ); - -static void checkForCommTimeouts( void ); -static void checkTooManyBadMsgCRCs( void ); - -static BOOL matchACKtoPendingACKList( S16 seqNo ); -static void checkPendingACKList( void ); - -/*********************************************************************//** - * @brief - * The initSystemComm function initializes the SystemComm module. - * @details Inputs: none - * @details Outputs: SystemComm module initialized. - * @return none - *************************************************************************/ -void initSystemComm( void ) -{ - U32 i; - +static OVERRIDE_U32_T pendingACKOverride = { 0, 0, 0, 0 }; ///< Pending ACK override data structure. + +// ********** private function prototypes ********** + +static void clearCANXmitBuffers( void ); + +static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ); +static U32 transmitNextCANPacket( void ); + +static void processIncomingData( void ); +static S32 parseMessageFromBuffer( U08 *data, U32 len ); +static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ); +static void processReceivedMessages( void ); +static void processReceivedMessage( MESSAGE_T *message ); + +static void checkForCommTimeouts( void ); +static void checkTooManyBadMsgCRCs( void ); + +static BOOL matchACKtoPendingACKList( S16 seqNo ); +static void checkPendingACKList( void ); + +/*********************************************************************//** + * @brief + * The initSystemComm function initializes the SystemComm module. + * @details Inputs: none + * @details Outputs: SystemComm module initialized. + * @return none + *************************************************************************/ +void initSystemComm( void ) +{ + U32 i; + // Initialize bad message CRC time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC, MAX_COMM_CRC_FAILURES, MAX_COMM_CRC_FAILURE_WINDOW_MS ); // Initialize FPGA clock speed error time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR, MAX_FPGA_CLOCK_SPEED_ERRORS, MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS); - - // Initialize pending ACK list - for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { - pendingAckList[ i ].used = FALSE; - } -} - -/*********************************************************************//** - * @brief - * The checkInFromDG function checks in the DG with the HD - indicating that - * the DG is communicating. - * @details Inputs: none - * @details Outputs: dgIsCommunicating - * @return none - *************************************************************************/ -void checkInFromDG( void ) -{ - dgIsCommunicating = TRUE; + + // Initialize pending ACK list + for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) + { + pendingAckList[ i ].used = FALSE; + } +} + +/*********************************************************************//** + * @brief + * The checkInFromDG function checks in the DG with the HD - indicating that + * the DG is communicating. + * @details Inputs: none + * @details Outputs: dgIsCommunicating + * @return none + *************************************************************************/ +void checkInFromDG( void ) +{ + dgIsCommunicating = TRUE; timeOfLastDGCheckIn = getMSTimerCount(); if ( TRUE == isAlarmActive( ALARM_ID_HD_DG_COMM_TIMEOUT ) ) { clearAlarmCondition( ALARM_ID_HD_DG_COMM_TIMEOUT ); - } -} - -/*********************************************************************//** - * @brief - * The checkInFromUI function checks in the UI with the HD - indicating that - * the UI is communicating. - * @details Inputs: none - * @details Outputs: uiIsCommunicating - * @return none - *************************************************************************/ -void checkInFromUI( void ) -{ + } +} + +/*********************************************************************//** + * @brief + * The checkInFromUI function checks in the UI with the HD - indicating that + * the UI is communicating. + * @details Inputs: none + * @details Outputs: uiIsCommunicating + * @return none + *************************************************************************/ +void checkInFromUI( void ) +{ if ( FALSE == uiDidCommunicate ) { // Start DG check-in timer when UI first communicates timeOfLastDGCheckIn = getMSTimerCount(); } - - uiIsCommunicating = TRUE; - timeOfLastUICheckIn = getMSTimerCount(); - uiDidCommunicate = TRUE; -} - -/*********************************************************************//** - * @brief - * The isDGCommunicating function determines whether the DG is communicating - * with the HD. - * @details Inputs: dgIsCommunicating - * @details Outputs: none - * @return TRUE if DG has checked in since last call, FALSE if not - *************************************************************************/ -BOOL isDGCommunicating( void ) -{ - return dgIsCommunicating; -} - -/*********************************************************************//** - * @brief - * The isUICommunicating function determines whether the UI is communicating - * with the HD. - * @details Inputs: uiIsCommunicating - * @details Outputs: none - * @return TRUE if UI has checked in since last call, FALSE if not - *************************************************************************/ -BOOL isUICommunicating( void ) -{ - BOOL result = uiIsCommunicating; - - uiIsCommunicating = FALSE; - - return result; -} - -/*********************************************************************//** - * @brief - * The uiCommunicated function determines whether the UI has communicated. - * @details Inputs: none - * @details Outputs: none - * @return TRUE if UI has communicated since power up, FALSE if not - *************************************************************************/ -BOOL uiCommunicated( void ) + + uiIsCommunicating = TRUE; + timeOfLastUICheckIn = getMSTimerCount(); + uiDidCommunicate = TRUE; +} + +/*********************************************************************//** + * @brief + * The isDGCommunicating function determines whether the DG is communicating + * with the HD. + * @details Inputs: dgIsCommunicating + * @details Outputs: none + * @return TRUE if DG has checked in since last call, FALSE if not + *************************************************************************/ +BOOL isDGCommunicating( void ) { + return dgIsCommunicating; +} + +/*********************************************************************//** + * @brief + * The isUICommunicating function determines whether the UI is communicating + * with the HD. + * @details Inputs: uiIsCommunicating + * @details Outputs: none + * @return TRUE if UI has checked in since last call, FALSE if not + *************************************************************************/ +BOOL isUICommunicating( void ) +{ + BOOL result = uiIsCommunicating; + + uiIsCommunicating = FALSE; + + return result; +} + +/*********************************************************************//** + * @brief + * The uiCommunicated function determines whether the UI has communicated. + * @details Inputs: none + * @details Outputs: none + * @return TRUE if UI has communicated since power up, FALSE if not + *************************************************************************/ +BOOL uiCommunicated( void ) +{ #ifdef SIMULATE_UI uiDidCommunicate = TRUE; #endif - - return uiDidCommunicate; + + return uiDidCommunicate; } /*********************************************************************//** @@ -257,46 +257,46 @@ BOOL isHDOnlyCANNode( void ) { return hdIsOnlyCANNode; -} - -/*********************************************************************//** - * @brief - * The execSystemCommRx function manages received data from other sub-systems. - * @details Inputs: none - * @details Outputs: Incoming messages parsed and processed. - * @return none - *************************************************************************/ -void execSystemCommRx( void ) +} + +/*********************************************************************//** + * @brief + * The execSystemCommRx function manages received data from other sub-systems. + * @details Inputs: none + * @details Outputs: Incoming messages parsed and processed. + * @return none + *************************************************************************/ +void execSystemCommRx( void ) { - // Parse messages from comm buffers and queue them - processIncomingData(); - - // Process received messages in the queue - processReceivedMessages(); - - // Check for sub-system comm timeouts - checkForCommTimeouts(); - - // Check ACK list for messages that need to be re-sent because they have not been ACK'd + // Parse messages from comm buffers and queue them + processIncomingData(); + + // Process received messages in the queue + processReceivedMessages(); + + // Check for sub-system comm timeouts + checkForCommTimeouts(); + + // Check ACK list for messages that need to be re-sent because they have not been ACK'd checkPendingACKList(); if ( TRUE == hasDialinCheckInExpired() ) { // It has been a while since the user logged in but not activity has been received from Dialin so set the tester's status to log out setTesterStatusToLoggedOut(); - } -} - -/*********************************************************************//** - * @brief - * The execSystemCommTx function manages data to be transmitted to other - * sub-systems. - * @details Inputs: none - * @details Outputs: Outgoing messages transmitted. - * @return none - *************************************************************************/ -void execSystemCommTx( void ) -{ + } +} + +/*********************************************************************//** + * @brief + * The execSystemCommTx function manages data to be transmitted to other + * sub-systems. + * @details Inputs: none + * @details Outputs: Outgoing messages transmitted. + * @return none + *************************************************************************/ +void execSystemCommTx( void ) +{ // Do not transmit if no other nodes on CAN bus if ( FALSE == hdIsOnlyCANNode ) { @@ -330,112 +330,112 @@ } // end - pending xmit timeout? } // end - transmit in progress or not } // end - DG not alone on CAN bus -} - -/*********************************************************************//** - * @brief - * The handleCANMsgInterrupt function handles a CAN message interrupt. - * This may have occurred because a CAN packet transmission has completed - * or because a CAN packet has been received. The appropriate handler is - * called. - * @details Inputs: none - * @details Outputs: message interrupt handled - * @param srcCANBox which CAN message box triggered this interrupt - * @return none - *************************************************************************/ -void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ) -{ - // Message interrupt is for a transmit message box? - if ( TRUE == isCANBoxForXmit( srcCANBox ) ) - { +} + +/*********************************************************************//** + * @brief + * The handleCANMsgInterrupt function handles a CAN message interrupt. + * This may have occurred because a CAN packet transmission has completed + * or because a CAN packet has been received. The appropriate handler is + * called. + * @details Inputs: none + * @details Outputs: message interrupt handled + * @param srcCANBox which CAN message box triggered this interrupt + * @return none + *************************************************************************/ +void handleCANMsgInterrupt( CAN_MESSAGE_BOX_T srcCANBox ) +{ + // Message interrupt is for a transmit message box? + if ( TRUE == isCANBoxForXmit( srcCANBox ) ) + { U32 bytesXmitted; - bytesXmitted = transmitNextCANPacket(); - - // If nothing more to send, signal that transmitter is available - if ( 0 == bytesXmitted ) - { - signalCANXmitsCompleted(); + bytesXmitted = transmitNextCANPacket(); + + // If nothing more to send, signal that transmitter is available + if ( 0 == bytesXmitted ) + { + signalCANXmitsCompleted(); } - } - else if ( TRUE == isCANBoxForRecv( srcCANBox ) ) - { - U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; - - // Get CAN packet received on given CAN message box - if ( FALSE != canIsRxMessageArrived( canREG1, srcCANBox ) ) - { - U32 result = canGetData( canREG1, srcCANBox, data ); - - // If packet retrieved, add to buffer - if ( result != 0 ) - { - // Add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) - addToCommBuffer( srcCANBox, data, CAN_MESSAGE_PAYLOAD_SIZE ); - } - } - } - else - { + } + else if ( TRUE == isCANBoxForRecv( srcCANBox ) ) + { + U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; + + // Get CAN packet received on given CAN message box + if ( FALSE != canIsRxMessageArrived( canREG1, srcCANBox ) ) + { + U32 result = canGetData( canREG1, srcCANBox, data ); + + // If packet retrieved, add to buffer + if ( result != 0 ) + { + // Add CAN packet to appropriate comm buffer based on the message box it came in on (s/b same #) + addToCommBuffer( srcCANBox, data, CAN_MESSAGE_PAYLOAD_SIZE ); + } + } + } + else + { // Should not get here - not an active message box - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CAN_MESSAGE_BOX, srcCANBox ) - } -} - -/*********************************************************************//** - * @brief - * The isCANBoxForXmit function determines whether a given CAN message box - * is configured for transmit. - * @details Inputs: CAN_OUT_BUFFERS[] - * @details Outputs: none - * @param srcCANBox which CAN message box to check - * @return TRUE if the given CAN message box is configured for transmit, FALSE if not. - *************************************************************************/ -BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ) -{ - BOOL result = FALSE; - U32 i; - - for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) - { - if ( CAN_OUT_BUFFERS[ i ] == srcCANBox ) - { - result = TRUE; - break; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The isCANBoxForRecv function determines whether a given CAN message box - * is configured for receiving. - * @details Inputs: MSG_IN_BUFFERS[] - * @details Outputs: none - * @param srcCANBox which CAN message box to check - * @return TRUE if the given CAN message box is configured for receiving, FALSE if not. - *************************************************************************/ -BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ) -{ - BOOL result = FALSE; - U32 i; - - for ( i = 0; i < NUM_OF_CAN_IN_BUFFERS; i++ ) - { - if ( MSG_IN_BUFFERS[ i ] == srcCANBox ) - { - result = TRUE; - break; - } - } - - return result; + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CAN_MESSAGE_BOX, srcCANBox ) + } } /*********************************************************************//** * @brief + * The isCANBoxForXmit function determines whether a given CAN message box + * is configured for transmit. + * @details Inputs: CAN_OUT_BUFFERS[] + * @details Outputs: none + * @param srcCANBox which CAN message box to check + * @return TRUE if the given CAN message box is configured for transmit, FALSE if not. + *************************************************************************/ +BOOL isCANBoxForXmit( CAN_MESSAGE_BOX_T srcCANBox ) +{ + BOOL result = FALSE; + U32 i; + + for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) + { + if ( CAN_OUT_BUFFERS[ i ] == srcCANBox ) + { + result = TRUE; + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The isCANBoxForRecv function determines whether a given CAN message box + * is configured for receiving. + * @details Inputs: MSG_IN_BUFFERS[] + * @details Outputs: none + * @param srcCANBox which CAN message box to check + * @return TRUE if the given CAN message box is configured for receiving, FALSE if not. + *************************************************************************/ +BOOL isCANBoxForRecv( CAN_MESSAGE_BOX_T srcCANBox ) +{ + BOOL result = FALSE; + U32 i; + + for ( i = 0; i < NUM_OF_CAN_IN_BUFFERS; i++ ) + { + if ( MSG_IN_BUFFERS[ i ] == srcCANBox ) + { + result = TRUE; + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The clearCANXmitBuffers function clears all CAN transmit buffers. * @details Inputs: CAN_OUT_BUFFERS[] * @details Outputs: CAN transmit buffers cleared. @@ -449,154 +449,154 @@ { clearBuffer( CAN_OUT_BUFFERS[ i ] ); } -} - - -/************************************************************************* -********************** TRANSMIT SUPPORT FUNCTIONS ************************ -*************************************************************************/ - - -/*********************************************************************//** - * @brief - * The findNextHighestPriorityCANPacketToTransmit function gets the next - * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. - * @details Inputs: Output CAN Comm Buffer(s) - * @details Outputs: none - * @return buffer with highest priority CAN packet to transmit, - * COMM_BUFFER_NOT_USED if not CAN packets pending transmit found - *************************************************************************/ -static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ) -{ - COMM_BUFFER_T result = COMM_BUFFER_NOT_USED; - U32 i; - - // Search for next priority CAN packet to transmit - for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) - { - if ( numberOfBytesInCommBuffer( CAN_OUT_BUFFERS[ i ] ) >= CAN_MESSAGE_PAYLOAD_SIZE ) - { - result = CAN_OUT_BUFFERS[ i ]; - break; // Found highest priority packet to transmit - we are done - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The transmitNextCANPacket function gets the next 8 byte packet and initiates - * a CAN transmit on the appropriate CAN channel. - * @details Inputs: Output CAN Comm Buffers - * @details Outputs: CAN packet transmit initiated. - * @return number of bytes transmitted - *************************************************************************/ -static U32 transmitNextCANPacket( void ) -{ - U32 result = 0; - COMM_BUFFER_T buffer = findNextHighestPriorityCANPacketToTransmit(); - - // If a buffer is found with a packet to transmit, get packet from buffer and transmit it - if ( buffer != COMM_BUFFER_NOT_USED ) - { - U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; - U32 dataSize = getFromCommBuffer( buffer, data, CAN_MESSAGE_PAYLOAD_SIZE ); - CAN_MESSAGE_BOX_T mBox = buffer; // CAN message boxes and comm buffers are aligned - - // If there is another CAN packet to send, send it - if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) - { - // We are transmitting another packet - signal transmitter is busy - signalCANXmitsInitiated(); - // Remember packet data being transmitted here in case transmission fails and we need to re-send - memcpy( lastCANPacketSent, data, CAN_MESSAGE_PAYLOAD_SIZE ); - lastCANPacketSentChannel = mBox; - lastCANPacketSentTimeStamp = getMSTimerCount(); - if ( 0 != canTransmit( canREG1, mBox, data ) ) - { - result = CAN_MESSAGE_PAYLOAD_SIZE; - } - else - { - signalCANXmitsCompleted(); - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_CMMM_CAN_TRANSMIT_REJECTED, (U32)mBox ) - } - } - else - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_FRAME_SIZE, ((U32)buffer << 16) | dataSize ) - } - } - - return result; -} - - -/************************************************************************* -********************** RECEIVE SUPPORT FUNCTIONS ************************* -*************************************************************************/ - - -/*********************************************************************//** - * @brief - * The processIncomingData function parses out messages from the Input - * Comm Buffers and adds them to the Received Message Queue. - * @details Inputs: none +} + + +/************************************************************************* +********************** TRANSMIT SUPPORT FUNCTIONS ************************ +*************************************************************************/ + + +/*********************************************************************//** + * @brief + * The findNextHighestPriorityCANPacketToTransmit function gets the next + * 8 byte packet and initiates a CAN transmit on the appropriate CAN channel. + * @details Inputs: Output CAN Comm Buffer(s) + * @details Outputs: none + * @return buffer with highest priority CAN packet to transmit, + * COMM_BUFFER_NOT_USED if not CAN packets pending transmit found + *************************************************************************/ +static COMM_BUFFER_T findNextHighestPriorityCANPacketToTransmit( void ) +{ + COMM_BUFFER_T result = COMM_BUFFER_NOT_USED; + U32 i; + + // Search for next priority CAN packet to transmit + for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) + { + if ( numberOfBytesInCommBuffer( CAN_OUT_BUFFERS[ i ] ) >= CAN_MESSAGE_PAYLOAD_SIZE ) + { + result = CAN_OUT_BUFFERS[ i ]; + break; // Found highest priority packet to transmit - we are done + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The transmitNextCANPacket function gets the next 8 byte packet and initiates + * a CAN transmit on the appropriate CAN channel. + * @details Inputs: Output CAN Comm Buffers + * @details Outputs: CAN packet transmit initiated. + * @return number of bytes transmitted + *************************************************************************/ +static U32 transmitNextCANPacket( void ) +{ + U32 result = 0; + COMM_BUFFER_T buffer = findNextHighestPriorityCANPacketToTransmit(); + + // If a buffer is found with a packet to transmit, get packet from buffer and transmit it + if ( buffer != COMM_BUFFER_NOT_USED ) + { + U08 data[ CAN_MESSAGE_PAYLOAD_SIZE ]; + U32 dataSize = getFromCommBuffer( buffer, data, CAN_MESSAGE_PAYLOAD_SIZE ); + CAN_MESSAGE_BOX_T mBox = buffer; // CAN message boxes and comm buffers are aligned + + // If there is another CAN packet to send, send it + if ( dataSize == CAN_MESSAGE_PAYLOAD_SIZE ) + { + // We are transmitting another packet - signal transmitter is busy + signalCANXmitsInitiated(); + // Remember packet data being transmitted here in case transmission fails and we need to re-send + memcpy( lastCANPacketSent, data, CAN_MESSAGE_PAYLOAD_SIZE ); + lastCANPacketSentChannel = mBox; + lastCANPacketSentTimeStamp = getMSTimerCount(); + if ( 0 != canTransmit( canREG1, mBox, data ) ) + { + result = CAN_MESSAGE_PAYLOAD_SIZE; + } + else + { + signalCANXmitsCompleted(); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_CMMM_CAN_TRANSMIT_REJECTED, (U32)mBox ) + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_FRAME_SIZE, ((U32)buffer << 16) | dataSize ) + } + } + + return result; +} + + +/************************************************************************* +********************** RECEIVE SUPPORT FUNCTIONS ************************* +*************************************************************************/ + + +/*********************************************************************//** + * @brief + * The processIncomingData function parses out messages from the Input + * Comm Buffers and adds them to the Received Message Queue. + * @details Inputs: none * @details Outputs:hdIsOnlyCANNode, rcvMsg, dgIsCommunicating, - * timeOfLastDGCheckIn, timeOfLastUICheckIn, uiDidCommunicate - * @return none - *************************************************************************/ -static void processIncomingData( void ) -{ - U08 data[ 512 ]; // Message work space - U32 i; - BOOL badCRCDetected = FALSE; - - // Queue any received messages - for ( i = 0; i < NUM_OF_MSG_IN_BUFFERS; i++ ) - { - BOOL messagesInBuffer = TRUE; // Assume true at first to get into while loop - - while ( TRUE == messagesInBuffer ) - { - U32 numOfBytesInBuffer; - - // Assume false so we do not get stuck in loop. Set to true only if we find another complete message in buffer - messagesInBuffer = FALSE; - - // Since messages can have 8-byte alignment padding left unconsumed by last get, get padding out of buffer - consumeBufferPaddingBeforeSync( MSG_IN_BUFFERS[ i ] ); - // Do we have enough bytes in buffer for smallest message? - numOfBytesInBuffer = numberOfBytesInCommBuffer( MSG_IN_BUFFERS[ i ] ); - if ( numOfBytesInBuffer >= MESSAGE_OVERHEAD_SIZE ) - { // Peek at minimum of all bytes available or max message size (+1 for sync byte) - U32 bytesPeeked = peekFromCommBuffer( MSG_IN_BUFFERS[ i ], data, MIN( numOfBytesInBuffer, sizeof( MESSAGE_WRAPPER_T ) + 1 ) ); + * timeOfLastDGCheckIn, timeOfLastUICheckIn, uiDidCommunicate + * @return none + *************************************************************************/ +static void processIncomingData( void ) +{ + U08 data[ 512 ]; // Message work space + U32 i; + BOOL badCRCDetected = FALSE; + + // Queue any received messages + for ( i = 0; i < NUM_OF_MSG_IN_BUFFERS; i++ ) + { + BOOL messagesInBuffer = TRUE; // Assume true at first to get into while loop + + while ( TRUE == messagesInBuffer ) + { + U32 numOfBytesInBuffer; + + // Assume false so we do not get stuck in loop. Set to true only if we find another complete message in buffer + messagesInBuffer = FALSE; + + // Since messages can have 8-byte alignment padding left unconsumed by last get, get padding out of buffer + consumeBufferPaddingBeforeSync( MSG_IN_BUFFERS[ i ] ); + // Do we have enough bytes in buffer for smallest message? + numOfBytesInBuffer = numberOfBytesInCommBuffer( MSG_IN_BUFFERS[ i ] ); + if ( numOfBytesInBuffer >= MESSAGE_OVERHEAD_SIZE ) + { // Peek at minimum of all bytes available or max message size (+1 for sync byte) + U32 bytesPeeked = peekFromCommBuffer( MSG_IN_BUFFERS[ i ], data, MIN( numOfBytesInBuffer, sizeof( MESSAGE_WRAPPER_T ) + 1 ) ); S32 msgSize = parseMessageFromBuffer( data, bytesPeeked ); hdIsOnlyCANNode = FALSE; // Since we are getting a message, this indicates we are not the only node on the CAN bus - canXmitRetryCtr = 0; - - if ( msgSize > 0 ) // Valid, complete message found? - { - MESSAGE_WRAPPER_T rcvMsg; - U08 *dataPtr = data+1; // Skip over sync byte - - // Consume message (+sync byte) - msgSize = getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, msgSize + 1 ); - // Convert received message data to a message and add to message queue - messagesInBuffer = TRUE; // Keep processing this buffer - // Blank the new message record - blankMessageInWrapper( &rcvMsg ); - // Copy message header portion of message data to the new message - memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof( MESSAGE_HEADER_T ) ); - dataPtr += sizeof( MESSAGE_HEADER_T ); - // Copy message payload portion of message data to the new message - memcpy( &(rcvMsg.msg.payload), dataPtr, rcvMsg.msg.hdr.payloadLen ); - dataPtr += rcvMsg.msg.hdr.payloadLen; - // Copy CRC portion of message data to the new message - rcvMsg.crc = *dataPtr; - // Add new message to queue for later processing + canXmitRetryCtr = 0; + + if ( msgSize > 0 ) // Valid, complete message found? + { + MESSAGE_WRAPPER_T rcvMsg; + U08 *dataPtr = data+1; // Skip over sync byte + + // Consume message (+sync byte) + msgSize = getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, msgSize + 1 ); + // Convert received message data to a message and add to message queue + messagesInBuffer = TRUE; // Keep processing this buffer + // Blank the new message record + blankMessageInWrapper( &rcvMsg ); + // Copy message header portion of message data to the new message + memcpy( &(rcvMsg.msg.hdr), dataPtr, sizeof( MESSAGE_HEADER_T ) ); + dataPtr += sizeof( MESSAGE_HEADER_T ); + // Copy message payload portion of message data to the new message + memcpy( &(rcvMsg.msg.payload), dataPtr, rcvMsg.msg.hdr.payloadLen ); + dataPtr += rcvMsg.msg.hdr.payloadLen; + // Copy CRC portion of message data to the new message + rcvMsg.crc = *dataPtr; + // Add new message to queue for later processing addToMsgQueue( MSG_Q_IN, &rcvMsg ); // If message from DG broadcast channel, update DG comm status if ( COMM_BUFFER_IN_CAN_DG_BROADCAST == MSG_IN_BUFFERS[ i ] ) @@ -609,180 +609,180 @@ { timeOfLastUICheckIn = getMSTimerCount(); uiDidCommunicate = TRUE; - } - } - else if ( -1 == msgSize ) // Candidate message with bad CRC found? - { - badCRCDetected = TRUE; - getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, 1 ); // Consume sync byte so we can re-sync - messagesInBuffer = TRUE; // Keep processing this buffer - } // Looks like there is a complete message in the comm buffer - } // Enough data left in comm buffer to possibly be a complete message - } // While loop to get all complete messages for each comm buffer - } // For loop to check all comm buffers for messages - - // If any bad CRCs detected, see if too many - if ( TRUE == badCRCDetected ) - { - checkTooManyBadMsgCRCs(); - } -} - -/*********************************************************************//** - * @brief - * The consumeBufferPaddingBeforeSync function removes any bytes in a given - * buffer that lie before a sync byte. - * @details Inputs: none - * @details Outputs: Any padding at front of buffer is consumed. - * @param buffer the comm buffer to process - * @return none - *************************************************************************/ -static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ) -{ - U08 data; - U32 numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); - - // Consume bytes out of buffer 1 at a time until we find the sync byte or it is empty - while ( numOfBytesInBuffer > 0 ) - { - peekFromCommBuffer( buffer, &data, 1 ); - if ( MESSAGE_SYNC_BYTE == data ) - { - break; // We found a sync - we are done - } - else // Not a sync byte, so consume it - { - getFromCommBuffer( buffer, &data, 1 ); - numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); - } - } -} - -/*********************************************************************//** - * @brief - * The parseMessageFromBuffer function looks for a complete message in a - * given buffer. If a message is found, its size is returned. - * @details Inputs: none - * @details Outputs: none - * @param data pointer to byte array to search for a message - * @param len number of bytes in the data to search - * @return size of message if found, zero if no complete message found, - * -1 if message found but CRC fails. - *************************************************************************/ -static S32 parseMessageFromBuffer( U08 *data, U32 len ) -{ - U32 i; - U32 payloadSize; - U32 msgSize; - S32 result = 0; - - for ( i = 0; i < len; i++ ) - { - // Find sync byte - if ( MESSAGE_SYNC_BYTE == data[ i ] ) - { - U32 pos = i + 1; // Skip past sync byte implemented - U32 remSize = len - pos; - - // If a minimum sized msg would fit in remaining, continue - if ( remSize >= MESSAGE_OVERHEAD_SIZE ) - { - payloadSize = data[ pos + sizeof(MESSAGE_HEADER_T) - sizeof(U08) ]; - msgSize = MESSAGE_OVERHEAD_SIZE + payloadSize; - // We now know the size of the message - we can now know if full message is contained in buffer - if ( msgSize <= remSize ) - { // Check CRC to make sure it is a valid message - if ( data[i+msgSize] == crc8( &data[pos], msgSize - 1 ) ) - { - result = msgSize; // We found a complete, valid message of this size - } - else // CRC failed - { - result = -1; // We found a complete, invalid message - } - } - } - break; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The processReceivedMessages function processes any messages in the - * received message queues. - * @details Inputs: Received Message Queues - * @details Outputs: Message(s) processed. - * @return none - *************************************************************************/ -static void processReceivedMessages( void ) -{ - BOOL isThereMsgRcvd = TRUE; // Assume TRUE at first to get into while loop - MESSAGE_WRAPPER_T message; + } + } + else if ( -1 == msgSize ) // Candidate message with bad CRC found? + { + badCRCDetected = TRUE; + getFromCommBuffer( MSG_IN_BUFFERS[ i ], data, 1 ); // Consume sync byte so we can re-sync + messagesInBuffer = TRUE; // Keep processing this buffer + } // Looks like there is a complete message in the comm buffer + } // Enough data left in comm buffer to possibly be a complete message + } // While loop to get all complete messages for each comm buffer + } // For loop to check all comm buffers for messages - while ( TRUE == isThereMsgRcvd ) - { - // See if any messages received - isThereMsgRcvd = getFromMsgQueue( MSG_Q_IN, &message ); - if ( TRUE == isThereMsgRcvd ) - { // CRC should be good because we checked it during parsing before adding to queue - but check it again for good measure - if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) - { - // If ACK, mark pending message ACK'd - if ( MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK == message.msg.hdr.msgID ) - { - matchACKtoPendingACKList( message.msg.hdr.seqNo ); - } - else - { - // If received message requires ACK, queue one up - if ( message.msg.hdr.seqNo < 0 ) - { - sendACKMsg( &message.msg ); - } - // Process the received message - processReceivedMessage( &message.msg ); - } - } - else // CRC failed - { - checkTooManyBadMsgCRCs(); - } - } - } -} - -/*********************************************************************//** - * @brief - * The checkForCommTimeouts function checks for sub-system communication - * timeout errors. - * @details Inputs: timeOfLastDGCheckIn, timeOfLastUICheckIn - * @details Outputs: possibly a comm t/o alarm - * @return none - *************************************************************************/ -static void checkForCommTimeouts( void ) -{ - if ( TRUE == uiDidCommunicate ) + // If any bad CRCs detected, see if too many + if ( TRUE == badCRCDetected ) { + checkTooManyBadMsgCRCs(); + } +} + +/*********************************************************************//** + * @brief + * The consumeBufferPaddingBeforeSync function removes any bytes in a given + * buffer that lie before a sync byte. + * @details Inputs: none + * @details Outputs: Any padding at front of buffer is consumed. + * @param buffer the comm buffer to process + * @return none + *************************************************************************/ +static void consumeBufferPaddingBeforeSync( COMM_BUFFER_T buffer ) +{ + U08 data; + U32 numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); + + // Consume bytes out of buffer 1 at a time until we find the sync byte or it is empty + while ( numOfBytesInBuffer > 0 ) + { + peekFromCommBuffer( buffer, &data, 1 ); + if ( MESSAGE_SYNC_BYTE == data ) + { + break; // We found a sync - we are done + } + else // Not a sync byte, so consume it + { + getFromCommBuffer( buffer, &data, 1 ); + numOfBytesInBuffer = numberOfBytesInCommBuffer( buffer ); + } + } +} + +/*********************************************************************//** + * @brief + * The parseMessageFromBuffer function looks for a complete message in a + * given buffer. If a message is found, its size is returned. + * @details Inputs: none + * @details Outputs: none + * @param data pointer to byte array to search for a message + * @param len number of bytes in the data to search + * @return size of message if found, zero if no complete message found, + * -1 if message found but CRC fails. + *************************************************************************/ +static S32 parseMessageFromBuffer( U08 *data, U32 len ) +{ + U32 i; + U32 payloadSize; + U32 msgSize; + S32 result = 0; + + for ( i = 0; i < len; i++ ) + { + // Find sync byte + if ( MESSAGE_SYNC_BYTE == data[ i ] ) + { + U32 pos = i + 1; // Skip past sync byte implemented + U32 remSize = len - pos; + + // If a minimum sized msg would fit in remaining, continue + if ( remSize >= MESSAGE_OVERHEAD_SIZE ) + { + payloadSize = data[ pos + sizeof(MESSAGE_HEADER_T) - sizeof(U08) ]; + msgSize = MESSAGE_OVERHEAD_SIZE + payloadSize; + // We now know the size of the message - we can now know if full message is contained in buffer + if ( msgSize <= remSize ) + { // Check CRC to make sure it is a valid message + if ( data[i+msgSize] == crc8( &data[pos], msgSize - 1 ) ) + { + result = msgSize; // We found a complete, valid message of this size + } + else // CRC failed + { + result = -1; // We found a complete, invalid message + } + } + } + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The processReceivedMessages function processes any messages in the + * received message queues. + * @details Inputs: Received Message Queues + * @details Outputs: Message(s) processed. + * @return none + *************************************************************************/ +static void processReceivedMessages( void ) +{ + BOOL isThereMsgRcvd = TRUE; // Assume TRUE at first to get into while loop + MESSAGE_WRAPPER_T message; + + while ( TRUE == isThereMsgRcvd ) + { + // See if any messages received + isThereMsgRcvd = getFromMsgQueue( MSG_Q_IN, &message ); + if ( TRUE == isThereMsgRcvd ) + { // CRC should be good because we checked it during parsing before adding to queue - but check it again for good measure + if ( message.crc == crc8( (U08*)(&message), sizeof(MESSAGE_HEADER_T) + message.msg.hdr.payloadLen ) ) + { + // If ACK, mark pending message ACK'd + if ( MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK == message.msg.hdr.msgID ) + { + matchACKtoPendingACKList( message.msg.hdr.seqNo ); + } + else + { + // If received message requires ACK, queue one up + if ( message.msg.hdr.seqNo < 0 ) + { + sendACKMsg( &message.msg ); + } + // Process the received message + processReceivedMessage( &message.msg ); + } + } + else // CRC failed + { + checkTooManyBadMsgCRCs(); + } + } + } +} + +/*********************************************************************//** + * @brief + * The checkForCommTimeouts function checks for sub-system communication + * timeout errors. + * @details Inputs: timeOfLastDGCheckIn, timeOfLastUICheckIn + * @details Outputs: possibly a comm t/o alarm + * @return none + *************************************************************************/ +static void checkForCommTimeouts( void ) +{ + if ( TRUE == uiDidCommunicate ) + { HD_OP_MODE_T opMode = getCurrentOperationMode(); U32 uiTO_MS = UI_COMM_TIMEOUT_IN_MS; // in service mode, allow up to 2 minutes for UI to check-in (for lock-down) if ( MODE_SERV == opMode ) { uiTO_MS = UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS; - } - if ( TRUE == didTimeout( timeOfLastUICheckIn, uiTO_MS ) ) + } + if ( TRUE == didTimeout( timeOfLastUICheckIn, uiTO_MS ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_UI_COMM_ALARMS ) != SW_CONFIG_ENABLE_VALUE ) #endif - { + { activateAlarmNoData( ALARM_ID_HD_UI_COMM_TIMEOUT ); } - } + } if ( TRUE == didTimeout( timeOfLastDGCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) { @@ -802,89 +802,89 @@ #endif } } -} - -/*********************************************************************//** - * @brief - * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs - * within a set period of time. Assumed function is being called when a new - * bad CRC is detected so a new bad CRC will be added to the list. - * @details Inputs: badCRCTimeStamps[], badCRCListIdx, badCRCListCount - * @details Outputs: possibly a "too many bad CRCs" alarm - * @return none - *************************************************************************/ -static void checkTooManyBadMsgCRCs( void ) -{ +} + +/*********************************************************************//** + * @brief + * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs + * within a set period of time. Assumed function is being called when a new + * bad CRC is detected so a new bad CRC will be added to the list. + * @details Inputs: badCRCTimeStamps[], badCRCListIdx, badCRCListCount + * @details Outputs: possibly a "too many bad CRCs" alarm + * @return none + *************************************************************************/ +static void checkTooManyBadMsgCRCs( void ) +{ if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) { SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_COMM_TOO_MANY_BAD_CRCS, (U32)ALARM_SOURCE_HD ); } -} - -/*********************************************************************//** - * @brief - * The addMsgToPendingACKList function adds a given message to the pending - * ACK list. Messages in this list will require receipt of an ACK message - * for this particular message within a limited time. - * @details Inputs: pendingAckList[] - * @details Outputs: pendingAckList[] - * @param msg pointer to msg within the message data - * @param msgData pointer to message data to add to pending ACK list - * @param len number of bytes of message data - * @return TRUE if message added successfully, FALSE if not - *************************************************************************/ -BOOL addMsgToPendingACKList( MESSAGE_T *msg, COMM_BUFFER_T channel, U08 *msgData, U32 len ) -{ - BOOL result = FALSE; - U32 i; - - // Find first open slot in pending ACK list and add given msg data to it - for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { - _disable_IRQ(); // Slot selection needs interrupt protection - if ( FALSE == pendingAckList[ i ].used ) - { - S16 seqNo = msg->hdr.seqNo * -1; // Remove ACK bit from seq # - - pendingAckList[ i ].used = TRUE; - _enable_IRQ(); - pendingAckList[ i ].seqNo = seqNo; - pendingAckList[ i ].channel = channel; - pendingAckList[ i ].timeStamp = getMSTimerCount(); - pendingAckList[ i ].retries = MSG_NOT_ACKED_MAX_RETRIES; - pendingAckList[ i ].msgSize = len; - memcpy( (U08*)pendingAckList[ i ].msg, msgData, len ); - result = TRUE; - break; - } - else - { - _enable_IRQ(); - } +} + +/*********************************************************************//** + * @brief + * The addMsgToPendingACKList function adds a given message to the pending + * ACK list. Messages in this list will require receipt of an ACK message + * for this particular message within a limited time. + * @details Inputs: pendingAckList[] + * @details Outputs: pendingAckList[] + * @param msg pointer to msg within the message data + * @param msgData pointer to message data to add to pending ACK list + * @param len number of bytes of message data + * @return TRUE if message added successfully, FALSE if not + *************************************************************************/ +BOOL addMsgToPendingACKList( MESSAGE_T *msg, COMM_BUFFER_T channel, U08 *msgData, U32 len ) +{ + BOOL result = FALSE; + U32 i; + + // Find first open slot in pending ACK list and add given msg data to it + for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) + { + _disable_IRQ(); // Slot selection needs interrupt protection + if ( FALSE == pendingAckList[ i ].used ) + { + S16 seqNo = msg->hdr.seqNo * -1; // Remove ACK bit from seq # + + pendingAckList[ i ].used = TRUE; + _enable_IRQ(); + pendingAckList[ i ].seqNo = seqNo; + pendingAckList[ i ].channel = channel; + pendingAckList[ i ].timeStamp = getMSTimerCount(); + pendingAckList[ i ].retries = MSG_NOT_ACKED_MAX_RETRIES; + pendingAckList[ i ].msgSize = len; + memcpy( (U08*)pendingAckList[ i ].msg, msgData, len ); + result = TRUE; + break; + } + else + { + _enable_IRQ(); + } } - return result; -} - -/*********************************************************************//** - * @brief - * The matchACKtoPendingACKList function searches the pending ACK list to - * see if the sequence # from a received ACK msg matches any. If found, - * the list entry is removed. - * @details Inputs: pendingAckList[] - * @details Outputs: pendingAckList[] - * @param seqNo sequence # to match to an entry in the list - * @return TRUE if a match was found, FALSE if not - *************************************************************************/ -static BOOL matchACKtoPendingACKList( S16 seqNo ) -{ - BOOL result = FALSE; + return result; +} + +/*********************************************************************//** + * @brief + * The matchACKtoPendingACKList function searches the pending ACK list to + * see if the sequence # from a received ACK msg matches any. If found, + * the list entry is removed. + * @details Inputs: pendingAckList[] + * @details Outputs: pendingAckList[] + * @param seqNo sequence # to match to an entry in the list + * @return TRUE if a match was found, FALSE if not + *************************************************************************/ +static BOOL matchACKtoPendingACKList( S16 seqNo ) +{ + BOOL result = FALSE; U32 i; - - // Find match - for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { - if ( ( TRUE == pendingAckList[ i ].used ) && ( pendingAckList[ i ].seqNo == seqNo ) ) + + // Find match + for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) + { + if ( ( TRUE == pendingAckList[ i ].used ) && ( pendingAckList[ i ].seqNo == seqNo ) ) { result = TRUE; // Remove message pending ACK from list @@ -893,42 +893,42 @@ { pendingAckList[ i ].used = FALSE; } - break; - } - } - - return result; -} - -/*********************************************************************//** - * @brief - * The checkPendingACKList function searches the pending ACK list to - * see if any have expired. Any such messages will be queued for retransmission - * and if max retries reached a fault is triggered. - * @details Inputs: pendingAckList[] - * @details Outputs: pendingAckList[] - * @return none - *************************************************************************/ -static void checkPendingACKList( void ) -{ - U32 i; - - // Find expired messages pending ACK - for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) - { // Pending ACK expired? - if ( ( TRUE == pendingAckList[ i ].used ) && ( TRUE == didTimeout( pendingAckList[ i ].timeStamp, MSG_NOT_ACKED_TIMEOUT_MS ) ) ) - { // If retries left, reset and resend pending message - if ( pendingAckList[ i ].retries > 0 ) - { // Re-queue message for transmit - pendingAckList[ i ].retries--; - pendingAckList[ i ].timeStamp = getMSTimerCount(); - addToCommBuffer( pendingAckList[ i ].channel, (U08*)pendingAckList[ i ].msg, pendingAckList[ i ].msgSize ); + break; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The checkPendingACKList function searches the pending ACK list to + * see if any have expired. Any such messages will be queued for retransmission + * and if max retries reached a fault is triggered. + * @details Inputs: pendingAckList[] + * @details Outputs: pendingAckList[] + * @return none + *************************************************************************/ +static void checkPendingACKList( void ) +{ + U32 i; + + // Find expired messages pending ACK + for ( i = 0; i < PENDING_ACK_LIST_SIZE; i++ ) + { // Pending ACK expired? + if ( ( TRUE == pendingAckList[ i ].used ) && ( TRUE == didTimeout( pendingAckList[ i ].timeStamp, MSG_NOT_ACKED_TIMEOUT_MS ) ) ) + { // If retries left, reset and resend pending message + if ( pendingAckList[ i ].retries > 0 ) + { // Re-queue message for transmit + pendingAckList[ i ].retries--; + pendingAckList[ i ].timeStamp = getMSTimerCount(); + addToCommBuffer( pendingAckList[ i ].channel, (U08*)pendingAckList[ i ].msg, pendingAckList[ i ].msgSize ); } - // If no retries left, alarm - else - { - U16 msgID; - + // If no retries left, alarm + else + { + U16 msgID; + memcpy( &msgID, (U08*)&pendingAckList[ i ].msg[ sizeof( U08 ) + sizeof( U16) ], sizeof( U16 ) ); if ( pendingAckList[ i ].channel != COMM_BUFFER_OUT_CAN_HD_2_DG ) @@ -940,30 +940,30 @@ SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_CAN_MESSAGE_NOT_ACKED_BY_DG, (U32)msgID ); } pendingAckList[ i ].used = FALSE; // Take pending message off of list - } - } - } -} - -/*********************************************************************//** - * @brief - * The processReceivedMessage function processes a given message. - * @details Inputs: none - * @details Outputs: message processed - * @param message pointer to message to process - * @return none - *************************************************************************/ -static void processReceivedMessage( MESSAGE_T *message ) -{ - U16 msgID = message->hdr.msgID; - - // Handle any messages from other sub-systems - switch ( msgID ) - { - case MSG_ID_OFF_BUTTON_PRESS_REQUEST: - handleOffButtonConfirmMsgFromUI( message ); - break; - + } + } + } +} + +/*********************************************************************//** + * @brief + * The processReceivedMessage function processes a given message. + * @details Inputs: none + * @details Outputs: message processed + * @param message pointer to message to process + * @return none + *************************************************************************/ +static void processReceivedMessage( MESSAGE_T *message ) +{ + U16 msgID = message->hdr.msgID; + + // Handle any messages from other sub-systems + switch ( msgID ) + { + case MSG_ID_OFF_BUTTON_PRESS_REQUEST: + handleOffButtonConfirmMsgFromUI( message ); + break; + case MSG_ID_ALARM_TRIGGERED: handleAlarmTriggered( message ); break; @@ -974,42 +974,42 @@ case MSG_ID_UI_ALARM_USER_ACTION_REQUEST: handleAlarmUserAction( message ); - break; - - case MSG_ID_UI_CHECK_IN: - handleUICheckIn( message ); - break; - - case MSG_ID_LOAD_CELL_READINGS_DATA: - handleLoadCellReadingsFromDG( message ); - break; - - case MSG_ID_USER_UF_PAUSE_RESUME_REQUEST: - handleUFPauseResumeRequest( message ); - break; - - case MSG_ID_USER_UF_SETTINGS_CHANGE_REQUEST: - handleChangeUFSettingsRequest( message ); break; + case MSG_ID_UI_CHECK_IN: + handleUICheckIn( message ); + break; + + case MSG_ID_LOAD_CELL_READINGS_DATA: + handleLoadCellReadingsFromDG( message ); + break; + + case MSG_ID_USER_UF_PAUSE_RESUME_REQUEST: + handleUFPauseResumeRequest( message ); + break; + + case MSG_ID_USER_UF_SETTINGS_CHANGE_REQUEST: + handleChangeUFSettingsRequest( message ); + break; + case MSG_ID_USER_SALINE_BOLUS_REQUEST: handleSalineBolusRequest( message ); - break; - - case MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE_REQUEST: - handleChangeUFSettingsConfirmation( message ); - break; - - case MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST: - handleChangeTreatmentDurationRequest( message ); - break; - - case MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST: - handleChangeBloodDialysateRateChangeRequest( message ); - break; - - case MSG_ID_FW_VERSIONS_REQUEST: - handleFWVersionRequest( message ); + break; + + case MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE_REQUEST: + handleChangeUFSettingsConfirmation( message ); + break; + + case MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST: + handleChangeTreatmentDurationRequest( message ); + break; + + case MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST: + handleChangeBloodDialysateRateChangeRequest( message ); + break; + + case MSG_ID_FW_VERSIONS_REQUEST: + handleFWVersionRequest( message ); handleHDSerialNumberRequest(); break; @@ -1019,24 +1019,24 @@ case MSG_ID_DG_HEATERS_DATA: handleDGHeatersData( message ); - break; - - case MSG_ID_DG_TEMPERATURE_DATA: - handleDGTemperatureData( message ); - break; - + break; + + case MSG_ID_DG_TEMPERATURE_DATA: + handleDGTemperatureData( message ); + break; + case MSG_ID_DG_FLOW_SENSORS_DATA: handleDialysateFlowData( message ); - break; - - case MSG_ID_DG_OP_MODE_DATA: - handleDGOpMode( message ); - break; - - case MSG_ID_DG_RESERVOIRS_DATA: - handleDGReservoirData( message ); - break; - + break; + + case MSG_ID_DG_OP_MODE_DATA: + handleDGOpMode( message ); + break; + + case MSG_ID_DG_RESERVOIRS_DATA: + handleDGReservoirData( message ); + break; + case MSG_ID_USER_ALARM_SILENCE_REQUEST: handleUIAlarmSilenceRequest( message ); break; @@ -1214,156 +1214,156 @@ handleTesterLogInRequest( message ); break; - default: - // Un-recognized or un-handled message ID received - ignore + default: + // Un-recognized or un-handled message ID received - ignore break; - } - - // Handle any test messages if tester has logged in successfully - if ( ( msgID > MSG_ID_FIRST_TESTER_MESSAGE ) && ( TRUE == isTestingActivated() ) ) - { - switch ( msgID ) - { - case MSG_ID_OFF_BUTTON_STATE_OVERRIDE: - handleTestOffButtonStateOverrideRequest( message ); - break; - - case MSG_ID_STOP_BUTTON_STATE_OVERRIDE: - handleTestStopButtonStateOverrideRequest( message ); - break; - - case MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE: - handleTestAlarmLampPatternOverrideRequest( message ); - break; - - case MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: - handleTestWatchdogCheckInStateOverrideRequest( message ); - break; - - case MSG_ID_ALARM_STATE_OVERRIDE: - handleTestAlarmStateOverrideRequest( message ); - break; - - case MSG_ID_ALARM_TIME_OVERRIDE: - handleTestAlarmTimeOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_FLOW_SET_PT_OVERRIDE: - handleTestBloodFlowSetPointOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_FLOW_MEAS_OVERRIDE: - handleTestBloodFlowMeasuredOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_PUMP_MC_MEAS_SPEED_OVERRIDE: - handleTestBloodPumpMCMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_PUMP_MC_MEAS_CURR_OVERRIDE: - handleTestBloodPumpMCMeasuredCurrentOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_FLOW_SEND_INTERVAL_OVERRIDE: - handleTestBloodFlowBroadcastIntervalOverrideRequest( message ); + } + + // Handle any test messages if tester has logged in successfully + if ( ( msgID > MSG_ID_FIRST_TESTER_MESSAGE ) && ( TRUE == isTestingActivated() ) ) + { + switch ( msgID ) + { + case MSG_ID_OFF_BUTTON_STATE_OVERRIDE: + handleTestOffButtonStateOverrideRequest( message ); break; + case MSG_ID_STOP_BUTTON_STATE_OVERRIDE: + handleTestStopButtonStateOverrideRequest( message ); + break; + + case MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE: + handleTestAlarmLampPatternOverrideRequest( message ); + break; + + case MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: + handleTestWatchdogCheckInStateOverrideRequest( message ); + break; + + case MSG_ID_ALARM_STATE_OVERRIDE: + handleTestAlarmStateOverrideRequest( message ); + break; + + case MSG_ID_ALARM_TIME_OVERRIDE: + handleTestAlarmTimeOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_FLOW_SET_PT_OVERRIDE: + handleTestBloodFlowSetPointOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_FLOW_MEAS_OVERRIDE: + handleTestBloodFlowMeasuredOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_PUMP_MC_MEAS_SPEED_OVERRIDE: + handleTestBloodPumpMCMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_PUMP_MC_MEAS_CURR_OVERRIDE: + handleTestBloodPumpMCMeasuredCurrentOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_FLOW_SEND_INTERVAL_OVERRIDE: + handleTestBloodFlowBroadcastIntervalOverrideRequest( message ); + break; + case MSG_ID_TREATMENT_TIME_REMAINING_OVERRIDE: handleTestTreatmentTimeRemainingOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE: - handleTestBloodPumpMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: - handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE: - handleTestDialInFlowSetPointOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE: - handleTestDialInFlowMeasuredOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE: - handleTestDialInPumpMCMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE: - handleTestDialInPumpMCMeasuredCurrentOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE: - handleTestDialInFlowBroadcastIntervalOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE: - handleTestDialInPumpMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: - handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_PRESSURE_ARTERIAL_OVERRIDE: - handleTestArterialPressureOverrideRequest( message ); - break; - - case MSG_ID_PRESSURE_VENOUS_OVERRIDE: - handleTestVenousPressureOverrideRequest( message ); - break; - - case MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE: - handleTestBloodPumpOcclusionOverrideRequest( message ); - break; - - case MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE: - handleTestPresOcclBroadcastIntervalOverrideRequest( message ); - break; - - case MSG_ID_SET_RTC_DATE_TIME: - handleSetRTCTimestamp( message ); - break; - - case MSG_ID_DIAL_OUT_FLOW_SEND_INTERVAL_OVERRIDE: - handleTestDialOutFlowBroadcastIntervalOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_UF_REF_VOLUME_OVERRIDE: - handleTestDialOutUFReferenceVolumeOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_UF_MEAS_VOLUME_OVERRIDE: - handleTestDialOutUFMeasuredVolumeOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_PUMP_MC_MEAS_SPEED_OVERRIDE: - handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_PUMP_MC_MEAS_CURR_OVERRIDE: - handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_PUMP_MEAS_SPEED_OVERRIDE: - handleTestDialOutPumpMeasuredSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: - handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( message ); - break; - - case MSG_ID_DIAL_OUT_LOAD_CELL_WEIGHT_OVERRIDE: - handleTestDialOutLoadCellWeightOverrideRequest( message ); - break; - - case MSG_ID_HD_SAFETY_SHUTDOWN_OVERRIDE: - handleTestHDSafetyShutdownOverrideRequest( message ); - break; - + break; + + case MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE: + handleTestBloodPumpMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: + handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE: + handleTestDialInFlowSetPointOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE: + handleTestDialInFlowMeasuredOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE: + handleTestDialInPumpMCMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE: + handleTestDialInPumpMCMeasuredCurrentOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE: + handleTestDialInFlowBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE: + handleTestDialInPumpMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: + handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_PRESSURE_ARTERIAL_OVERRIDE: + handleTestArterialPressureOverrideRequest( message ); + break; + + case MSG_ID_PRESSURE_VENOUS_OVERRIDE: + handleTestVenousPressureOverrideRequest( message ); + break; + + case MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE: + handleTestBloodPumpOcclusionOverrideRequest( message ); + break; + + case MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE: + handleTestPresOcclBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_SET_RTC_DATE_TIME: + handleSetRTCTimestamp( message ); + break; + + case MSG_ID_DIAL_OUT_FLOW_SEND_INTERVAL_OVERRIDE: + handleTestDialOutFlowBroadcastIntervalOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_UF_REF_VOLUME_OVERRIDE: + handleTestDialOutUFReferenceVolumeOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_UF_MEAS_VOLUME_OVERRIDE: + handleTestDialOutUFMeasuredVolumeOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_PUMP_MC_MEAS_SPEED_OVERRIDE: + handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_PUMP_MC_MEAS_CURR_OVERRIDE: + handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_PUMP_MEAS_SPEED_OVERRIDE: + handleTestDialOutPumpMeasuredSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_PUMP_MEAS_ROTOR_SPEED_OVERRIDE: + handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( message ); + break; + + case MSG_ID_DIAL_OUT_LOAD_CELL_WEIGHT_OVERRIDE: + handleTestDialOutLoadCellWeightOverrideRequest( message ); + break; + + case MSG_ID_HD_SAFETY_SHUTDOWN_OVERRIDE: + handleTestHDSafetyShutdownOverrideRequest( message ); + break; + case MSG_ID_HD_ACCEL_OVERRIDE: handleTestHDAccelOverrideRequest( message ); break; @@ -1678,7 +1678,7 @@ handleTestFansRPMAlarmStartTimeOffsetRequest( message ); break; - case MSG_ID_HD_SYRINGE_PUMP_HEPRIN_BOLUS_TARGET_RATE_OVERRIDE: + case MSG_ID_HD_SYRINGE_PUMP_HEPARIN_BOLUS_TARGET_RATE_OVERRIDE: handleTestSyringePumpHeprinBolusTargetRateOverrideRequest( message ); break; @@ -1817,12 +1817,12 @@ break; // The default cannot be reached in VectorCAST since the cases are run in a for loop - default: - // Unrecognized message ID received - ignore + default: + // Unrecognized message ID received - ignore break; - } - } -} + } + } +} /************************************************************************* Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -46,7 +46,7 @@ #include "Valves.h" #include "WatchdogMgmt.h" #include "HDDefs.h" -#include "TaskPriority.h" +#include "TaskPriority.h" /** * @addtogroup SystemCommMessages @@ -61,7 +61,7 @@ /// Payload record structure for block message transmission request. typedef struct { - U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; + U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; ///< Blocked messages. } BLOCKED_MSGS_DATA_T; #pragma pack(pop) @@ -1659,16 +1659,17 @@ *************************************************************************/ void handleUIClockSyncRequest( MESSAGE_T *message ) { - BOOL result = FALSE; - U32 rejReason = REQUEST_REJECT_REASON_NONE; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + BOOL result = FALSE; + U32 rejReason = REQUEST_REJECT_REASON_NONE; + U08 *payloadPtr = msg.payload; + U32 *messagePayload = (U32*)message->payload; if ( message->hdr.payloadLen == sizeof( U32 ) ) { U32 epoch; - memcpy( &epoch, message->payload, sizeof( U32 ) ); + memcpy( &epoch, messagePayload, sizeof( U32 ) ); result = setRTCEpoch( epoch ); if ( FALSE == result ) { @@ -3361,11 +3362,13 @@ if ( 0 == message->hdr.payloadLen ) { + U32 lastServiceEpochDate = service.lastServiceEpochDate; + U32 serviceIntervalSeconds = ( 0 == service.lastServiceEpochDate ? 0 : service.serviceIntervalSeconds ); + // Fill message payload - memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + memcpy( payloadPtr, &lastServiceEpochDate, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); - service.serviceIntervalSeconds = ( 0 == service.lastServiceEpochDate ? 0 : service.serviceIntervalSeconds ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + memcpy( payloadPtr, &serviceIntervalSeconds, sizeof( U32 ) ); } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -rdb291cc22fd8f10e6e47cad468e14ed5590a94f2 -rbb643418e1f0c59ca3ee75c642aaa1f31850069e --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision db291cc22fd8f10e6e47cad468e14ed5590a94f2) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision bb643418e1f0c59ca3ee75c642aaa1f31850069e) @@ -14,11 +14,11 @@ * @date (original) 05-Nov-2019 * ***************************************************************************/ - -#ifndef __SYSTEM_COMM_MESSAGES_H__ -#define __SYSTEM_COMM_MESSAGES_H__ -#include "AirPump.h" +#ifndef __SYSTEM_COMM_MESSAGES_H__ +#define __SYSTEM_COMM_MESSAGES_H__ + +#include "AirPump.h" #include "AirTrap.h" #include "BloodFlow.h" #include "BloodLeak.h" @@ -27,13 +27,13 @@ #include "CommBuffers.h" #include "DGInterface.h" #include "DialInFlow.h" -#include "DialOutFlow.h" +#include "DialOutFlow.h" #include "Dialysis.h" -#include "Fans.h" +#include "Fans.h" #include "FluidLeak.h" #include "HDCommon.h" #include "MessageSupport.h" -#include "ModeInitPOST.h" +#include "ModeInitPOST.h" #include "ModePostTreat.h" #include "ModePreTreat.h" #include "ModeStandby.h" @@ -49,7 +49,7 @@ #include "Temperatures.h" #include "Valves.h" #include "Voltages.h" - + /** * @defgroup SystemCommMessages SystemCommMessages * @brief The system communication messages module provides helper functions @@ -62,7 +62,7 @@ // ********** public definitions ********** #define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. -#define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. +#define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. #pragma pack(push, 1) /// Payload record structure for ACK response. @@ -126,16 +126,6 @@ U32 dialRate; ///< new dialysate flow rate } BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T; -/// Payload record structure for event messages. -typedef struct -{ - U32 event; ///< Event ID - U32 dataType1; ///< Data type for data field 1 - EVENT_DATAS_T data1; ///< data field 1 - U32 dataType2; ///< Data type for data field 2 - EVENT_DATAS_T data2; ///< Data field 2 -} EVENT_PAYLOAD_T; - /// Payload record structure for treatment parameter broadcast messages. typedef struct { @@ -146,22 +136,22 @@ U32 minDialRate; ///< Minimum dialysate flow rate (in mL/min) U32 maxDialRate; ///< Maximum dialysate flow rate (in mL/min) } TREATMENT_PARAM_BROADCAST_PAYLOAD_T; - -// ********** public function prototypes ********** -// Serialize message +// ********** public function prototypes ********** + +// Serialize message U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ); -// ACK MSG +// ACK MSG BOOL sendACKMsg( MESSAGE_T *message ); -// MSG_ID_DG_CHECK_IN -void handleDGCheckIn( MESSAGE_T *message ); - -// MSG_ID_UI_CHECK_IN -void handleUICheckIn( MESSAGE_T *message ); - -// MSG_ID_REQUEST_FW_VERSIONS +// MSG_ID_DG_CHECK_IN +void handleDGCheckIn( MESSAGE_T *message ); + +// MSG_ID_UI_CHECK_IN +void handleUICheckIn( MESSAGE_T *message ); + +// MSG_ID_REQUEST_FW_VERSIONS void handleFWVersionRequest( MESSAGE_T *message ); // MSG_ID_REQUEST_FW_VERSIONS @@ -180,8 +170,8 @@ void handleHDServiceScheduleRequest( MESSAGE_T *message ); // MSG_ID_REQUEST_HD_USAGE_INFO -void handleHDUsageInfoRequest( MESSAGE_T *message ); - +void handleHDUsageInfoRequest( MESSAGE_T *message ); + // MSG_ID_DG_VERSION void handleDGVersionResponse( MESSAGE_T *message ); @@ -191,16 +181,16 @@ // MSG_ID_HD_EVENT BOOL sendEvent( HD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ); -// MSG_ID_OFF_BUTTON_PRESS -BOOL sendOffButtonMsgToUI( U08 cmd ); -void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ); +// MSG_ID_OFF_BUTTON_PRESS +BOOL sendOffButtonMsgToUI( U08 cmd ); +void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ); // MSG_ID_ALARM_TRIGGERED void handleAlarmTriggered( MESSAGE_T *message ); // MSG_ID_ALARM_CLEARED void handleAlarmCleared( MESSAGE_T *message ); - + // MSG_ID_USER_REQUEST_ALARM_SILENCE void handleUIAlarmSilenceRequest( MESSAGE_T *message ); @@ -222,19 +212,19 @@ // MSG_ID_UI_POST_FINAL_TEST_RESULT void handleUIPOSTFinalResult( MESSAGE_T *message ); -// MSG_ID_LOAD_CELL_READINGS +// MSG_ID_LOAD_CELL_READINGS void handleLoadCellReadingsFromDG( MESSAGE_T *message ); // MSG_ID_DG_HEATERS_DATA -void handleDGHeatersData( MESSAGE_T *message ); - -// MSG_ID_DG_TEMPERATURE_DATA: -void handleDGTemperatureData( MESSAGE_T *message ); - +void handleDGHeatersData( MESSAGE_T *message ); + +// MSG_ID_DG_TEMPERATURE_DATA: +void handleDGTemperatureData( MESSAGE_T *message ); + // MSG_ID_DG_FLOW_SENSORS_DATA -void handleDialysateFlowData( MESSAGE_T *message ); - -// MSG_ID_DG_RESERVOIR_DATA: +void handleDialysateFlowData( MESSAGE_T *message ); + +// MSG_ID_DG_RESERVOIR_DATA: void handleDGReservoirData( MESSAGE_T *message ); // MSG_ID_UI_INITIATE_TREATMENT_REQUEST @@ -247,8 +237,8 @@ void handleTreatmentParametersFromUI( MESSAGE_T *message ); // MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE -BOOL sendTreatmentParametersResponseMsg( BOOL accepted, U08 *rejectReasons, U32 byteLength ); - +BOOL sendTreatmentParametersResponseMsg( BOOL accepted, U08 *rejectReasons, U32 byteLength ); + // MSG_ID_UI_SET_UF_VOLUME_PARAMETER void handleUFVolumeSetRequest( MESSAGE_T *message ); @@ -258,40 +248,40 @@ // MSG_ID_UI_USER_CONFIRM_TREATMENT_PARAMS void handleUIUserConfirmTreatmentParameters( MESSAGE_T *message ); -// MSG_ID_USER_UF_PAUSE_RESUME_REQUEST -void handleUFPauseResumeRequest( MESSAGE_T *message ); +// MSG_ID_USER_UF_PAUSE_RESUME_REQUEST +void handleUFPauseResumeRequest( MESSAGE_T *message ); -// MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE +// MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE BOOL sendUFPauseResumeResponse( BOOL accepted, U32 reason, U32 ufState ); -// MSG_ID_USER_UF_SETTINGS_CHANGE_REQUEST -void handleChangeUFSettingsRequest( MESSAGE_T *message ); - -// MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE -BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff, F32 oldUFRate_mL_min ); - -// MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE -void handleChangeUFSettingsConfirmation( MESSAGE_T *message ); - -// MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE -BOOL sendChangeUFSettingsOptionResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min ); - -// MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST -void handleChangeTreatmentDurationRequest( MESSAGE_T *message ); - -// MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE -BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ); - +// MSG_ID_USER_UF_SETTINGS_CHANGE_REQUEST +void handleChangeUFSettingsRequest( MESSAGE_T *message ); + +// MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE +BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff, F32 oldUFRate_mL_min ); + +// MSG_ID_USER_CONFIRM_UF_SETTINGS_CHANGE +void handleChangeUFSettingsConfirmation( MESSAGE_T *message ); + +// MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE +BOOL sendChangeUFSettingsOptionResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min ); + +// MSG_ID_USER_TREATMENT_TIME_CHANGE_REQUEST +void handleChangeTreatmentDurationRequest( MESSAGE_T *message ); + +// MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE +BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ); + // MSG_ID_TREATMENT_TIME_REMAINING_OVERRIDE: void handleTestTreatmentTimeRemainingOverrideRequest( MESSAGE_T *message ); -// MSG_ID_TREATMENT_PARAM_CHANGE_RANGES -BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ); +// MSG_ID_TREATMENT_PARAM_CHANGE_RANGES +BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ); // MSG_ID_HD_TREATMENT_LOG_PERIODIC_DATA BOOL sendTreatmentPeriodicDataToUI( TREATMENT_LOG_DATA_PERIODIC_T * periodDataPtr ); -// MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST +// MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_REQUEST void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ); // MSG_ID_USER_SALINE_BOLUS_REQUEST @@ -300,9 +290,9 @@ // MSG_ID_USER_SALINE_BOLUS_RESPONSE BOOL sendSalineBolusResponse( BOOL accepted, U32 rejReason, U32 bolusVol ); -// MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE -BOOL sendChangeBloodDialysateRateChangeResponse( BOOL accepted, U32 reason, U32 bloodRate, U32 dialRate ); - +// MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE +BOOL sendChangeBloodDialysateRateChangeResponse( BOOL accepted, U32 reason, U32 bloodRate, U32 dialRate ); + // MSG_ID_UI_PRESSURE_LIMITS_CHANGE_REQUEST void handleChangePressureLimitsRequest( MESSAGE_T *message ); @@ -437,37 +427,37 @@ // *********** public DG command functions ********** -// MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS -BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ); - -// MSG_ID_DG_SWITCH_RESERVOIR_CMD -BOOL sendDGSwitchReservoirCommand( DG_SWITCH_RSRVRS_CMD_T *cmd ); +// MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS +BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ); +// MSG_ID_DG_SWITCH_RESERVOIR_CMD +BOOL sendDGSwitchReservoirCommand( DG_SWITCH_RSRVRS_CMD_T *cmd ); + // MSG_ID_DG_CHANGE_VALVE_SETTING_CMD BOOL sendDGChangeValveSettingCommand( U32 valveSettingCmd ); - -// MSG_ID_DG_FILL_CMD -BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ); - -// MSG_ID_DG_DRAIN_CMD -BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ); - -// MSG_ID_STARTING_STOPPING_TREATMENT_CMD -BOOL sendDGStartStopCommand( BOOL start ); - -// MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD -BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ); - -// MSG_ID_DG_SAMPLE_WATER_CMD -BOOL sendDGSampleWaterCommand( SAMPLE_WATER_CMD_T cmd ); +// MSG_ID_DG_FILL_CMD +BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ); + +// MSG_ID_DG_DRAIN_CMD +BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ); + +// MSG_ID_STARTING_STOPPING_TREATMENT_CMD +BOOL sendDGStartStopCommand( BOOL start ); + +// MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start ); + +// MSG_ID_DG_SAMPLE_WATER_CMD +BOOL sendDGSampleWaterCommand( SAMPLE_WATER_CMD_T cmd ); + // MSG_ID_DG_COMMAND_RESPONSE void handleDGCmdResp( MESSAGE_T *messagePtr ); // MSG_ID_UI_HD_SET_RTC_REQUEST: void handleUIClockSyncRequest( MESSAGE_T *message ); - -// MSG_ID_DG_OP_MODE + +// MSG_ID_DG_OP_MODE void handleDGOpMode( MESSAGE_T *message ); // MSG_ID_DG_START_STOP_FLUSH @@ -494,7 +484,7 @@ // MSG_ID_UI_REQUEST_SERVICE_MODE void handleUIServiceModeRequest( MESSAGE_T *message ); -// MSG_ID_ALARM_STATUS +// MSG_ID_ALARM_STATUS BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ); // MSG_ID_HD_SEND_CALIBRATION_RECORD @@ -568,124 +558,124 @@ // MSG_ID_DG_SEND_RO_PERMEATE_SAMPLE_DISPENSE_READY_TO_HD void handleReceiveROPermeateSampleReadyToDispenseFromDG( MESSAGE_T* message ); -// *********** public test support message functions ********** - -// MSG_TESTER_LOG_IN -void handleTesterLogInRequest( MESSAGE_T *message ); +// *********** public test support message functions ********** + +// MSG_TESTER_LOG_IN +void handleTesterLogInRequest( MESSAGE_T *message ); BOOL isTestingActivated( void ); -void setTesterStatusToLoggedOut( void ); - -// MSG_ID_OFF_BUTTON_STATE_OVERRIDE -void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_STOP_BUTTON_STATE_OVERRIDE -void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE -void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: -void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_ALARM_STATE_OVERRIDE -void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_ALARM_TIME_OVERRIDE -void handleTestAlarmTimeOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_FLOW_SET_PT_OVERRIDE -void handleTestBloodFlowSetPointOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_FLOW_MEAS_OVERRIDE -void handleTestBloodFlowMeasuredOverrideRequest( MESSAGE_T *message ); - +void setTesterStatusToLoggedOut( void ); + +// MSG_ID_OFF_BUTTON_STATE_OVERRIDE +void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_STOP_BUTTON_STATE_OVERRIDE +void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_ALARM_LAMP_PATTERN_OVERRIDE +void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_WATCHDOG_TASK_CHECKIN_OVERRIDE: +void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_ALARM_STATE_OVERRIDE +void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_ALARM_TIME_OVERRIDE +void handleTestAlarmTimeOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_FLOW_SET_PT_OVERRIDE +void handleTestBloodFlowSetPointOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_FLOW_MEAS_OVERRIDE +void handleTestBloodFlowMeasuredOverrideRequest( MESSAGE_T *message ); + // MSG_ID_BLOOD_ROTOR_COUNT_OVERRIDE void handleHDBloodPumpRotorCountOverrideRequest( MESSAGE_T *message ); // MSG_ID_DIALYSATE_INLET_PUMP_ROTOR_COUNT_OVERRIDE void handleHDDialInPumpRotorCountOverrideRequest( MESSAGE_T *message ); -// MSG_ID_BLOOD_PUMP_MC_MEAS_SPEED_OVERRIDE -void handleTestBloodPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_PUMP_MC_MEAS_CURR_OVERRIDE -void handleTestBloodPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_FLOW_SEND_INTERVAL_OVERRIDE -void handleTestBloodFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE -void handleTestBloodPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE -void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE +// MSG_ID_BLOOD_PUMP_MC_MEAS_SPEED_OVERRIDE +void handleTestBloodPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_PUMP_MC_MEAS_CURR_OVERRIDE +void handleTestBloodPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_FLOW_SEND_INTERVAL_OVERRIDE +void handleTestBloodFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_PUMP_MEAS_SPEED_OVERRIDE +void handleTestBloodPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_BLOOD_PUMP_MEAS_ROTOR_SPEED_OVERRIDE +void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_FLOW_SET_PT_OVERRIDE void handleTestDialInFlowSetPointOverrideRequest( MESSAGE_T *message ); // MSG_ID_DIAL_OUT_FLOW_SET_PT_OVERRIDE -void handleTestDialOutFlowSetPointOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE -void handleTestDialInFlowMeasuredOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE -void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE -void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE -void handleTestDialInFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE -void handleTestDialInPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE -void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_PRESSURE_ARTERIAL_OVERRIDE -void handleTestArterialPressureOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_PRESSURE_VENOUS_OVERRIDE -void handleTestVenousPressureOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE -void handleTestBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE -void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_SET_RTC_TIMESTAMP -void handleSetRTCTimestamp( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_FLOW_SEND_INTERVAL_OVERRIDE -void handleTestDialOutFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_UF_REF_VOLUME_OVERRIDE -void handleTestDialOutUFReferenceVolumeOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_UF_MEAS_VOLUME_OVERRIDE -void handleTestDialOutUFMeasuredVolumeOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_PUMP_MC_MEAS_SPEED_OVERRIDE -void handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_PUMP_MC_MEAS_CURR_OVERRIDE -void handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_PUMP_MEAS_SPEED_OVERRIDE -void handleTestDialOutPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_PUMP_MEAS_ROTOR_SPEED_OVERRIDE -void handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_DIAL_OUT_LOAD_CELL_WEIGHT_OVERRIDE -void handleTestDialOutLoadCellWeightOverrideRequest( MESSAGE_T *message ); - -// MSG_ID_HD_SAFETY_SHUTDOWN_OVERRIDE: -void handleTestHDSafetyShutdownOverrideRequest( MESSAGE_T *message ); +void handleTestDialOutFlowSetPointOverrideRequest( MESSAGE_T *message ); +// MSG_ID_DIAL_IN_FLOW_MEAS_OVERRIDE +void handleTestDialInFlowMeasuredOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_PUMP_MC_MEAS_SPEED_OVERRIDE +void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_PUMP_MC_MEAS_CURR_OVERRIDE +void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_FLOW_SEND_INTERVAL_OVERRIDE +void handleTestDialInFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_PUMP_MEAS_SPEED_OVERRIDE +void handleTestDialInPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_IN_PUMP_MEAS_ROTOR_SPEED_OVERRIDE +void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRESSURE_ARTERIAL_OVERRIDE +void handleTestArterialPressureOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRESSURE_VENOUS_OVERRIDE +void handleTestVenousPressureOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_OCCLUSION_BLOOD_PUMP_OVERRIDE +void handleTestBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_PRES_OCCL_SEND_INTERVAL_OVERRIDE +void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_SET_RTC_TIMESTAMP +void handleSetRTCTimestamp( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_FLOW_SEND_INTERVAL_OVERRIDE +void handleTestDialOutFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_UF_REF_VOLUME_OVERRIDE +void handleTestDialOutUFReferenceVolumeOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_UF_MEAS_VOLUME_OVERRIDE +void handleTestDialOutUFMeasuredVolumeOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_PUMP_MC_MEAS_SPEED_OVERRIDE +void handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_PUMP_MC_MEAS_CURR_OVERRIDE +void handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_PUMP_MEAS_SPEED_OVERRIDE +void handleTestDialOutPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_PUMP_MEAS_ROTOR_SPEED_OVERRIDE +void handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_DIAL_OUT_LOAD_CELL_WEIGHT_OVERRIDE +void handleTestDialOutLoadCellWeightOverrideRequest( MESSAGE_T *message ); + +// MSG_ID_HD_SAFETY_SHUTDOWN_OVERRIDE: +void handleTestHDSafetyShutdownOverrideRequest( MESSAGE_T *message ); + // MSG_ID_HD_ACCEL_OVERRIDE: void handleTestHDAccelOverrideRequest( MESSAGE_T *message ); @@ -1018,4 +1008,4 @@ /**@}*/ -#endif +#endif