Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r49533d4870aa10c1b20406dd5c013567fe854694 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 49533d4870aa10c1b20406dd5c013567fe854694) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -7,8 +7,8 @@ * * @file SyringePump.c * -* @author (last) Dara Navaei -* @date (last) 31-Mar-2022 +* @author (last) Darren Cox +* @date (last) 13-May-2022 * * @author (original) Sean Nash * @date (original) 04-Mar-2021 @@ -367,6 +367,7 @@ accepted = TRUE; heparinDeliveryState = HEPARIN_STATE_PAUSED; stopSyringePump(); + sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, HEPARIN_STATE_DISPENSING, HEPARIN_STATE_PAUSED ); } else { @@ -379,6 +380,7 @@ { accepted = TRUE; startHeparinContinuous(); + sendTreatmentLogEventData( HEPARIN_START_RESUME_EVENT, HEPARIN_STATE_PAUSED, HEPARIN_STATE_DISPENSING ); } else { Index: firmware/App/HDCommon.h =================================================================== diff -u -rd678b71dda2e9b4489829da9ee5c8094b26f27dc -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/HDCommon.h (.../HDCommon.h) (revision d678b71dda2e9b4489829da9ee5c8094b26f27dc) +++ firmware/App/HDCommon.h (.../HDCommon.h) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -99,11 +99,11 @@ /// 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. Index: firmware/App/Modes/Dialysis.c =================================================================== diff -u -r49533d4870aa10c1b20406dd5c013567fe854694 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 49533d4870aa10c1b20406dd5c013567fe854694) +++ firmware/App/Modes/Dialysis.c (.../Dialysis.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -8,7 +8,7 @@ * @file Dialysis.c * * @author (last) Darren Cox -* @date (last) 10-Mar-2022 +* @date (last) 13-May-2022 * * @author (original) Sean * @date (original) 15-Jan-2020 @@ -516,6 +516,7 @@ setDialOutPumpTargetRate( setDialysateFlowRate, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Go to UF paused state currentUFState = UF_PAUSED_STATE; + sendTreatmentLogEventData( UF_START_RESUME_EVENT, UF_RUNNING_STATE, UF_PAUSED_STATE ); } else { @@ -568,6 +569,7 @@ lastUFTimeStamp = getMSTimerCount(); // Go to UF running state currentUFState = UF_RUNNING_STATE; + sendTreatmentLogEventData( UF_START_RESUME_EVENT, UF_PAUSED_STATE, UF_RUNNING_STATE ); } else { Index: firmware/App/Modes/ModeTreatment.c =================================================================== diff -u -r49533d4870aa10c1b20406dd5c013567fe854694 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 49533d4870aa10c1b20406dd5c013567fe854694) +++ firmware/App/Modes/ModeTreatment.c (.../ModeTreatment.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -8,7 +8,7 @@ * @file ModeTreatment.c * * @author (last) Darren Cox -* @date (last) 10-Mar-2022 +* @date (last) 11-May-2022 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -ra33009eaa35d2d5be3872b64f2f1609196769256 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision a33009eaa35d2d5be3872b64f2f1609196769256) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -7,8 +7,8 @@ * * @file SelfTests.c * -* @author (last) Dara Navaei -* @date (last) 31-Mar-2022 +* @author (last) Darren Cox +* @date (last) 13-May-2022 * * @author (original) Quang Nguyen * @date (original) 28-Jan-2021 @@ -384,6 +384,8 @@ *************************************************************************/ void execDrySelfTests( void ) { + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + // execute dry self-tests state machine switch ( currentDrySelfTestsState ) { @@ -460,6 +462,11 @@ // Self-tests flags should be handled by now, reset if flags not handled with current state resetSelfTestsFlags(); + if ( SELF_TEST_STATUS_FAILED == result ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRE_TREATMENT_DRY_PRESSURE_TEST_FAILURE, currentDrySelfTestsState ); + } + // Publish current self-test time data if ( calcTimeSince( selfTestPreviousPublishDataTime ) >= SELF_TEST_TIME_DATA_PUB_INTERVAL ) { @@ -538,6 +545,8 @@ *************************************************************************/ void execWetSelfTests( void ) { + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_PASSED; + #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_WET_SELF_TEST ) == SW_CONFIG_ENABLE_VALUE ) { @@ -607,6 +616,11 @@ // Self-tests flags should be handled by now, reset if flags not handled with current state resetSelfTestsFlags(); + + if ( SELF_TEST_STATUS_FAILED == result ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_PRE_TREATMENT_WET_LC_TEST_FAILURE, currentWetSelfTestsState ); + } } /*********************************************************************//** Index: firmware/App/Modes/TreatmentEnd.c =================================================================== diff -u -rb3724006e900d548c758aee54cd35386f19a7f1a -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision b3724006e900d548c758aee54cd35386f19a7f1a) +++ firmware/App/Modes/TreatmentEnd.c (.../TreatmentEnd.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -50,6 +50,7 @@ static BOOL txEndAlarmRinsebackRequested; ///< Flag indicates user requesting rinseback from alarm. static BOOL txEndAlarmEndTreatmentRequested; ///< Flag indicates user requesting end treatment from alarm. static BOOL txEndRinsebackRequested; ///< Flag indicates user requesting final rinseback. +static BOOL txEndDrainCmdSent; ///< Flag indicates DG Drain command has been sent. // ********** private function prototypes ********** @@ -76,6 +77,7 @@ treatmentEndState = TREATMENT_END_WAIT_FOR_RINSEBACK_STATE; txEndTimerCtr = 0; bloodSittingTimerCtr = 0; + txEndDrainCmdSent = FALSE; resetTreatmentEndFlags(); } @@ -125,6 +127,9 @@ // Continue air trap control startAirTrapControl(); + // Command the blood leak to exit the normal state + exitBloodLeakNormalState(); + // Set user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); // Resume in this sub-mode indicates resume wait for user rinseback request (not resume treatment) setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); @@ -228,7 +233,11 @@ } else { - cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, FALSE, TRUE ); + if ( txEndDrainCmdSent != TRUE ) + { + txEndDrainCmdSent = TRUE; + cmdStartDGDrain( DRAIN_RESERVOIR_TO_VOLUME_ML, TRUE, FALSE, TRUE ); + } } } Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -rb3724006e900d548c758aee54cd35386f19a7f1a -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision b3724006e900d548c758aee54cd35386f19a7f1a) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -17,6 +17,7 @@ #include "AirTrap.h" #include "BloodFlow.h" +#include "BloodLeak.h" #include "DGInterface.h" #include "DialInFlow.h" #include "DialOutFlow.h" @@ -97,6 +98,7 @@ { setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, TRUE ); } + setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); // Ensure syringe pump is stopped Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r22cab5beebd48faf29e78c5003b0bdd0a32748e8 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 22cab5beebd48faf29e78c5003b0bdd0a32748e8) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -7,8 +7,8 @@ * * @file AlarmMgmt.c * -* @author (last) Michael Garthwaite -* @date (last) 11-Mar-2022 +* @author (last) Darren Cox +* @date (last) 28-Mar-2022 * * @author (original) Sean Nash * @date (original) 07-Nov-2019 @@ -198,7 +198,8 @@ alarmStatus.noClear = FALSE; alarmStatus.noResume = FALSE; alarmStatus.noRinseback = FALSE; - alarmStatus.noEndTreatment = FALSE; + alarmStatus.noEndTreatment = FALSE; + alarmStatus.noBloodRecirc = FALSE; alarmStatus.noDialRecirc = FALSE; alarmStatus.ok = FALSE; @@ -572,6 +573,19 @@ /*********************************************************************//** * @brief + * The isBloodRecircBlocked function determines whether any currently + * active alarm is blocking blood re-circulation. + * @details Inputs: alarmStatus + * @details Outputs: none + * @return TRUE if any active alarm prevents blood re-circulation, FALSE if not + *************************************************************************/ +BOOL isBloodRecircBlocked( void ) +{ + return alarmStatus.noBloodRecirc; +} + +/*********************************************************************//** + * @brief * The isDialysateRecircBlocked function determines whether any currently * active alarm is blocking dialysate re-circulation. * @details Inputs: alarmStatus @@ -754,6 +768,7 @@ ALARM_ID_T a; BOOL faultsActive = FALSE; BOOL dialysateRecircBlocked = FALSE; + BOOL bloodRecircBlocked = FALSE; // Update FIFOs and sub-ranks per active alarms table - for alarm ranking purposes to determine "top" alarm for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) @@ -797,6 +812,11 @@ { dialysateRecircBlocked = TRUE; } + // Track whether any active alarms prevent blood re-circulation so far + if ( TRUE == ALARM_TABLE[ a ].alarmNoBloodRecirc ) + { + bloodRecircBlocked = TRUE; + } } } @@ -805,6 +825,7 @@ alarmStatus.alarmTop = alarmPriorityFIFO[ highestPriority ].alarmID; alarmStatus.topAlarmConditionDetected = alarmIsDetected[ alarmStatus.alarmTop ]; alarmStatus.systemFault = faultsActive; + alarmStatus.noBloodRecirc = bloodRecircBlocked; alarmStatus.noDialRecirc = dialysateRecircBlocked; } Index: firmware/App/Services/AlarmMgmt.h =================================================================== diff -u -r7a878f735bf78937f6d55f4b9a45618ac8eef4f3 -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 7a878f735bf78937f6d55f4b9a45618ac8eef4f3) +++ firmware/App/Services/AlarmMgmt.h (.../AlarmMgmt.h) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -7,8 +7,8 @@ * * @file AlarmMgmt.h * -* @author (last) Michael Garthwaite -* @date (last) 11-Mar-2022 +* @author (last) Darren Cox +* @date (last) 28-Mar-2022 * * @author (original) Sean Nash * @date (original) 07-Nov-2019 @@ -71,6 +71,7 @@ BOOL noResume; ///< Treatment may not be resumed at this time BOOL noRinseback; ///< Rinseback may not be initiated at this time BOOL noEndTreatment; ///< Ending the treatment is not an option at this time + BOOL noBloodRecirc; ///< No blood re-circulation allowed at this time BOOL noDialRecirc; ///< No dialysate re-circulation allowed at this time BOOL ok; ///< Display OK button instead of other options BOOL noMinimize; ///< Prevent user from minimizing the alarm window @@ -175,6 +176,7 @@ void signalAlarmUserActionInitiated( ALARM_USER_ACTION_T action ); BOOL isAlarmActive( ALARM_ID_T alarm ); BOOL isAnyAlarmActive( void ); +BOOL isBloodRecircBlocked( void ); BOOL isDialysateRecircBlocked( void ); BOOL doesAlarmStatusIndicateStop( void ); ALARM_PRIORITY_T getCurrentAlarmStatePriority( void ); Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rb3724006e900d548c758aee54cd35386f19a7f1a -r9944e4f766d9eb4cdf7a5ca7587e3ceca556e106 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision b3724006e900d548c758aee54cd35386f19a7f1a) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9944e4f766d9eb4cdf7a5ca7587e3ceca556e106) @@ -14,40 +14,40 @@ * @date (original) 05-Nov-2019 * ***************************************************************************/ - -#include // For memcpy() +#include // For memcpy() + #include "reg_system.h" // Used to access system register to reset processor on request -#include "Accel.h" +#include "Accel.h" #include "AlarmLamp.h" #include "Battery.h" #include "Buttons.h" #include "Compatible.h" #include "ConsumableSelfTest.h" #include "Fans.h" #include "FPGA.h" -#include "ModeStandby.h" -#include "OperationModes.h" +#include "ModeStandby.h" +#include "OperationModes.h" #include "RTC.h" #include "SampleWater.h" -#include "SafetyShutdown.h" -#include "SystemComm.h" +#include "SafetyShutdown.h" +#include "SystemComm.h" #include "SystemCommMessages.h" #include "Temperatures.h" #include "TreatmentEnd.h" #include "TreatmentRecirc.h" -#include "TreatmentStop.h" +#include "TreatmentStop.h" #include "Utilities.h" -#include "WatchdogMgmt.h" - +#include "WatchdogMgmt.h" + /** * @addtogroup SystemCommMessages * @{ */ -// ********** private definitions ********** - +// ********** private definitions ********** + #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. #pragma pack(push,1) @@ -57,43 +57,43 @@ U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; } BLOCKED_MSGS_DATA_T; #pragma pack(pop) - -// ********** private data ********** - -static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. + +// ********** private data ********** + +static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. /// List of message IDs that are requested not to be transmitted. -static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -// ********** private function prototypes ********** - -static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); +static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; + +// ********** private function prototypes ********** + +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); -static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ); - -/*********************************************************************//** - * @brief - * The serializeMessage function serializes a given message into a given - * array of bytes. A sequence # is added to the message here and the ACK - * bit of the sequence # is set if ACK is required per parameter. A sync byte - * is inserted at the beginning of the message and an 8-bit CRC is appended to - * the end of the message. The message is queued for transmission in the given buffer. - * @details Inputs: blockedMessagesForXmit - * @details Outputs: given data array populated with serialized message data and queued for transmit. - * @param msg message to serialize - * @param buffer outgoing buffer that message should be queued in - * @param ackReq is an acknowledgement from receiver required? - * @return size (in bytes) of serialized message populated in given data array. - *************************************************************************/ -U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) -{ - BOOL result = 0; +static BOOL sendUIResponseMsg( MSG_ID_T msgID, BOOL accepted, U32 reason ); + +/*********************************************************************//** + * @brief + * The serializeMessage function serializes a given message into a given + * array of bytes. A sequence # is added to the message here and the ACK + * bit of the sequence # is set if ACK is required per parameter. A sync byte + * is inserted at the beginning of the message and an 8-bit CRC is appended to + * the end of the message. The message is queued for transmission in the given buffer. + * @details Inputs: blockedMessagesForXmit + * @details Outputs: given data array populated with serialized message data and queued for transmit. + * @param msg message to serialize + * @param buffer outgoing buffer that message should be queued in + * @param ackReq is an acknowledgement from receiver required? + * @return size (in bytes) of serialized message populated in given data array. + *************************************************************************/ +U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) +{ + BOOL result = 0; BOOL error = FALSE; - BOOL blocked = FALSE; - U32 msgSize = 0; - U32 sizeMod, sizePad; - U32 i; - U08 crc; + BOOL blocked = FALSE; + U32 msgSize = 0; + U32 sizeMod, sizePad; + U32 i; + U08 crc; U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data // Check to see if tester has requested this message not be transmited @@ -112,133 +112,135 @@ } // Serialize and queue message for transmission unless this message is blocked if ( blocked != TRUE ) - { - // Prefix data with message sync byte - data[ msgSize++ ] = MESSAGE_SYNC_BYTE; - - // Set sequence # and ACK bit (unless this is an ACK to a received message) - if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) - { - // Thread protect next sequence # access & increment - _disable_IRQ(); - msg.hdr.seqNo = nextSeqNo; - nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); - _enable_IRQ(); - if ( TRUE == ackReq ) - { - msg.hdr.seqNo *= -1; - } - } - - // Calculate message CRC - crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - - // Serialize message header data - memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); - msgSize += sizeof( MESSAGE_HEADER_T ); - - // Serialize message payload (only used bytes per payloadLen field) - memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); - msgSize += msg.hdr.payloadLen; - - // Add 8-bit CRC - data[ msgSize++ ] = crc; - - // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) - sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; - sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); - for ( i = 0; i < sizePad; i++ ) - { - data[ msgSize++ ] = 0; - } + { + // Prefix data with message sync byte + data[ msgSize++ ] = MESSAGE_SYNC_BYTE; + // Set sequence # and ACK bit (unless this is an ACK to a received message) + if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) + { + // Thread protect next sequence # access & increment + _disable_IRQ(); + msg.hdr.seqNo = nextSeqNo; + nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); + _enable_IRQ(); + if ( TRUE == ackReq ) + { + msg.hdr.seqNo *= -1; + } + } + + // Calculate message CRC + crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); + + // Serialize message header data + memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); + msgSize += sizeof( MESSAGE_HEADER_T ); + + // Serialize message payload (only used bytes per payloadLen field) + memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); + msgSize += msg.hdr.payloadLen; + + // Add 8-bit CRC + data[ msgSize++ ] = crc; + + // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; + sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); + for ( i = 0; i < sizePad; i++ ) + { + data[ msgSize++ ] = 0; + } + +#ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ACK_ERRORS ) != SW_CONFIG_ENABLE_VALUE ) - { - // If ACK required, add to pending ACK list - if ( TRUE == ackReq ) - { - if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) - { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) - } +#endif + { + // If ACK required, add to pending ACK list + if ( TRUE == ackReq ) + { + if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + { + error = TRUE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + } } - } - - if ( FALSE == error ) - { - // Add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } + } + + if ( FALSE == error ) + { + // Add serialized message data to appropriate out-going comm buffer + result = addToCommBuffer( buffer, data, msgSize ); + } } else { result = TRUE; // If message blocked, return successful transmission } - - return result; -} - -/*********************************************************************//** - * @brief - * The sendACKMsg function constructs and queues for transmit an ACK message - * for a given received message. - * @details Inputs: none - * @details Outputs: ACK message queued for transmit on broadcast CAN channel. - * @param message message to send an ACK for - * @return TRUE if ACK message queued successfully, FALSE if not - *************************************************************************/ -BOOL sendACKMsg( MESSAGE_T *message ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - // Send ACK back with same seq. #, but w/o ACK bit - msg.hdr.seqNo = message->hdr.seqNo * -1; - // ACK messages always have this ID - msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; - // ACK messages always have no payload - msg.hdr.payloadLen = 0; - - // Serialize and queue the message for transmit on broadcast channel - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendAckResponseMsg function constructs a simple response - * message for a handled message and queues it for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param buffer outgoing buffer that message should be queued in - * @param ack TRUE if test message was handled successfully, FALSE if not - * @return TRUE if response message successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); - - return result; -} + return result; +} + /*********************************************************************//** * @brief + * The sendACKMsg function constructs and queues for transmit an ACK message + * for a given received message. + * @details Inputs: none + * @details Outputs: ACK message queued for transmit on broadcast CAN channel. + * @param message message to send an ACK for + * @return TRUE if ACK message queued successfully, FALSE if not + *************************************************************************/ +BOOL sendACKMsg( MESSAGE_T *message ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + // Send ACK back with same seq. #, but w/o ACK bit + msg.hdr.seqNo = message->hdr.seqNo * -1; + // ACK messages always have this ID + msg.hdr.msgID = MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK; + // ACK messages always have no payload + msg.hdr.payloadLen = 0; + + // Serialize and queue the message for transmit on broadcast channel + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendAckResponseMsg function constructs a simple response + * message for a handled message and queues it for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param buffer outgoing buffer that message should be queued in + * @param ack TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, buffer, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The sendUIResponseMsg function constructs an UI response message for a * handled UI message and queues it for transmit on the appropriate CAN channel. * @details Inputs: none @@ -269,36 +271,36 @@ return result; } - -// *********************************************************************** -// ***************** Message Sending Helper Functions ******************** -// *********************************************************************** - -/*********************************************************************//** - * @brief - * The sendOffButtonMsgToUI function constructs an off button msg to the UI - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Off button msg constructed and queued. - * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 cmd ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = cmd; - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; +// *********************************************************************** +// ***************** Message Sending Helper Functions ******************** +// *********************************************************************** + + +/*********************************************************************//** + * @brief + * The sendOffButtonMsgToUI function constructs an off button msg to the UI + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Off button msg constructed and queued. + * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendOffButtonMsgToUI( U08 cmd ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = cmd; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } /*********************************************************************//** @@ -310,7 +312,7 @@ * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ BOOL sendUIVersionRequest( void ) -{ +{ BOOL result; MESSAGE_T msg; @@ -391,176 +393,176 @@ return result; } - -/*********************************************************************//** - * @brief - * The sendChangeUFSettingsResponse function constructs a UF change settings - * response to the UI and queues the msg for transmit on the appropriate CAN - * channel. - * @details Inputs: none - * @details Outputs: UF change settings response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param volume_mL UF volume (in mL) - * @param time_min treatment duration (in minutes) - * @param ufRate_mL_min UF rate (in mL/min) - * @param timeDiff change in treatment duration (in minutes) - * @param rateDiff change in UF rate (in mL/min) - * @param oldUFRate_mL_min the UF rate prior to this change (in mL/min) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff, F32 oldUFRate_mL_min ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); - payloadPtr += sizeof( S32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; + +/*********************************************************************//** + * @brief + * The sendChangeUFSettingsResponse function constructs a UF change settings + * response to the UI and queues the msg for transmit on the appropriate CAN + * channel. + * @details Inputs: none + * @details Outputs: UF change settings response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @param time_min treatment duration (in minutes) + * @param ufRate_mL_min UF rate (in mL/min) + * @param timeDiff change in treatment duration (in minutes) + * @param rateDiff change in UF rate (in mL/min) + * @param oldUFRate_mL_min the UF rate prior to this change (in mL/min) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendChangeUFSettingsResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min, S32 timeDiff, F32 rateDiff, F32 oldUFRate_mL_min ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( S32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); + payloadPtr += sizeof( S32 ); + memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } -/*********************************************************************//** - * @brief - * The sendChangeUFSettingsResponse function constructs a UF change settings - * option response to the UI and queues the msg for transmit on the appropriate CAN - * channel. - * @details Inputs: none - * @details Outputs: UF change settings option response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param volume_mL UF volume (in mL) - * @param time_min treatment duration (in minutes) - * @param ufRate_mL_min UF rate (in mL/min) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendChangeUFSettingsOptionResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendChangeTreatmentDurationResponse function constructs a treatment - * duration change response to the UI and queues the msg for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment duration change settings response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason rejected (if not accepted) - * @param time_min treatment duration (in minutes) - * @param volume_mL UF volume (in mL) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; +/*********************************************************************//** + * @brief + * The sendChangeUFSettingsResponse function constructs a UF change settings + * option response to the UI and queues the msg for transmit on the appropriate CAN + * channel. + * @details Inputs: none + * @details Outputs: UF change settings option response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param volume_mL UF volume (in mL) + * @param time_min treatment duration (in minutes) + * @param ufRate_mL_min UF rate (in mL/min) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendChangeUFSettingsOptionResponse( BOOL accepted, U32 reason, F32 volume_mL, U32 time_min, F32 ufRate_mL_min ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_UF_SETTINGS_CHANGE_CONFIRMATION_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } -/*********************************************************************//** - * @brief - * The sendChangeBloodDialysateRateChangeResponse function constructs a change - * blood and dialysate rate settings response to the UI and queues the msg for - * transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Blood & dialysate rate change response msg constructed and queued. - * @param accepted T/F - are settings ok? - * @param reason reason code for rejection or unused if accepted - * @param bloodRate new blood flow rate - * @param dialRate new dialysate flow rate - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendChangeBloodDialysateRateChangeResponse( BOOL accepted, U32 reason, U32 bloodRate, U32 dialRate ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dialRate, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; +/*********************************************************************//** + * @brief + * The sendChangeTreatmentDurationResponse function constructs a treatment + * duration change response to the UI and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: treatment duration change settings response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason rejected (if not accepted) + * @param time_min treatment duration (in minutes) + * @param volume_mL UF volume (in mL) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendChangeTreatmentDurationResponse( BOOL accepted, U32 reason, U32 time_min, F32 volume_mL ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_TREATMENT_TIME_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &time_min, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } /*********************************************************************//** * @brief + * The sendChangeBloodDialysateRateChangeResponse function constructs a change + * blood and dialysate rate settings response to the UI and queues the msg for + * transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Blood & dialysate rate change response msg constructed and queued. + * @param accepted T/F - are settings ok? + * @param reason reason code for rejection or unused if accepted + * @param bloodRate new blood flow rate + * @param dialRate new dialysate flow rate + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendChangeBloodDialysateRateChangeResponse( BOOL accepted, U32 reason, U32 bloodRate, U32 dialRate ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_USER_BLOOD_DIAL_RATE_CHANGE_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dialRate, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The sendPressureLimitsChangeResponse function constructs a change * pressure limits response to the UI and queues the msg for transmit on the * appropriate CAN channel. @@ -652,49 +654,49 @@ return result; } -/*********************************************************************//** - * @brief - * The sendTreatmentParamsRangesToUI function constructs a treatment parameter - * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Treatment parameter ranges msg constructed and queued. - * @param minTime Minimum treatment duration (in minutes) - * @param maxTime Maximum treatment duration (in minutes) - * @param minUFVol Minimum ultrafiltration volume (in mL) - * @param maxUFVol Maximum ultrafiltration volume (in mL) - * @param minDialRate Minimum dialysate flow rate (in mL/min) - * @param maxDialRate Maximum dialysate flow rate (in mL/min) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &minTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); - - return result; +/*********************************************************************//** + * @brief + * The sendTreatmentParamsRangesToUI function constructs a treatment parameter + * ranges message to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Treatment parameter ranges msg constructed and queued. + * @param minTime Minimum treatment duration (in minutes) + * @param maxTime Maximum treatment duration (in minutes) + * @param minUFVol Minimum ultrafiltration volume (in mL) + * @param maxUFVol Maximum ultrafiltration volume (in mL) + * @param minDialRate Minimum dialysate flow rate (in mL/min) + * @param maxDialRate Maximum dialysate flow rate (in mL/min) + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendTreatmentParamsRangesToUI( U32 minTime, U32 maxTime, F32 minUFVol, F32 maxUFVol, U32 minDialRate, U32 maxDialRate ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_TREATMENT_PARAM_CHANGE_RANGES; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ) + sizeof( F32 ) + sizeof( U32 ) + sizeof( U32 ); + + memcpy( payloadPtr, &minTime, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); + payloadPtr += sizeof( F32 ); + memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + + return result; } - + /*********************************************************************//** * @brief * The sendTreatmentPeriodicDataToUI function constructs a treatment periodic @@ -1020,6 +1022,7 @@ } /*********************************************************************//** + * @brief * The sendActiveAlarmsList function constructs a treatment log data message * for UI and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -1378,67 +1381,67 @@ return sendUIResponseMsg( MSG_ID_HD_START_TREATMENT_RESPONSE, accepted, reason ); } -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The sendDialysateTempTargetsAndReservoirCycleTimeToDG function constructs a * dialysate temperature set points message and the active reservoir cycle time - * for DG and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Dialysate temperature set points msg constructed and queued. + * for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: Dialysate temperature set points msg constructed and queued. * @param trimmer temperature set point for trimmer heater * @param rsrvrCycleTime active reservoir cycle time in milliseconds - * @param rsrvrWait2Switch time to switch the inactive and active reservoirs in milliseconds - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; - msg.hdr.payloadLen = sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ); - + * @param rsrvrWait2Switch time to switch the inactive and active reservoirs in milliseconds + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDialysateHeatingParamsToDG( DG_CMD_DIALYSATE_HEATING_PARAMS_T *params ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; + msg.hdr.payloadLen = sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ); + memcpy( payloadPtr, params, sizeof( DG_CMD_DIALYSATE_HEATING_PARAMS_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGSwitchReservoirCommand function constructs a DG set active - * reservoir message for DG and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG set active reservoir msg constructed and queued. - * @param activeReservoir reservoir ID to set as active - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGSwitchReservoirCommand( U32 activeReservoir ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &activeReservoir, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + /*********************************************************************//** * @brief + * The sendDGSwitchReservoirCommand function constructs a DG set active + * reservoir message for DG and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG set active reservoir msg constructed and queued. + * @param activeReservoir reservoir ID to set as active + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSwitchReservoirCommand( U32 activeReservoir ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SWITCH_RESERVOIR_CMD; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &activeReservoir, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief * The sendDGChangeValveSettingCommand function constructs a DG change valve * setting message for DG and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none @@ -1464,156 +1467,156 @@ return result; } - -/*********************************************************************//** - * @brief - * The sendDGFillCommand function constructs a DG fill command message - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none + +/*********************************************************************//** + * @brief + * The sendDGFillCommand function constructs a DG fill command message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none * @details Outputs: DG fill command msg constructed and queued. - * @param cmd start or stop fill command + * @param cmd start or stop fill command * @param fillToVolumeMl volume (in mL) to fill inactive reservoir to - * @param targetFlowLRatePM target fill flow rate in L/min - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_FILL_CMD; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + * @param targetFlowLRatePM target fill flow rate in L/min + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGFillCommand( U32 cmd, U32 fillToVolumeMl, F32 targetFlowRateLPM ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_FILL_CMD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( F32 ); + memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &cmd, sizeof( U32 ) ); payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &targetFlowRateLPM, sizeof( F32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGDrainCommand function constructs a DG drain command message - * and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG drain command msg constructed and queued. + memcpy( payloadPtr, &targetFlowRateLPM, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGDrainCommand function constructs a DG drain command message + * and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG drain command msg constructed and queued. * @param drainCmdPtr drain command data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; - msg.hdr.payloadLen = sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ); - - memcpy( payloadPtr, drainCmdPtr, sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGStartStopCommand function constructs a DG start/stop command - * message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG start/stop command msg constructed and queued. - * @param start TRUE indicates start DG, FALSE indicates stop DG - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGStartStopCommand( BOOL start ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); - - memcpy( payloadPtr, &start, sizeof( BOOL ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGStartStopTrimmerHeaterCommand function constructs a DG start/stop - * trimmer heater command message and queues the msg for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGDrainCommand( DRAIN_RESERVOIR_CMD_PAYLOAD_T *drainCmdPtr ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_DRAIN_CMD; + msg.hdr.payloadLen = sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ); + + memcpy( payloadPtr, drainCmdPtr, sizeof( DRAIN_RESERVOIR_CMD_PAYLOAD_T ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartStopCommand function constructs a DG start/stop command + * message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start/stop command msg constructed and queued. + * @param start TRUE indicates start DG, FALSE indicates stop DG + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartStopCommand( BOOL start ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_STARTING_STOPPING_TREATMENT_CMD; + msg.hdr.payloadLen = sizeof( BOOL ); + + memcpy( payloadPtr, &start, sizeof( BOOL ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGStartStopTrimmerHeaterCommand function constructs a DG start/stop + * trimmer heater command message and queues the msg for transmit on the + * appropriate CAN channel. + * @details Inputs: none + * @details Outputs: DG start/stop trimmer heater command msg constructed and queued. * @param start TRUE indicates start heater, FALSE indicates stop heater - * @param trimmerHtrTemp target temperature for trimmer heater - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + * @param trimmerHtrTemp target temperature for trimmer heater + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + memcpy( payloadPtr, &start, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The sendDGSampleWaterCommand function constructs a DG sample water command - * message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none + memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The sendDGSampleWaterCommand function constructs a DG sample water command + * message and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none * @details Outputs: DG sample water command msg constructed and queued. - * @param cmd sample water sub-command - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL sendDGSampleWaterCommand( SAMPLE_WATER_CMD_T cmd ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; + * @param cmd sample water sub-command + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendDGSampleWaterCommand( SAMPLE_WATER_CMD_T cmd ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; msg.hdr.payloadLen = sizeof( U32 ); - memcpy( msg.payload, &cmd, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); - - return result; + memcpy( msg.payload, &cmd, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_DG, ACK_REQUIRED ); + + return result; } - + /*********************************************************************//** * @brief * The handleDGCmdResp function handles a DG command response message. @@ -1793,43 +1796,43 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastAlarmStatus function constructs an alarm status msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm status msg constructed and queued. - * @param almStatus alarm status record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) -{ - BOOL result; - ALARM_COMP_STATUS_PAYLOAD_T payload; - - payload.alarmState = (U32)almStatus.alarmsState; - payload.alarmTop = (U32)almStatus.alarmTop; - payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; +/*********************************************************************//** + * @brief + * The broadcastAlarmStatus function constructs an alarm status msg to + * be broadcast and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: alarm status msg constructed and queued. + * @param almStatus alarm status record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) +{ + BOOL result; + ALARM_COMP_STATUS_PAYLOAD_T payload; + + payload.alarmState = (U32)almStatus.alarmsState; + payload.alarmTop = (U32)almStatus.alarmTop; + payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; payload.escalatesIn = almStatus.alarmsEscalatesIn; - - payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_SYSTEM_FAULT) : 0 ); - payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_STOP) : 0 ); - payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_CLEAR) : 0 ); - payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RESUME) : 0 ); - payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RINSEBACK) : 0 ); - payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_END_TREATMENT) : 0 ); - payload.alarmsFlags |= ( almStatus.ok ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_OK_BUTTON_ONLY) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_TO_ESCALATE) : 0 ); + + payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_SYSTEM_FAULT) : 0 ); + payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_STOP) : 0 ); + payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_CLEAR) : 0 ); + payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RESUME) : 0 ); + payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_RINSEBACK) : 0 ); + payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_END_TREATMENT) : 0 ); + payload.alarmsFlags |= ( almStatus.ok ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_OK_BUTTON_ONLY) : 0 ); + payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_TO_ESCALATE) : 0 ); payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_ALARMS_SILENCED) : 0 ); payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 0 ); payload.alarmsFlags |= ( almStatus.noBloodRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_BLOOD_RECIRC) : 0 ); payload.alarmsFlags |= ( almStatus.noDialRecirc ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_DIALYSATE_RECIRC) : 0 ); payload.alarmsFlags |= ( almStatus.noMinimize ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_MINIMIZE) : 0 ); - payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); + payload.alarmsFlags |= ( almStatus.topAlarmConditionDetected ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_TOP_CONDITION) : 0 ); result = broadcastData( MSG_ID_ALARM_STATUS, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); - - return result; + + return result; } /*********************************************************************//** @@ -1997,59 +2000,59 @@ } -#ifdef EMC_TEST_BUILD -BOOL broadcastCANErrorCount( U32 count ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &count, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} -#endif - -// *********************************************************************** -// **************** Message Handling Helper Functions ******************** -// *********************************************************************** - -/*********************************************************************//** - * @brief - * The handleDGCheckIn function handles a check-in from the DG. - * @details Inputs: none - * @details Outputs: check in the DG with the SystemComm module. - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGCheckIn( MESSAGE_T *message ) -{ - checkInFromDG(); -} - -/*********************************************************************//** - * @brief - * The handleUICheckIn function handles a check-in from the UI. - * @details Inputs: none - * @details Outputs: check in the UI with the SystemComm module. - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleUICheckIn( MESSAGE_T *message ) -{ - checkInFromUI(); -} +#ifdef EMC_TEST_BUILD +BOOL broadcastCANErrorCount( U32 count ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_CAN_ERROR_COUNT; + msg.hdr.payloadLen = sizeof( U32 ); + + memcpy( payloadPtr, &count, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); + + return result; +} +#endif + +// *********************************************************************** +// **************** Message Handling Helper Functions ******************** +// *********************************************************************** + /*********************************************************************//** * @brief + * The handleDGCheckIn function handles a check-in from the DG. + * @details Inputs: none + * @details Outputs: check in the DG with the SystemComm module. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGCheckIn( MESSAGE_T *message ) +{ + checkInFromDG(); +} + +/*********************************************************************//** + * @brief + * The handleUICheckIn function handles a check-in from the UI. + * @details Inputs: none + * @details Outputs: check in the UI with the SystemComm module. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUICheckIn( MESSAGE_T *message ) +{ + checkInFromUI(); +} + +/*********************************************************************//** + * @brief * The handleAlarmTriggered function handles a triggered alarm event message. * @details Inputs: none * @details Outputs: alarm triggered. @@ -2268,68 +2271,68 @@ } } -/*********************************************************************//** - * @brief - * The handleOffButtonConfirmMsgFromUI function handles a response to an - * off button message to the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) -{ - OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T payload; - - if ( message->hdr.payloadLen == sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ) - { - memcpy( &payload, message->payload, sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ); - userConfirmOffButton( payload.confirmed ); - } -} - -/*********************************************************************//** - * @brief - * The handleLoadCellReadingsFromDG function handles a load cell readings - * broadcast message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleLoadCellReadingsFromDG( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) - { - LOAD_CELL_READINGS_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); - setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); +/*********************************************************************//** + * @brief + * The handleOffButtonConfirmMsgFromUI function handles a response to an + * off button message to the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleOffButtonConfirmMsgFromUI( MESSAGE_T *message ) +{ + OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T payload; + + if ( message->hdr.payloadLen == sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ) + { + memcpy( &payload, message->payload, sizeof(OFF_BUTTON_MESSAGE_FROM_UI_PAYLOAD_T) ); + userConfirmOffButton( payload.confirmed ); } -} - -/*********************************************************************//** - * @brief - * The handleDGTemperatureData function handles a temperature readings - * broadcast message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGTemperatureData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof( TEMPERATURE_SENSORS_DATA_T ) ) - { +} + +/*********************************************************************//** + * @brief + * The handleLoadCellReadingsFromDG function handles a load cell readings + * broadcast message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleLoadCellReadingsFromDG( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ) + { + LOAD_CELL_READINGS_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(LOAD_CELL_READINGS_PAYLOAD_T) ); + setNewLoadCellReadings( payload.res1PrimaryLoadCell, payload.res1BackupLoadCell, payload.res2PrimaryLoadCell, payload.res2BackupLoadCell ); + } +} + +/*********************************************************************//** + * @brief + * The handleDGTemperatureData function handles a temperature readings + * broadcast message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGTemperatureData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( TEMPERATURE_SENSORS_DATA_T ) ) + { TEMPERATURE_SENSORS_DATA_T payload; - memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); - } - // TODO - what to do if invalid payload length? - // TODO - how to know if DG stops sending these? -} - + memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + } + // TODO - what to do if invalid payload length? + // TODO - how to know if DG stops sending these? +} + /*********************************************************************//** * @brief * The handleDialysateFlowData function handles dialysate flow data broadcast @@ -2348,59 +2351,59 @@ memcpy( &payload, message->payload, sizeof( DIALYSATE_FLOW_METER_DATA_T ) ); setDialysateFlowData( payload.measuredDialysateFlowRate ); } -} - +} + /*********************************************************************//** * @brief - * The handleDGReservoirData function handles a reservoir data broadcast - * message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDGReservoirData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ) - { - DG_RESERVOIRS_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ); - setDGReservoirsData( (DG_RESERVOIR_ID_T)payload.resID, payload.setFillToVolumeMl, payload.setDrainToVolumeMl ); - } -} - -/*********************************************************************//** - * @brief - * The handleUFPauseResumeRequest function handles a ultrafiltration pause - * or resume request message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleUFPauseResumeRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 cmd; - - memcpy( &cmd, message->payload, sizeof(U32) ); - if ( UF_CMD_PAUSE == cmd ) - { - result = pauseUF(); - } - else if ( UF_CMD_RESUME == cmd ) - { - result = resumeUF(); - } + * The handleDGReservoirData function handles a reservoir data broadcast + * message from the DG. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleDGReservoirData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ) + { + DG_RESERVOIRS_DATA_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof( DG_RESERVOIRS_DATA_PAYLOAD_T ) ); + setDGReservoirsData( (DG_RESERVOIR_ID_T)payload.resID, payload.setFillToVolumeMl, payload.setDrainToVolumeMl ); + } +} + +/*********************************************************************//** + * @brief + * The handleUFPauseResumeRequest function handles a ultrafiltration pause + * or resume request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUFPauseResumeRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 cmd; + + memcpy( &cmd, message->payload, sizeof(U32) ); + if ( UF_CMD_PAUSE == cmd ) + { + result = pauseUF(); + } + else if ( UF_CMD_RESUME == cmd ) + { + result = resumeUF(); + } } - - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); -} - + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + /*********************************************************************//** * @brief * The sendUFPauseResumeResponse function constructs a UF pause/resume @@ -2560,11 +2563,11 @@ // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; + msg.hdr.payloadLen = sizeof( BOOL ) + ( sizeof( U32 ) * byteLength ); memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, rejectReasons, byteLength ); + memcpy( payloadPtr, rejectReasons, sizeof( U32 ) * byteLength ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -2634,112 +2637,112 @@ -/*********************************************************************//** - * @brief - * The handleChangeUFSettingsRequest function handles a ultrafiltration - * change settings request message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeUFSettingsRequest( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(F32) ) - { - F32 uFVolume; - - memcpy( &uFVolume, message->payload, sizeof(F32) ); - - verifyUFSettingsChange( uFVolume ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} - -/*********************************************************************//** - * @brief - * The handleChangeUFSettingsConfirmation function handles a ultrafiltration - * change setting confirmation message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeUFSettingsConfirmation( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ) - { - UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ); - - verifyUFSettingsConfirmation( payload.volume_mL, payload.adjustType ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} - -/*********************************************************************//** - * @brief - * The handleChangeTreatmentDurationRequest function handles a treatment - * duration setting change message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeTreatmentDurationRequest( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 timeInMin; - - memcpy( &timeInMin, message->payload, sizeof(U32) ); - - verifyTreatmentDurationSettingChange( timeInMin ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } -} +/*********************************************************************//** + * @brief + * The handleChangeUFSettingsRequest function handles a ultrafiltration + * change settings request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeUFSettingsRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(F32) ) + { + F32 uFVolume; -/*********************************************************************//** - * @brief - * The handleChangeBloodDialysateRateChangeRequest function handles a blood - * and dialysate rate settings change message from the UI. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) -{ - U32 expPayloadSize = sizeof(U32) + sizeof(U32); - - if ( expPayloadSize == message->hdr.payloadLen ) - { - U32 bloodRate; - U32 dialRate; - - memcpy( &bloodRate, &message->payload[0], sizeof(U32) ); - memcpy( &dialRate, &message->payload[sizeof(U32)], sizeof(U32) ); - - verifyBloodAndDialysateRateSettingsChange( bloodRate, dialRate ); - } - else - { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); - } + memcpy( &uFVolume, message->payload, sizeof(F32) ); + + verifyUFSettingsChange( uFVolume ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } } /*********************************************************************//** * @brief + * The handleChangeUFSettingsConfirmation function handles a ultrafiltration + * change setting confirmation message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeUFSettingsConfirmation( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ) + { + UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T payload; + + memcpy( &payload, message->payload, sizeof(UF_SETTINGS_CHANGE_CONFIRMATION_PAYLOAD_T) ); + + verifyUFSettingsConfirmation( payload.volume_mL, payload.adjustType ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChangeTreatmentDurationRequest function handles a treatment + * duration setting change message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeTreatmentDurationRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(U32) ) + { + U32 timeInMin; + + memcpy( &timeInMin, message->payload, sizeof(U32) ); + + verifyTreatmentDurationSettingChange( timeInMin ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleChangeBloodDialysateRateChangeRequest function handles a blood + * and dialysate rate settings change message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleChangeBloodDialysateRateChangeRequest( MESSAGE_T *message ) +{ + U32 expPayloadSize = sizeof(U32) + sizeof(U32); + + if ( expPayloadSize == message->hdr.payloadLen ) + { + U32 bloodRate; + U32 dialRate; + + memcpy( &bloodRate, &message->payload[0], sizeof(U32) ); + memcpy( &dialRate, &message->payload[sizeof(U32)], sizeof(U32) ); + + verifyBloodAndDialysateRateSettingsChange( bloodRate, dialRate ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief * The handleChangePressureLimitsRequest function handles a pressure limits * change message from the UI. * @details Inputs: none @@ -2990,7 +2993,7 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); return result; -} +} /*********************************************************************//** * @brief @@ -3048,42 +3051,45 @@ return result; } - -/*********************************************************************//** - * @brief - * The handleFWVersionRequest function handles a request for HD f/w version. - * @details Inputs: none - * @details Outputs: message handled, response constructed and queued for transmit. - * @param message a pointer to the message to handle. - * @return none - *************************************************************************/ -void handleFWVersionRequest( MESSAGE_T *message ) -{ + +/*********************************************************************//** + * @brief + * The handleFWVersionRequest function handles a request for HD f/w version. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message a pointer to the message to handle. + * @return none + *************************************************************************/ +void handleFWVersionRequest( MESSAGE_T *message ) +{ MESSAGE_T msg; - HD_VERSIONS_T payload; + HD_VERSIONS_T payload; U08 *payloadPtr = msg.payload; - // Get UI version data from this request msg and have it recorded - handleUIVersionResponse( message ); + if ( message->hdr.payloadLen == sizeof( U08 ) + sizeof( U08 ) + sizeof( U08 ) + sizeof( U16 ) + sizeof( U32 ) ) + { + // Get UI version data from this request msg and have it recorded + handleUIVersionResponse( message ); - // Populate payload for response - payload.major = (U08)HD_VERSION_MAJOR; - payload.minor = (U08)HD_VERSION_MINOR; - payload.micro = (U08)HD_VERSION_MICRO; - payload.build = (U16)HD_VERSION_BUILD; - payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; - getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VERSION; - msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); + // Populate payload for response + payload.major = (U08)HD_VERSION_MAJOR; + payload.minor = (U08)HD_VERSION_MINOR; + payload.micro = (U08)HD_VERSION_MICRO; + payload.build = (U16)HD_VERSION_BUILD; + payload.compatibilityRev = (U32)SW_COMPATIBILITY_REV; + getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - // Fill message payload - memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_VERSION; + msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); + + // Fill message payload + memcpy( payloadPtr, &payload, sizeof( HD_VERSIONS_T ) ); + } + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); } /*********************************************************************//** @@ -3135,7 +3141,7 @@ msg.hdr.payloadLen = MAX_TOP_LEVEL_SN_CHARS + 1; // Fill message payload - memcpy( payloadPtr, &system.topLevelSN, MAX_TOP_LEVEL_SN_CHARS ); + memcpy( payloadPtr, &system.topLevelSN, sizeof( U08 ) * MAX_TOP_LEVEL_SN_CHARS ); payloadPtr += MAX_TOP_LEVEL_SN_CHARS; *payloadPtr = 0; @@ -3182,15 +3188,18 @@ U08 *payloadPtr = msg.payload; - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); + if ( message->hdr.payloadLen == sizeof( U32 ) + sizeof( U32 ) ) + { + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SERVICE_SCHEDULE_DATA; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - // Fill message payload - memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + // Fill message payload + memcpy( payloadPtr, &service.lastServiceEpochDate, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &service.serviceIntervalSeconds, sizeof( U32 ) ); + } // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -3209,7 +3218,7 @@ void handleHDUsageInfoRequest( MESSAGE_T *message ) { MESSAGE_T msg; - U32 payload = getTreatmentTime(); + U32 payload = 0; // TODO update this one implemented U08 *payloadPtr = msg.payload; // Create a message record @@ -3222,90 +3231,90 @@ // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); -} - - -/************************************************************************* - * TEST SUPPORT FUNCTIONS - *************************************************************************/ - - -/*********************************************************************//** - * @brief - * The isTestingActivated function determines whether a tester has successfully - * logged in to activate testing functionality. - * @details Inputs: testerLoggedIn - * @details Outputs: none - * @return TRUE if a tester has logged in to activate testing, FALSE if not - *************************************************************************/ -BOOL isTestingActivated( void ) -{ - return testerLoggedIn; -} - -/*********************************************************************//** - * @brief - * The sendTestAckResponseMsg function constructs a simple response - * message for a handled test message and queues it for transmit on the - * appropriate UART channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. - * @param msgID ID of handled message that we are responding to - * @param ack TRUE if test message was handled successfully, FALSE if not - * @return TRUE if response message successfully queued for transmit, FALSE if not - *************************************************************************/ -static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The handleTesterLogInRequest function handles a request to login as a - * tester. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTesterLogInRequest( MESSAGE_T *message ) -{ - // Verify pass code - // TODO - placeholder - how do we want to authenticate tester? - if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) - { - testerLoggedIn = TRUE; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The isTestingActivated function determines whether a tester has successfully + * logged in to activate testing functionality. + * @details Inputs: testerLoggedIn + * @details Outputs: none + * @return TRUE if a tester has logged in to activate testing, FALSE if not + *************************************************************************/ +BOOL isTestingActivated( void ) +{ + return testerLoggedIn; +} + +/*********************************************************************//** + * @brief + * The sendTestAckResponseMsg function constructs a simple response + * message for a handled test message and queues it for transmit on the + * appropriate UART channel. + * @details Inputs: none + * @details Outputs: response message constructed and queued for transmit. + * @param msgID ID of handled message that we are responding to + * @param ack TRUE if test message was handled successfully, FALSE if not + * @return TRUE if response message successfully queued for transmit, FALSE if not + *************************************************************************/ +static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) +{ + BOOL result; + MESSAGE_T msg; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = msgID; + msg.hdr.payloadLen = sizeof( U08 ); + msg.payload[ 0 ] = (U08)ack; + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** + * @brief + * The handleTesterLogInRequest function handles a request to login as a + * tester. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTesterLogInRequest( MESSAGE_T *message ) +{ + // Verify pass code + // TODO - placeholder - how do we want to authenticate tester? + if ( ( 3 == message->hdr.payloadLen ) && ( 0x31 == message->payload[ 0 ] ) && ( 0x32 == message->payload[ 1 ] ) && ( 0x33 == message->payload[ 2 ] ) ) + { + testerLoggedIn = TRUE; checkInFromUI(); // Allow tasks to begin normal processing when tester has logged in - } - else - { - testerLoggedIn = FALSE; - } - // Respond to would be tester - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); -} - -/*********************************************************************//** - * @brief - * The handleTestOffButtonStateOverrideRequest function handles a request to - * override the state of the off button. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + } + else + { + testerLoggedIn = FALSE; + } + // Respond to would be tester + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); +} + +/*********************************************************************//** + * @brief + * The handleTestOffButtonStateOverrideRequest function handles a request to + * override the state of the off button. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestOffButtonStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3329,16 +3338,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestStopButtonStateOverrideRequest function handles a request to - * override the stop button state. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestStopButtonStateOverrideRequest function handles a request to + * override the stop button state. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestStopButtonStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3361,16 +3370,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmLampPatternOverrideRequest function handles a request to - * override the alarm lamp pattern. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmLampPatternOverrideRequest function handles a request to + * override the alarm lamp pattern. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmLampPatternOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3393,16 +3402,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestWatchdogCheckInStateOverrideRequest function handles a - * request to override the check-in status of a given task. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestWatchdogCheckInStateOverrideRequest function handles a + * request to override the check-in status of a given task. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestWatchdogCheckInStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -3425,16 +3434,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmStateOverrideRequest function handles a request to - * override the active status of a given alarm. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmStateOverrideRequest function handles a request to + * override the active status of a given alarm. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmStateOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -3457,16 +3466,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestAlarmTimeOverrideRequest function handles a request to - * override the time since activation of a given alarm. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestAlarmTimeOverrideRequest function handles a request to + * override the time since activation of a given alarm. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestAlarmTimeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -3489,16 +3498,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowSetPointOverrideRequest function handles a request to - * override the set point for the blood flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowSetPointOverrideRequest function handles a request to + * override the set point for the blood flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodFlowSetPointOverrideRequest( MESSAGE_T *message ) { OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; @@ -3514,16 +3523,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to - * override the measured blood flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowMeasuredOverrideRequest function handles a request to + * override the measured blood flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodFlowMeasuredOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3611,15 +3620,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump rotor speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump rotor speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3642,16 +3651,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3674,16 +3683,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to - * override the measured blood pump motor controller speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredSpeedOverrideRequest function handles a request to + * override the measured blood pump motor controller speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3706,16 +3715,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to - * override the measured blood pump motor controller current (mA). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpMCMeasuredCurrentOverrideRequest function handles a request to + * override the measured blood pump motor controller current (mA). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3738,16 +3747,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for blood flow data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodFlowBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for blood flow data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3770,16 +3779,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInFlowSetPointOverrideRequest function handles a request to - * override the set point for the dialysate inlet flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowSetPointOverrideRequest function handles a request to + * override the set point for the dialysate inlet flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowSetPointOverrideRequest( MESSAGE_T *message ) { OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; @@ -3795,7 +3804,7 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - + /*********************************************************************//** * @brief * The handleTestDialOutFlowSetPointOverrideRequest function handles a request to @@ -3821,15 +3830,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to - * override the measured dialysate inlet flow rate (mL/min). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestDialInFlowMeasuredOverrideRequest function handles a request to + * override the measured dialysate inlet flow rate (mL/min). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowMeasuredOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3853,15 +3862,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump rotor speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump rotor speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpRotorMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3884,16 +3893,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3916,16 +3925,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to - * override the measured dialysate inlet pump motor controller speed (RPM). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredSpeedOverrideRequest function handles a request to + * override the measured dialysate inlet pump motor controller speed (RPM). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3948,16 +3957,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to - * override the measured dialysate inlet pump motor controller current (mA). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInPumpMCMeasuredCurrentOverrideRequest function handles a request to + * override the measured dialysate inlet pump motor controller current (mA). + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -3980,16 +3989,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for dialysate inlet flow data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialInFlowBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for dialysate inlet flow data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialInFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4012,16 +4021,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestArterialPressureOverrideRequest function handles a request to - * override the arterial pressure. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestArterialPressureOverrideRequest function handles a request to + * override the arterial pressure. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestArterialPressureOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4044,16 +4053,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestVenousPressureOverrideRequest function handles a request to - * override the venous pressure. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestVenousPressureOverrideRequest function handles a request to + * override the venous pressure. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestVenousPressureOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4076,16 +4085,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to - * override the blood pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestBloodPumpOcclusionOverrideRequest function handles a request to + * override the blood pump occlusion sensor. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestBloodPumpOcclusionOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4108,16 +4117,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to - * override the broadcast interval for pressure/occlusion data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestPresOcclBroadcastIntervalOverrideRequest function handles a request to + * override the broadcast interval for pressure/occlusion data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestPresOcclBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4140,46 +4149,46 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleSetRTCTimestamp function handles a request to write time and - * date to RTC - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleSetRTCTimestamp( MESSAGE_T *message ) -{ + +/*********************************************************************//** + * @brief + * The handleSetRTCTimestamp function handles a request to write time and + * date to RTC + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleSetRTCTimestamp( MESSAGE_T *message ) +{ BOOL result = FALSE; - + if ( message->hdr.payloadLen == 9 ) // TODO - add payload structure to RTC.h and use a structure to import payload. { - U08 seconds = message->payload[0]; - U08 minutes = message->payload[1]; - U08 hours = message->payload[2]; - U08 days = message->payload[3]; - U08 months = message->payload[4]; - U32 years; - - memcpy(&years, &message->payload[5], sizeof(U32)); + U08 seconds = message->payload[0]; + U08 minutes = message->payload[1]; + U08 hours = message->payload[2]; + U08 days = message->payload[3]; + U08 months = message->payload[4]; + U32 years; + + memcpy(&years, &message->payload[5], sizeof(U32)); result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles - * a request to override the broadcast interval for dialysate outlet pump data. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestDialOutFlowBroadcastIntervalOverrideRequest function handles + * a request to override the broadcast interval for dialysate outlet pump data. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutFlowBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4202,17 +4211,17 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a - * request to override the ultrafiltration reference volume for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutUFReferenceVolumeOverrideRequest function handles a + * request to override the ultrafiltration reference volume for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutUFReferenceVolumeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4235,17 +4244,17 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a - * request to override the ultrafiltration measured volume for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutUFMeasuredVolumeOverrideRequest function handles a + * request to override the ultrafiltration measured volume for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutUFMeasuredVolumeOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4268,17 +4277,17 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a - * request to override the measured motor controller speed for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMCMeasuredSpeedOverrideRequest function handles a + * request to override the measured motor controller speed for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMCMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4301,17 +4310,17 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a - * request to override the measured motor controller current for the dialysate - * outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMCMeasuredCurrentOverrideRequest function handles a + * request to override the measured motor controller current for the dialysate + * outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMCMeasuredCurrentOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4334,16 +4343,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a - * request to override the measured speed for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMeasuredSpeedOverrideRequest function handles a + * request to override the measured speed for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMeasuredSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4366,16 +4375,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a - * request to override the measured rotor speed for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest function handles a + * request to override the measured rotor speed for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutPumpMeasuredRotorSpeedOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -4398,16 +4407,16 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - -/*********************************************************************//** - * @brief - * The handleTestDialOutLoadCellWeightOverrideRequest function handles a - * request to override the measured load cell weight for the dialysate outlet pump. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ + +/*********************************************************************//** + * @brief + * The handleTestDialOutLoadCellWeightOverrideRequest function handles a + * request to override the measured load cell weight for the dialysate outlet pump. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestDialOutLoadCellWeightOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; @@ -4430,7 +4439,7 @@ // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - + /*********************************************************************//** * @brief * The handleTestTreatmentTimeRemainingOverrideRequest function handles a treatment @@ -4456,15 +4465,15 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestHDSafetyShutdownOverrideRequest function handles a - * request to override the safety shutdown signal. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ +/*********************************************************************//** + * @brief + * The handleTestHDSafetyShutdownOverrideRequest function handles a + * request to override the safety shutdown signal. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ void handleTestHDSafetyShutdownOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; @@ -5846,6 +5855,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; +#ifndef _RELEASE_ // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { @@ -5859,6 +5869,7 @@ result = testResetValvesCurrentOverride( payload.index ); } } +#endif // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); @@ -6808,39 +6819,6 @@ /*********************************************************************//** * @brief - * The handleTestFansRPMAlarmStartTimeOverrideRequest function handles a - * request to override the fan RPM alarm start time. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestFansRPMAlarmStartTimeOffsetOverrideRequest( MESSAGE_T *message ) -{ - TEST_OVERRIDE_PAYLOAD_T payload; - BOOL result = FALSE; - - // verify payload length - if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) - { - memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); - - if ( FALSE == payload.reset ) - { - result = testSetFanRPMAlarmStartTimeOffsetOverride( payload.state.u32 ); - } - else - { - result = testResetFanRPMAlarmStartTimeOffsetOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleSetFansDutyCycleOverrideRequest function handles a * request to override the fans duty cycle. * @details Inputs: none @@ -6918,6 +6896,33 @@ /*********************************************************************//** * @brief + * The handleTestFansRPMAlarmStartTimeOffsetRequest function handles a + * request to set the fans RPM alarm start time offset. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestFansRPMAlarmStartTimeOffsetRequest( MESSAGE_T *message ) +{ + U32 rpmTimeOffset; + + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(U32) == message->hdr.payloadLen ) + { + memcpy( &rpmTimeOffset, message->payload, sizeof(U32) ); + + result = testSetFanRPMAlarmStartTime( rpmTimeOffset ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The sendHDSWConfigRecord function sends out the HD software configuration record. * @details Inputs: none * @details Outputs: HD software configuration record msg constructed and queued @@ -6996,7 +7001,6 @@ U32 currentMessage; U32 totalMessages; U32 payloadLength; - BOOL status = FALSE; U08* payloadPtr = message->payload; @@ -7018,4 +7022,258 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); } +/*********************************************************************//** +* @brief +* The handleUIServiceModeRequest function handles a request to enter service +* mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleUIServiceModeRequest( MESSAGE_T *message ) +{ + BOOL status = FALSE; + HD_OP_MODE_T currentMode = getCurrentOperationMode(); + REQUEST_REJECT_REASON_CODE_T reject; + + if ( 0 == message->hdr.payloadLen ) + { + if ( ( MODE_STAN == currentMode ) || ( MODE_FAUL == currentMode ) ) + { + status = TRUE; + requestNewOperationMode( MODE_SERV ); + reject = REQUEST_REJECT_REASON_NONE; + } + else + { + reject = REQUEST_REJECT_REASON_TREATMENT_IN_PROGRESS; + } + } + else + { + reject = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); + sendUIServiceModeResponse( status, (U32)reject ); +} + +/*********************************************************************//** + * @brief + * The sendUIServiceModeResponse function sends out the HD response to a + * UI request to go to service mode. + * @details Inputs: none + * @details Outputs: Service mode request response msg constructed and queued + * @param accepted TRUE if request was accepted, FALSE if not + * @param rejCode Reject reason code explaining why request was rejected + * @return none + *************************************************************************/ +void sendUIServiceModeResponse( BOOL accepted, U32 rejCode ) +{ + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_RESPONSE_SERVICE_MODE_REQUEST; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &rejCode, sizeof( U32 ) ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); +} + +/*********************************************************************//** +* @brief +* The handleGetHDUsageInfoRecord function handles a request to get the HD +* usage information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleGetHDUsageInfoRecord( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + // Tester must be logged in + if ( TRUE == isTestingActivated() ) + { + result = sendRecordToDialin( NVDATAMGMT_USAGE_INFO_RECORD ); + } + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetHDUsageInfoRecord function handles a request to set the HD +* information record. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetHDUsageInfoRecord( MESSAGE_T *message ) +{ + U32 currentMessage; + U32 totalMessages; + U32 payloadLength; + + BOOL status = FALSE; + U08* payloadPtr = message->payload; + + if ( message->hdr.payloadLen >= ( sizeof(currentMessage) + sizeof(totalMessages) + sizeof(payloadLength) ) ) + { + memcpy(¤tMessage, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&totalMessages, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + memcpy(&payloadLength, payloadPtr, sizeof(U32)); + payloadPtr += sizeof(U32); + + status = receiveRecordFromDialin( NVDATAMGMT_USAGE_INFO_RECORD, currentMessage, totalMessages, payloadLength, payloadPtr ); + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, status ); +} + +/*********************************************************************//** + * @brief + * The sendDGUsageInfoRecord function sends out the DG usage information record. + * @details Inputs: none + * @details Outputs: DG usage information record msg constructed and queued + * @param msgCurrNum: current payload number + * @param msgTotalNum: total number of payloads + * @param length: buffer length to be written + * @param usageInfoAddress: start address of the susage information record + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSendHDUsageInfoRecord( U32 payloadCurrNum, U32 payloadTotalNum, U32 length, U08* usageInfoAddress ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_USAGE_INFO_RECORD; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + length; + + memcpy( payloadPtr, &payloadCurrNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &payloadTotalNum, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, &length, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + + memcpy( payloadPtr, usageInfoAddress, length ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + +/*********************************************************************//** +* @brief +* The handleSetBloodLeak2EmbeddedMode function handles a request to set the HD +* blood leak to embedded mode. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetBloodLeak2EmbeddedMode( MESSAGE_T* message ) +{ + BOOL result = FALSE; + + // verify payload length + if ( 0 == message->hdr.payloadLen ) + { + result = testSetBloodLeak2EmbeddedMode(); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** +* @brief +* The handleSetBloodLeakEmbeddedModeCommand function handles a request to set +* the HD blood leak to embedded mode command. +* @details Inputs: none +* @details Outputs: message handled +* @param message a pointer to the message to handle +* @return none +*************************************************************************/ +void handleSetBloodLeakEmbeddedModeCommand( MESSAGE_T* message ) +{ + U08 command; + U16 commandPayload; + BOOL result = FALSE; + U08* payloadPtr = message->payload; + + // verify payload length + if ( sizeof( U08 ) + sizeof( U16 ) == message->hdr.payloadLen ) + { + memcpy( &command, payloadPtr, sizeof( U08 ) ); + + payloadPtr += sizeof( U08 ); + + memcpy( &commandPayload, payloadPtr, sizeof( U16 ) ); + + result = testSetBloodLeakEmbeddedModeCommand( command, commandPayload ); + } + + // respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleSendBloodLeakEmbeddedModeCommandResponse function sends out + * the blood leak embedded mode command response. + * @details Inputs: none + * @details Outputs: blood leak embedded mode command response msg constructed and queued + * @param responseLen: the length of the buffer + * @param response: pointer to the response buffer + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL handleSendBloodLeakEmbeddedModeCommandResponse( U32 responseLen, U08* response ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SEND_BLOOD_LEAK_EMB_MODE_RESPONSE; + msg.hdr.payloadLen = sizeof( U32 ) + responseLen; + + memcpy( payloadPtr, &responseLen, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, response, responseLen ); + + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_PC, ACK_NOT_REQUIRED ); + + return result; +} + /**@}*/