Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r31785f24396cebed8e10834f56fc2668783558e6 -r5bfaf341319b9fd763d07ad0a68a986028c37587 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 31785f24396cebed8e10834f56fc2668783558e6) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 5bfaf341319b9fd763d07ad0a68a986028c37587) @@ -49,17 +49,26 @@ // ********** private definitions ********** -#define ACK_REQUIRED TRUE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. -#define ACK_NOT_REQUIRED FALSE ///< Macro for functions that want to know if an outgoing message requires acknowledgement from receiver. - #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif +#endif + +#define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. + +#pragma pack(push,1) +/// Payload record structure for block message transmission request. +typedef struct +{ + 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. -static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted 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 ********** @@ -74,7 +83,7 @@ * 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: none + * @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 @@ -84,69 +93,92 @@ U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = 0; - BOOL error = FALSE; + BOOL error = FALSE; + 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 - - // 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 ) + 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 + if ( TRUE == isTestingActivated() ) + { + U32 i; + + for ( i = 0; i < MAX_MSGS_BLOCKED_FOR_XMIT; i++ ) + { + if ( msg.hdr.msgID == blockedMessagesForXmit.blockedMessages[ i ] ) + { + blocked = TRUE; + break; + } + } + } + // Serialize and queue message for transmission unless this message is blocked + if ( blocked != TRUE ) { - // 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 ) + // 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 ) { - msg.hdr.seqNo *= -1; + // 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 ); + // 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 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; + // 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; + // 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; - } + // 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 DISABLE_ACK_ERRORS - // If ACK required, add to pending ACK list - if ( TRUE == ackReq ) - { - if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + #ifndef DISABLE_ACK_ERRORS + // If ACK required, add to pending ACK list + if ( TRUE == ackReq ) { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + 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 + #endif - 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; } @@ -320,6 +352,41 @@ return result; } + +/*********************************************************************//** + * @brief + * The sendEvent function constructs an HD event message to the UI and + * queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: HD event msg constructed and queued. + * @param event Enumeration of event type that occurred + * @param dat1 First data associated with event + * @param dat2 Second data associated with event + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendEvent( HD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + U32 e = (U32)event; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_EVENT; + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( EVENT_DATA_T ) * 2; + + memcpy( payloadPtr, &e, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &dat1, sizeof( EVENT_DATA_T ) ); + payloadPtr += sizeof( EVENT_DATA_T ); + memcpy( payloadPtr, &dat2, sizeof( EVENT_DATA_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_UI, ACK_NOT_REQUIRED ); + + return result; +} /*********************************************************************//** * @brief @@ -1024,7 +1091,7 @@ * @param newValue parameter change event new data value * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendTreatmentLogEventData( HD_EVENT_ID_T event, F32 oldValue, F32 newValue ) +BOOL sendTreatmentLogEventData( TX_EVENT_ID_T event, F32 oldValue, F32 newValue ) { MESSAGE_T msg; U08 *payloadPtr = msg.payload; @@ -1704,52 +1771,6 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastAccelData function constructs an accelerometer data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: accelerometer data broadcast msg constructed and queued. - * @param x X axis vector magnitude (in g) - * @param y Y axis vector magnitude (in g) - * @param z Z axis vector magnitude (in g) - * @param xm max X axis vector magnitude (in g) - * @param ym max Y axis vector magnitude (in g) - * @param zm max Z axis vector magnitude (in g) - * @param xt X axis tilt (in degrees) - * @param yt Y axis tilt (in degrees) - * @param zt Z axis tilt (in degrees) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAccelData( F32 x, F32 y, F32 z, F32 xm, F32 ym, F32 zm, F32 xt, F32 yt, F32 zt ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - ACCEL_DATA_PAYLOAD_T payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_ACCELEROMETER_DATA; - msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); - payload.x = x; - payload.y = y; - payload.z = z; - payload.xMax = xm; - payload.yMax = ym; - payload.zMax = zm; - payload.xTilt = xt; - payload.yTilt = yt; - payload.zTilt = zt; - - memcpy( payloadPtr, &payload, sizeof( ACCEL_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - /*********************************************************************//** * @brief * The broadcastAlarmStatus function constructs an alarm status msg to @@ -1762,15 +1783,8 @@ BOOL broadcastAlarmStatus( COMP_ALARM_STATUS_T almStatus ) { BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; ALARM_COMP_STATUS_PAYLOAD_T payload; - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_STATUS; - msg.hdr.payloadLen = sizeof( ALARM_COMP_STATUS_PAYLOAD_T ); - payload.alarmState = (U32)almStatus.alarmsState; payload.alarmTop = (U32)almStatus.alarmTop; payload.silenceExpiresIn = almStatus.alarmsSilenceExpiresIn; @@ -1789,925 +1803,14 @@ payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_LAMP_ON) : 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 ); - - memcpy( payloadPtr, &payload, sizeof( ALARM_COMP_STATUS_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_ALARM, ACK_NOT_REQUIRED ); - - return result; -} -/*********************************************************************//** - * @brief - * The broadcastAlarmInfo function constructs an alarm information msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm information msg constructed and queued. - * @param data alarm information record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmInfo( ALARM_INFO_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_ALARM_INFORMATION; - msg.hdr.payloadLen = sizeof( ALARM_INFO_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( ALARM_INFO_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} + result = broadcastData( MSG_ID_ALARM_STATUS, COMM_BUFFER_OUT_CAN_HD_ALARM, (U08*)&payload, sizeof( ALARM_COMP_STATUS_PAYLOAD_T ) ); -/*********************************************************************//** - * @brief - * The broadcastAlarmTriggered function constructs an alarm triggered msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm triggered msg constructed and queued. - * @param alarm ID of alarm triggered - * @param almData1 1st data associated with alarm - * @param almData2 2nd data associated with alarm - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmTriggered( U32 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each - - memcpy( payloadPtr, &alarm, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.dataType, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData1.data, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData2.dataType, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &almData2.data, 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_ALARM, ACK_REQUIRED ); - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastAlarmCleared function constructs an alarm cleared msg to be - * broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm cleared msg constructed and queued. - * @param alarm ID of alarm cleared - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmCleared( U32 alarm ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_CLEARED; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &alarm, 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_ALARM, ACK_REQUIRED ); - - return result; } /*********************************************************************//** * @brief - * The broadcastAlarmConditionCleared function constructs an alarm condition - * cleared msg to be broadcast and queues the msg for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: alarm condition cleared msg constructed and queued. - * @param alarm ID of alarm that has had its condition cleared - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAlarmConditionCleared( U32 alarm ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_ALARM_CONDITION_CLEARED; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &alarm, 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_ALARM, ACK_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastBloodFlowData function constructs a blood flow data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: blood flow data msg constructed and queued. - * @param bloodData blood pump and flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodFlowData( BLOOD_PUMP_STATUS_PAYLOAD_T *bloodData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_BLOOD_FLOW_DATA; - msg.hdr.payloadLen = sizeof( BLOOD_PUMP_STATUS_PAYLOAD_T ); - - memcpy( payloadPtr, bloodData, sizeof( BLOOD_PUMP_STATUS_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastDialInFlowData function constructs a dialysate flow data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: dialysate flow data msg constructed and queued. - * @param dialInData Dialysate inlet pump and flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDialInFlowData( DIALIN_PUMP_STATUS_PAYLOAD_T *dialInData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DIALYSATE_FLOW_DATA; - msg.hdr.payloadLen = sizeof( DIALIN_PUMP_STATUS_PAYLOAD_T ); - - memcpy( payloadPtr, dialInData, sizeof( DIALIN_PUMP_STATUS_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastDialInFlowData function constructs a dialysate outlet flow data - * msg to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: dialysate out flow data msg constructed and queued. - * @param dialOutFlowData Pointer to the dialysate out flow data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDialOutFlowData( DIAL_OUT_FLOW_DATA_T *dialOutFlowData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_DIALYSATE_OUT_FLOW_DATA; - msg.hdr.payloadLen = sizeof( DIAL_OUT_FLOW_DATA_T ); - - memcpy( payloadPtr, dialOutFlowData, sizeof( DIAL_OUT_FLOW_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastSyringePumpData function constructs a syringe pump data - * msg to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: syringe pump data msg constructed and queued. - * @param data syringe pump data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSyringePumpData( SYRINGE_PUMP_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SYRINGE_PUMP_DATA; - msg.hdr.payloadLen = sizeof( SYRINGE_PUMP_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( SYRINGE_PUMP_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastHeparinData function constructs a Heparin data message - * to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: Heparin data msg constructed and queued. - * @param data Heparin data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHeparinData( F32 volume ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_HEPARIN_DATA_BROADCAST; - msg.hdr.payloadLen = sizeof( F32 ); - - memcpy( payloadPtr, &volume, 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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastPresOcclData function constructs a pres/occl data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: pressure/occlusion data msg constructed and queued. - * @param data Latest measured pressures and occlusion values. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPresOcclData( PRESSURE_OCCLUSION_DATA_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_PRESSURE_OCCLUSION_DATA; - msg.hdr.payloadLen = sizeof( PRESSURE_OCCLUSION_DATA_T ); - - memcpy( payloadPtr, &data, sizeof( PRESSURE_OCCLUSION_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastVoltagesData function constructs a monitored voltages data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: monitored voltages data msg constructed and queued. - * @param data Latest monitored voltage values. - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastVoltagesData( VOLTAGES_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VOLTAGES_DATA; - msg.hdr.payloadLen = sizeof( VOLTAGES_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( VOLTAGES_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastRTCEpoch function constructs an epoch msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: RTC time and date in epoch - * @param epoch Current time and date in epoch - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRTCEpoch( U32 epoch ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_RTC_EPOCH; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &epoch, 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; -} - -/*********************************************************************//** - * @brief - * The broadcastTreatmentTime function constructs a treatment time msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment time data msg constructed and queued - * @param secsTotTreatment Total treatment time prescribed (in seconds) - * @param secsElapsed Treatment time elapsed (in seconds) - * @param secsRemaining Treatment time remaining (in seconds) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentTime( U32 secsTotTreatment, U32 secsElapsed, U32 secsRemaining ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - TREATMENT_TIME_DATA_T payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_TIME; - msg.hdr.payloadLen = sizeof( TREATMENT_TIME_DATA_T ); - - payload.treatmentTimePrescribedinSec = secsTotTreatment; - payload.treatmentTimeElapsedinSec = secsElapsed; - payload.treatmentTimeRemaininginSec = secsRemaining; - - memcpy( payloadPtr, &payload, sizeof( TREATMENT_TIME_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastTreatmentState function constructs a treatment state msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment state msg constructed and queued - * @param payload Record with treatment state data - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentState( TREATMENT_STATE_DATA_T payload ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); - - memcpy( payloadPtr, &payload, sizeof( TREATMENT_STATE_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastPostTreatmentState function constructs a post treatment state msg - * to be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: post-treatment state msg constructed and queued - * @param postTreatmentSubMode post-treatment state sub-mode - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPostTreatmentState( U32 postTreatmentSubMode ) -{ - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_POST_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &postTreatmentSubMode, sizeof( U32 ) ); - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - return serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); -} - -/*********************************************************************//** - * @brief - * The broadcastPreTreatmentState function constructs a pre-treatment state msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: pre-treatment state msg constructed and queued - * @param preTreatmentDataPtr pointer to pre-treatment data record to broadcast - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPreTreatmentState( PRE_TREATMENT_STATE_DATA_T *preTreatmentDataPtr ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_PRE_TREATMENT_STATE; - msg.hdr.payloadLen = sizeof( PRE_TREATMENT_STATE_DATA_T ); - - memcpy( payloadPtr, preTreatmentDataPtr, sizeof( PRE_TREATMENT_STATE_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastPowerOffWarning function constructs a power off warning msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: power off warning msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPowerOffWarning( void ) -{ - BOOL result; - MESSAGE_T msg; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_POWER_OFF_WARNING; - msg.hdr.payloadLen = 0; - - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastHDOperationMode function constructs an HD operation mode - * broadcast message and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: HD operation mode msg constructed and queued - * @param mode current HD operation mode - * @param subMode current HD operation sub-mode - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHDOperationMode( U32 mode, U32 subMode ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_OP_MODE; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &mode, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &subMode, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastHDValves function constructs an HD valves msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: HD valves msg constructed and queued - * @param valveData valve data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastHDValves( HD_VALVE_DATA_T *valveData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_VALVES_DATA; - msg.hdr.payloadLen = sizeof( HD_VALVE_DATA_T ); - - memcpy( payloadPtr, valveData, sizeof( HD_VALVE_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastSalineBolusData function constructs a saline bolus data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: saline bolus data msg constructed and queued - * @param data saline bolus data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSalineBolusData( SALINE_BOLUS_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_SALINE_BOLUS_DATA; - msg.hdr.payloadLen = sizeof( SALINE_BOLUS_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( SALINE_BOLUS_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastTreatmentStopData function constructs a treatment stop data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment stop data msg constructed and queued - * @param timeout treatment stop timeout (in sec) - * @param countdown treatment stop timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTreatmentStopData( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TREATMENT_STOP_TIMER_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastRinsebackData function constructs a rinseback data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: rinseback data msg constructed and queued - * @param data rinseback data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRinsebackData( RINSEBACK_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_RINSEBACK_PROGRESS; - msg.hdr.payloadLen = sizeof( RINSEBACK_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( RINSEBACK_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastRecircData function constructs a treatment re-circ data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: treatment re-circ data msg constructed and queued - * @param timeout re-circulation timeout (in sec) - * @param countdown re-circulation timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastRecircData( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_RECIRC_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastBloodPrimeData function constructs a blood prime data msg to - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: blood prime data msg constructed and queued - * @param data blood prime data record - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodPrimeData( BLOOD_PRIME_DATA_PAYLOAD_T data ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BLOOD_PRIME_PROGRESS; - msg.hdr.payloadLen = sizeof( BLOOD_PRIME_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, &data, sizeof( BLOOD_PRIME_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/***********************************************************************//** - * @brief - * The broadcastAirTrapData function constructs an HD air trap data msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: air trap data msg constructed and queued - * @param lowerLevel air trap lower level data - * @param upperLevel air trap upper level data - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastAirTrapData( AIR_TRAP_LEVELS_T lowerLevel, AIR_TRAP_LEVELS_T upperLevel ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 lower = (U32)lowerLevel; - U32 upper = (U32)upperLevel; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &lower, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &upper, 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; -} - -/*********************************************************************//** - * @brief - * The broadcastNoCartSelfTestTime function sends out the no cartridge self-test - * progress data. - * @details Inputs: none - * @details Outputs: no cartridge self-test time data msg constructed and queued - * @param timeout no cartridge self-test timeout (in sec) - * @param countdown no cartridge self-test timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastNoCartSelfTestTime( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_NO_CART_SELF_TEST_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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; -} - -/*********************************************************************//** - * @brief - * The broadcastDrySelfTestTime function sends out the dry self-test progress data. - * @details Inputs: none - * @details Outputs: dry self-test time data msg constructed and queued - * @param timeout dry self-test timeout (in sec) - * @param countdown dry self-test timeout count down (in sec) - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDrySelfTestTime( U32 timeout, U32 countdown ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_DRY_SELF_TEST_PROGRESS; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &timeout, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &countdown, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastFluidLeakState function constructs an HD fluid leak state msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: fluid leak state msg constructed and queued - * @param state fluid leak state - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFluidLeakState( FLUID_LEAK_STATES_T state ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 leakState = (U32)state; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_FLUID_LEAK_STATE; - msg.hdr.payloadLen = sizeof( U32 ); - - memcpy( payloadPtr, &leakState, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastBloodLeakData function constructs an HD blood leak data msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: blood leak data msg constructed and queued - * @param status blood leak status - * @param state blood leak state - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBloodLeakData( BLOOD_LEAK_STATUS_T status, U32 state ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 leakStatus = (U32)status; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BLOOD_LEAK_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &leakStatus, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &state, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastBubblesData function constructs an HD air bubble data msg to \n - * be broadcasted and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: air bubbles data msg constructed and queued - * @param status air bubbles status - * @param state air bubbles states - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastBubblesData( U32 statusADA, U32 stateADA, U32 statusADV, U32 stateADV ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_BUBBLES_DATA; - msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ) + sizeof( U32 ); - - memcpy( payloadPtr, &statusADA, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &stateADA, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &statusADV, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &stateADV, 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; -} - -/***********************************************************************//** - * @brief - * The broadcastPrimeData function constructs a prime data msg to \n - * be broadcast and queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: prime data msg constructed and queued - * @param primeDataPtr prime data record pointer - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastPrimeData( PRIMING_DATA_PAYLOAD_T *primeDataPtr ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_PRIMING_STATUS_DATA; - msg.hdr.payloadLen = sizeof( PRIMING_DATA_PAYLOAD_T ); - - memcpy( payloadPtr, primeDataPtr, sizeof( PRIMING_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief * The sendHDCalibrationRecord function sends out the HD calibration * record. * @details Inputs: none @@ -2824,114 +1927,6 @@ return result; } -/*********************************************************************//** - * @brief - * The broadcastDisinfectsData function sends out the disinfects data. - * @details Inputs: none - * @details Outputs: disinfects data msg constructed and queued - * @param disinfectsData which is disinfects msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastDisinfectsData( DISINFECTS_DATA_T *disinfectsData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_DISINFECT_STANDBY_DATA; - msg.hdr.payloadLen = sizeof( DISINFECTS_DATA_T ); - - memcpy( payloadPtr, disinfectsData, sizeof( DISINFECTS_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastSwitchesData function sends out switches data. - * @details Inputs: none - * @details Outputs: switches data msg constructed and queued - * @param SWITCHES_DATA_T which is switches msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastSwitchesData( SWITCHES_DATA_T *switchesData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_SWITCHES_DATA; - msg.hdr.payloadLen = sizeof( SWITCHES_DATA_T ); - - memcpy( payloadPtr, switchesData, sizeof( SWITCHES_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastTemperaturesData function sends out the temperatures data. - * @details Inputs: none - * @details Outputs: temperatures data msg constructed and queued - * @param temperaturesData which is the temperatures msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastTemperaturesData( TEMPERATURES_DATA_T *temperaturesData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_TEMPERATURES_DATA; - msg.hdr.payloadLen = sizeof( TEMPERATURES_DATA_T ); - - memcpy( payloadPtr, temperaturesData, sizeof( TEMPERATURES_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - -/*********************************************************************//** - * @brief - * The broadcastFansData function sends out the fans data. - * @details Inputs: none - * @details Outputs: fans data msg constructed and queued - * @param fansData which is the fans msg constructed and queued - * @return TRUE if msg successfully queued for transmit, FALSE if not - *************************************************************************/ -BOOL broadcastFansData( FANS_DATA_T *fansData ) -{ - BOOL result; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // Create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_FANS_DATA; - msg.hdr.payloadLen = sizeof( FANS_DATA_T ); - - memcpy( payloadPtr, fansData, sizeof( FANS_DATA_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_BROADCAST, ACK_NOT_REQUIRED ); - - return result; -} - #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { @@ -3259,74 +2254,34 @@ TEMPERATURE_SENSORS_DATA_T payload; memcpy( &payload, message->payload, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); - setDialysateTemperatureReadings( payload.inletDialysate, payload.outletRedundant ); + setDialysateTemperatureReadings( payload.TDi, payload.TRo ); } // TODO - what to do if invalid payload length? // TODO - how to know if DG stops sending these? } -/*********************************************************************//** - * @brief - * The handleROPumpData function handles an RO pump 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 handleROPumpData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ) - { - DG_RO_PUMP_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_RO_PUMP_DATA_PAYLOAD_T) ); - setDGROPumpData( payload.setPtPSI, payload.measFlowRateMlMin ); - } +/*********************************************************************//** + * @brief + * The handleDialysateFlowData function handles dialysate flow 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 handleDialysateFlowData( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof(DIALYSATE_FLOW_METER_DATA_T) ) + { + DIALYSATE_FLOW_METER_DATA_T payload; + + memcpy( &payload, message->payload, sizeof(DIALYSATE_FLOW_METER_DATA_T) ); + setDialysateFlowData( payload.measuredDialysateFlowRate ); + } } -/*********************************************************************//** - * @brief - * The handleDrainPumpData function handles a drain pump broadcast - * message from the DG. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleDrainPumpData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ) - { - DG_DRAIN_PUMP_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_DRAIN_PUMP_DATA_PAYLOAD_T) ); - setDGDrainPumpData( payload.setPtRPM ); - } -} - -/*********************************************************************//** - * @brief - * The handleDGPressuresData function handles a DG pressure sensor 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 handleDGPressuresData( MESSAGE_T *message ) -{ - if ( message->hdr.payloadLen == sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ) - { - DG_PRESSURES_DATA_PAYLOAD_T payload; - - memcpy( &payload, message->payload, sizeof(DG_PRESSURES_DATA_PAYLOAD_T) ); - setDGPressures( payload.roInPSI, payload.roOutPSI, payload.drainInPSI, payload.drainOutPSI ); - } -} - -/*********************************************************************//** - * @brief +/*********************************************************************//** + * @brief * The handleDGReservoirData function handles a reservoir data broadcast * message from the DG. * @details Inputs: none @@ -4563,14 +3518,14 @@ /*********************************************************************//** * @brief - * The handleTestBloodFlowSignalStrengthOverrideRequest function handles a - * request to override the measured blood flow signal strength (%). + * The handleHDBloodPumpRotorCountOverrideRequest function handles a request to + * override the blood pump rotor count. * @details Inputs: none * @details Outputs: message handled * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestBloodFlowSignalStrengthOverrideRequest( MESSAGE_T *message ) +void handleHDBloodPumpRotorCountOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -4581,18 +3536,50 @@ memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); if ( FALSE == payload.reset ) { - result = testSetMeasuredBloodFlowSignalStrengthOverride( payload.state.f32 ); + result = testSetBloodPumpRotorCountOverride( payload.state.u32 ); } else { - result = testResetMeasuredBloodFlowSignalStrengthOverride(); + result = testResetBloodPumpRotorCountOverride(); } } // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } - + +/*********************************************************************//** + * @brief + * The handleHDSetArterialPressureOffsetRequest function handles a request to + * set the arterial pressure offset. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleHDSetArterialPressureOffsetRequest( 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 = testSetArterialPressureOffsetOverride( payload.state.f32 ); + } + else + { + result = testResetArterialPressureOffsetOverride(); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + /*********************************************************************//** * @brief * The handleTestBloodPumpRotorMeasuredSpeedOverrideRequest function handles a request to @@ -4835,38 +3822,6 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestDialInFlowSignalStrengthOverrideRequest function handles a - * request to override the measured dialysate inlet flow signal strength (%). - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialInFlowSignalStrengthOverrideRequest( 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 = testSetMeasuredDialInFlowSignalStrengthOverride( payload.state.f32 ); - } - else - { - result = testResetMeasuredDialInFlowSignalStrengthOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /*********************************************************************//** * @brief * The handleTestDialInPumpRotorMeasuredSpeedOverrideRequest function handles a request to @@ -5125,70 +4080,6 @@ /*********************************************************************//** * @brief - * The handleTestDialysateInletPumpOcclusionOverrideRequest function handles a request to - * override the dialysate inlet pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialysateInletPumpOcclusionOverrideRequest( 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 = testSetDialInPumpOcclusionOverride( payload.state.u32 ); - } - else - { - result = testResetDialInPumpOcclusionOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestDialysateOutletPumpOcclusionOverrideRequest function handles a request to - * override the dialysate outlet pump occlusion sensor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestDialysateOutletPumpOcclusionOverrideRequest( 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 = testSetDialOutPumpOcclusionOverride( payload.state.u32 ); - } - else - { - result = testResetDialOutPumpOcclusionOverride(); - } - } - - // 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 @@ -6228,6 +5119,7 @@ if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + if ( FALSE == payload.reset ) { result = testSetBatteryRemainingPercentOverride( payload.state.u32 ); @@ -6276,38 +5168,6 @@ /*********************************************************************//** * @brief - * The handleBloodPrimeSafetyVolumeOverrideRequest function handles a request to - * override the calculated safety blood prime volume (in mL). - * @details Inputs: none - * @details Outputs: message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -void handleBloodPrimeSafetyVolumeOverrideRequest( 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 = testSetBloodPrimeSafetyVolumeOverride( payload.state.f32 ); - } - else - { - result = testResetBloodPrimeSafetyVolumeOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleRinsebackVolumeOverrideRequest function handles a request to * override the calculated rinseback volume (in mL). * @details Inputs: none @@ -6340,38 +5200,6 @@ /*********************************************************************//** * @brief - * The handleRinsebackSafetyVolumeOverrideRequest function handles a request to - * override the calculated safety rinseback volume (in mL). - * @details Inputs: none - * @details Outputs: message handled - * @param message : a pointer to the message to handle - * @return none - *************************************************************************/ -void handleRinsebackSafetyVolumeOverrideRequest( 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 = testSetRinsebackSafetyVolumeOverride( payload.state.f32 ); - } - else - { - result = testResetRinsebackSafetyVolumeOverride(); - } - } - - // Respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief * The handleHDSoftwareResetRequest function handles a request to reset the * HD firmware processor. * @details Inputs: none @@ -7457,6 +6285,63 @@ /*********************************************************************//** * @brief + * The handleTestBlockMessagesRequest function handles a request to + * block transmission of specific message(s). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBlockMessagesRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( BLOCKED_MSGS_DATA_T ) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + memcpy( &blockedMessagesForXmit.blockedMessages[0], message->payload, sizeof( BLOCKED_MSGS_DATA_T ) ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief + * The handleTestSyringePumpForceSensorCalibrateRequest function handles a + * request message to set the syringe pump DAC reference voltage. + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestSyringePumpForceSensorCalibrateRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof( F32 ) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + F32 dacVRef; + + result = TRUE; + memcpy( &dacVRef, message->payload, sizeof( F32 ) ); + setSyringePumpDACVref( dacVRef ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestAlarmAudioVolumeOverrideRequest function handles a * request to override the alarm audio volume level. * @details Inputs: none