Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r8a0632bf9908008ee8db18474bc914d990760986 -rc282822f36836a8127f447c8ac5b8a50e851be63 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 8a0632bf9908008ee8db18474bc914d990760986) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision c282822f36836a8127f447c8ac5b8a50e851be63) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include // for memcpy() +#include // For memcpy() #include "reg_system.h" @@ -84,15 +84,15 @@ U32 sizeMod, sizePad; U32 i; U08 crc; - U08 data[ MAX_ACK_MSG_SIZE ]; // byte array to populate with message data + U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data - // prefix data with message sync byte + // 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 ) + // 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 + // Thread protect next sequence # access & increment _disable_IRQ(); msg.hdr.seqNo = nextSeqNo; nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); @@ -103,21 +103,21 @@ } } - // calculate message CRC + // Calculate message CRC crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - // serialize message header data + // 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) + // 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 + // Add 8-bit CRC data[ msgSize++ ] = crc; - // pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + // 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++ ) @@ -126,7 +126,7 @@ } #ifndef DISABLE_ACK_ERRORS - // if ACK required, add to pending ACK list + // If ACK required, add to pending ACK list if ( TRUE == ackReq ) { if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) @@ -139,7 +139,7 @@ if ( FALSE == error ) { - // add serialized message data to appropriate out-going comm buffer + // Add serialized message data to appropriate out-going comm buffer result = addToCommBuffer( buffer, data, msgSize ); } @@ -160,16 +160,16 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); - // send ACK back with same seq. #, but w/o ACK bit + // 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; + 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 + // Serialize and queue the message for transmit on broadcast channel result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_BROADCAST, ACK_NOT_REQUIRED ); return result; @@ -192,13 +192,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // 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 + // 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; @@ -222,13 +222,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // 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 + // 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; @@ -257,7 +257,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 ); @@ -278,7 +278,7 @@ 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 + // 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; @@ -304,7 +304,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 ); @@ -319,7 +319,7 @@ 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 + // 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; @@ -344,7 +344,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 ); @@ -357,7 +357,7 @@ 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 + // 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; @@ -382,7 +382,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 ); @@ -395,7 +395,7 @@ 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 + // 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; @@ -417,14 +417,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_PRESSURE_LIMITS_CHANGE_RESPONSE; msg.hdr.payloadLen = sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ); memcpy( payloadPtr, (U08*)data, sizeof( PRESSURE_LIMIT_CHANGE_RESPONSE_T ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -450,7 +450,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 ); @@ -467,7 +467,7 @@ 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 + // 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; @@ -489,7 +489,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_SET_DG_DIALYSATE_TEMP_TARGETS; msg.hdr.payloadLen = sizeof( F32 ) + sizeof( F32 ); @@ -498,7 +498,7 @@ payloadPtr += sizeof( F32 ); memcpy( payloadPtr, &trimmer, sizeof( F32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -519,14 +519,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -547,14 +547,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_FILL_CMD; msg.hdr.payloadLen = sizeof( U32 ); memcpy( payloadPtr, &fillToVolumeMl, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -566,7 +566,7 @@ * and queues the msg for transmit on the appropriate CAN channel. * @details Inputs: none * @details Outputs: DG drain command msg constructed and queued. - * @param drainToVolumeMl volume (in mL) to drain the inactive reservoir to + * @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 ) @@ -575,14 +575,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -603,14 +603,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -623,23 +623,26 @@ * 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 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 ) +BOOL sendDGStartStopTrimmerHeaterCommand( BOOL start, F32 trimmerHtrTemp ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_START_STOP_TRIMMER_HEATER_CMD; - msg.hdr.payloadLen = sizeof( BOOL ); + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( F32 ); + + memcpy( payloadPtr, &start, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &trimmerHtrTemp, sizeof( F32 ) ); - memcpy( payloadPtr, &start, sizeof( BOOL ) ); - - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -658,19 +661,64 @@ BOOL result; MESSAGE_T msg; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_DG_SAMPLE_WATER_CMD; msg.hdr.payloadLen = 0; - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param messagePtr pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGCmdResp( MESSAGE_T *messagePtr ) +{ + BOOL result = FALSE; + if ( messagePtr->hdr.payloadLen == sizeof( DG_CMD_RESPONSE_T ) ) + { + result = TRUE; + handleDGCommandResponse( messagePtr->payload ); + } + + sendAckResponseMsg( (MSG_ID_T)messagePtr->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_DG, result ); +} + /*********************************************************************//** * @brief + * The handleDGOpMode function handles a DG broadcast of its current mode. + * @details Inputs: none + * @details Outputs: message handled, response constructed and queued for transmit. + * @param message pointer to the message to handle. + * @return none + *************************************************************************/ +void handleDGOpMode( MESSAGE_T *message ) +{ + U32 payloadSize = sizeof(U32) + sizeof(U32); + + if ( message->hdr.payloadLen == payloadSize ) + { + U32 mode, subMode; + + memcpy( &mode, message->payload, sizeof(U32) ); + memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); + + setDGOpMode( mode, subMode ); + checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast + } +} + +/*********************************************************************//** + * @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 @@ -693,7 +741,7 @@ U08 *payloadPtr = msg.payload; ACCEL_DATA_PAYLOAD_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_ACCELEROMETER_DATA; msg.hdr.payloadLen = sizeof( ACCEL_DATA_PAYLOAD_T ); @@ -709,7 +757,7 @@ 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 + // 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; @@ -731,29 +779,32 @@ U08 *payloadPtr = msg.payload; ALARM_COMP_STATUS_PAYLOAD_T payload; - // create a message record + // 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; - payload.escalatesIn = almStatus.alarmsEscalatesIn; - payload.alarmsFlags = ( almStatus.systemFault ? BIT_BY_POS(0) : 0 ); - payload.alarmsFlags |= ( almStatus.stop ? BIT_BY_POS(1) : 0 ); - payload.alarmsFlags |= ( almStatus.noClear ? BIT_BY_POS(2) : 0 ); - payload.alarmsFlags |= ( almStatus.noResume ? BIT_BY_POS(3) : 0 ); - payload.alarmsFlags |= ( almStatus.noRinseback ? BIT_BY_POS(4) : 0 ); - payload.alarmsFlags |= ( almStatus.noEndTreatment ? BIT_BY_POS(5) : 0 ); - payload.alarmsFlags |= ( almStatus.noNewTreatment ? BIT_BY_POS(6) : 0 ); - payload.alarmsFlags |= ( almStatus.bypassDialyzer ? BIT_BY_POS(7) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsToEscalate ? BIT_BY_POS(8) : 0 ); - payload.alarmsFlags |= ( almStatus.alarmsSilenced ? BIT_BY_POS(9) : 0 ); - payload.alarmsFlags |= ( almStatus.lampOn ? BIT_BY_POS(10) : 0 ); + 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; + 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.noNewTreatment ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_NO_NEW_TREATMENT) : 0 ); + payload.alarmsFlags |= ( almStatus.usrACKRequired ? BIT_BY_POS(ALARM_STATE_FLAG_BIT_POS_USER_MUST_ACK) : 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.topAlarmConditionnDetected ? 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 + // 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; @@ -770,19 +821,19 @@ * @param almData2 2nd data associated with alarm * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastAlarmTriggered( U16 alarm, ALARM_DATA_T almData1, ALARM_DATA_T almData2 ) +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 + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_TRIGGERED; - msg.hdr.payloadLen = sizeof( U16 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each + msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ) * 2 * 2; // 2 alarm data recs w/ 2 32-bit values each - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); - payloadPtr += sizeof( U16 ); + memcpy( payloadPtr, &alarm, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &almData1.dataType, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &almData1.data, sizeof( U32 ) ); @@ -791,7 +842,7 @@ 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 + // 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; @@ -806,25 +857,25 @@ * @param alarm ID of alarm cleared * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL broadcastAlarmCleared( U16 alarm ) +BOOL broadcastAlarmCleared( U32 alarm ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_ALARM_CLEARED; - msg.hdr.payloadLen = sizeof( U16 ); + msg.hdr.payloadLen = sizeof( U32 ); - memcpy( payloadPtr, &alarm, sizeof( U16 ) ); + memcpy( payloadPtr, &alarm, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 @@ -852,8 +903,8 @@ result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_ALARM, ACK_REQUIRED ); return result; -} - +} + /*********************************************************************//** * @brief * The broadcastBloodFlowData function constructs a blood flow data msg to @@ -869,14 +920,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -897,14 +948,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -925,14 +976,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -953,14 +1004,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -981,14 +1032,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -1012,7 +1063,7 @@ U08 *payloadPtr = msg.payload; TREATMENT_TIME_DATA_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_TIME; msg.hdr.payloadLen = sizeof( TREATMENT_TIME_DATA_T ); @@ -1023,7 +1074,7 @@ 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 + // 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; @@ -1047,18 +1098,19 @@ U08 *payloadPtr = msg.payload; TREATMENT_STATE_DATA_T payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_TREATMENT_STATE; msg.hdr.payloadLen = sizeof( TREATMENT_STATE_DATA_T ); payload.treatmentSubMode = subMode; payload.uFState = uFState; payload.salineBolusState = salineBolusState; + payload.heparinState = 0; // TODO - add this later 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 + // 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; @@ -1077,12 +1129,12 @@ BOOL result; MESSAGE_T msg; - // create a message record + // 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 + // 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; @@ -1094,7 +1146,8 @@ * 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 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 ) @@ -1103,7 +1156,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_OP_MODE; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); @@ -1112,7 +1165,7 @@ 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 + // 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; @@ -1124,6 +1177,7 @@ * 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 ) @@ -1132,14 +1186,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -1151,6 +1205,7 @@ * 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 ) @@ -1159,14 +1214,14 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -1178,6 +1233,8 @@ * 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 ) @@ -1188,7 +1245,7 @@ U32 lower = (U32)lowerLevel; U32 upper = (U32)upperLevel; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_AIR_TRAP_DATA; msg.hdr.payloadLen = sizeof( U32 ) + sizeof( U32 ); @@ -1197,27 +1254,55 @@ 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 + // 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 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; +} + #ifdef EMC_TEST_BUILD BOOL broadcastCANErrorCount( U32 count ) { BOOL result; MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // 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 + // 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; @@ -1264,14 +1349,14 @@ *************************************************************************/ void handleAlarmTriggered( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == ( sizeof( U16 ) + sizeof( U32 ) * 2 * 2 ) ) // 2 data records w/ 2 U32s each + if ( message->hdr.payloadLen == ( sizeof( U32 ) + sizeof( U32 ) * 2 * 2 ) ) // 2 data records w/ 2 U32s each { U08 *payloadPtr = message->payload; - U16 alarmID; + U32 alarmID; ALARM_DATA_T alm1, alm2; - memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); - payloadPtr += sizeof( U16 ); + memcpy( &alarmID, payloadPtr, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); memcpy( &alm1.dataType, payloadPtr, sizeof( U32 ) ); payloadPtr += sizeof( U32 ); memcpy( &alm1.data, payloadPtr, sizeof( U32 ) ); @@ -1289,28 +1374,82 @@ /*********************************************************************//** * @brief - * The handleAlarmCleared function handles a cleared alarm event message. + * The handleAlarmCleared function handles a cleared alarm condition event message. * @details Inputs: none - * @details Outputs: alarm cleared. + * @details Outputs: alarm condition is cleared. * @param message a pointer to the message to handle * @return none *************************************************************************/ void handleAlarmCleared( MESSAGE_T *message ) { - if ( message->hdr.payloadLen == sizeof( U16 ) ) + if ( message->hdr.payloadLen == sizeof( U32 ) ) { U08 *payloadPtr = message->payload; - U16 alarmID; + U32 alarmID; - memcpy( &alarmID, payloadPtr, sizeof( U16 ) ); + memcpy( &alarmID, payloadPtr, sizeof( U32 ) ); if ( (ALARM_ID_T)alarmID < NUM_OF_ALARM_IDS ) { - clearAlarm( (ALARM_ID_T)alarmID ); + clearAlarmCondition( (ALARM_ID_T)alarmID ); } } } - + +/*********************************************************************//** + * @brief + * The handleUIAlarmSilenceRequest function handles an alarm silence request + * message. + * @details Inputs: none + * @details Outputs: alarm silence command is handled. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUIAlarmSilenceRequest( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 cmd; + + memcpy( &cmd, payloadPtr, sizeof( U32 ) ); + + signalAlarmSilence( cmd ); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleAlarmUserAction function handles a user alarm action event message. + * @details Inputs: none + * @details Outputs: selected action initiated. + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleAlarmUserAction( MESSAGE_T *message ) +{ + if ( message->hdr.payloadLen == sizeof( U32 ) ) + { + U08 *payloadPtr = message->payload; + U32 action; + + memcpy( &action, payloadPtr, sizeof( U32 ) ); + + if ( (ALARM_USER_ACTION_T)action < NUMBER_OF_ALARM_USER_ACTIONS ) + { + signalAlarmUserActionInitiated( (ALARM_USER_ACTION_T)action ); + } + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + } +} + /*********************************************************************//** * @brief * The handleOffButtonConfirmMsgFromUI function handles a response to an @@ -1508,7 +1647,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_UF_PAUSE_RESUME_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); @@ -1519,7 +1658,7 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &ufState, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1544,15 +1683,15 @@ memcpy( &cmd, message->payload, sizeof(U32) ); - if ( 0 == cmd ) // initiate treatment (go to treatment params mode) + if ( 0 == cmd ) // Initiate treatment (go to treatment params mode) { result = signalUserStartingTreatment(); } - else if ( 1 == cmd ) // cancel treatment (return from aborted treatment params mode) + else if ( 1 == cmd ) // Cancel treatment (return from aborted treatment params mode) { result = signalUserCancelTreatment(); } - else if ( 2 == cmd ) // start treatment + else if ( 2 == cmd ) // Start treatment { result = signalUserBeginningTreatment(); } @@ -1578,7 +1717,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_START_TREATMENT_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); @@ -1587,7 +1726,7 @@ payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, &reason, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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; @@ -1666,7 +1805,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_NEW_TREATMENT_PARAMS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + byteLength; @@ -1675,12 +1814,71 @@ payloadPtr += sizeof( BOOL ); memcpy( payloadPtr, rejectReasons, byteLength ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 handleUFVolumeSetRequest function handles a UF volume treatment parameter + * set and validate request message from the UI. + * @details Inputs: none + * @details Outputs: message handled + * @param message a pointer to the message to handle + * @return none + *************************************************************************/ +void handleUFVolumeSetRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + if ( message->hdr.payloadLen == sizeof(F32) ) + { + F32 uFVolumeMl; + + memcpy( &uFVolumeMl, message->payload, sizeof(F32) ); + + result = validateAndSetUFVolume( uFVolumeMl ); + } + + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, result ); +} + +/*********************************************************************//** + * @brief + * The sendUFVolumeSetResponseMsg function constructs a UF volume treatment parameter + * response to the UI and queues the msg for transmit on the appropriate CAN channel. + * @details Inputs: none + * @details Outputs: UF volume treatment parameter response msg constructed and queued. + * @param accepted T/F - is UF volume setting accepted? + * @param rejectReasons reason UF volume setting was rejected (if not accepted) + * @param uFVolumeMl UF volume (in mL) value that is now in place + * @return TRUE if msg successfully queued for transmit, FALSE if not + *************************************************************************/ +BOOL sendUFVolumeSetResponseMsg( BOOL accepted, U32 reason, F32 uFVolumeMl ) +{ + BOOL result; + MESSAGE_T msg; + U08 *payloadPtr = msg.payload; + + // Create a message record + blankMessage( &msg ); + msg.hdr.msgID = MSG_ID_HD_SET_UF_VOLUME_PARAMETER_RESPONSE; + msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( F32 ); + + memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); + payloadPtr += sizeof( BOOL ); + memcpy( payloadPtr, &reason, sizeof( U32 ) ); + payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &uFVolumeMl, 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 handleChangeUFSettingsRequest function handles a ultrafiltration @@ -1859,7 +2057,7 @@ MESSAGE_T msg; U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_USER_SALINE_BOLUS_RESPONSE; msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( U32 ); @@ -1870,38 +2068,14 @@ payloadPtr += sizeof( U32 ); memcpy( payloadPtr, &bolusVol, sizeof( U32 ) ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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 handleDGOpMode function handles a DG broadcast of it's current mode. - * @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 handleDGOpMode( MESSAGE_T *message ) -{ - U32 payloadSize = sizeof(U32) + sizeof(U32); - - if ( message->hdr.payloadLen == payloadSize ) - { - U32 mode, subMode; - - memcpy( &mode, message->payload, sizeof(U32) ); - memcpy( &subMode, &message->payload[sizeof(U32)], sizeof(U32) ); - - setDGOpMode( mode, subMode ); - checkInFromDG(); // TODO - here until we implement DG check-in w/ HD broadcast - } -} - -/*********************************************************************//** - * @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. @@ -1914,22 +2088,22 @@ HD_VERSIONS_T payload; U08 *payloadPtr = msg.payload; - // populate payload + // Populate payload payload.major = (U08)HD_VERSION_MAJOR; payload.minor = (U08)HD_VERSION_MINOR; payload.micro = (U08)HD_VERSION_MICRO; payload.build = (U16)HD_VERSION_BUILD; getFPGAVersions( &payload.fpgaId, &payload.fpgaMajor, &payload.fpgaMinor, &payload.fpgaLab ); - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_VERSION; msg.hdr.payloadLen = sizeof( HD_VERSIONS_T ); - // fill message payload + // 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 + // 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 ); } @@ -1954,7 +2128,7 @@ { BOOL result; - // add serialized message data to appropriate comm buffer + // Add serialized message data to appropriate comm buffer result = addToCommBuffer( COMM_BUFFER_OUT_UART_PC, dbgData, len ); return result; @@ -1975,15 +2149,15 @@ U32 txtLen = strlen( (char*)str ); U08 *payloadPtr = msg.payload; - // create a message record + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_DEBUG_EVENT; - msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // add 1 byte for null terminator + msg.hdr.payloadLen = DEBUG_EVENT_MAX_TEXT_LEN + 1; // Add 1 byte for null terminator if ( txtLen <= DEBUG_EVENT_MAX_TEXT_LEN ) { memcpy( payloadPtr, str, txtLen + 1 ); - // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer + // 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_NOT_REQUIRED ); } } @@ -2018,13 +2192,13 @@ BOOL result; MESSAGE_T msg; - // create a message record + // 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 + // 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; @@ -2041,18 +2215,18 @@ *************************************************************************/ void handleTesterLogInRequest( MESSAGE_T *message ) { - // verify pass code + // 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 + checkInFromUI(); // Allow tasks to begin normal processing when tester has logged in } else { testerLoggedIn = FALSE; } - // respond to would be tester + // Respond to would be tester sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, testerLoggedIn ); } @@ -2070,7 +2244,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2085,7 +2259,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2103,7 +2277,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2117,7 +2291,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2135,7 +2309,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = 0; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2149,7 +2323,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2167,7 +2341,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2181,7 +2355,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2199,7 +2373,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2213,7 +2387,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2231,7 +2405,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -2245,7 +2419,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2263,14 +2437,14 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); result = testSetTargetBloodFlowRateOverride( payload.setPt, payload.ctrlMode ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2288,7 +2462,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2302,7 +2476,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2320,7 +2494,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2334,7 +2508,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2352,7 +2526,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2366,7 +2540,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2384,7 +2558,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2398,7 +2572,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2416,7 +2590,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2430,7 +2604,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2448,7 +2622,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2462,7 +2636,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2480,7 +2654,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2494,7 +2668,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2512,14 +2686,14 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); result = testSetTargetDialInFlowRateOverride( payload.setPt, payload.ctrlMode ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2537,14 +2711,14 @@ OVERRIDE_PUMP_SET_PT_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_PUMP_SET_PT_PAYLOAD_T) ); result = testSetTargetDialOutFlowRateOverride( payload.setPt, payload.ctrlMode ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2562,7 +2736,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2576,7 +2750,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2594,7 +2768,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2608,7 +2782,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2626,7 +2800,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2640,7 +2814,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2658,7 +2832,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2672,7 +2846,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2690,7 +2864,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2704,7 +2878,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2722,7 +2896,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2736,7 +2910,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2754,7 +2928,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2768,7 +2942,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2786,7 +2960,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2800,7 +2974,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2818,7 +2992,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2832,7 +3006,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2850,7 +3024,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2864,7 +3038,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2882,7 +3056,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2896,7 +3070,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2914,7 +3088,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2928,7 +3102,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2946,7 +3120,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -2960,7 +3134,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -2990,7 +3164,7 @@ result = setRTCTimestamp( seconds, minutes, hours, days, months, years ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3008,7 +3182,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3022,7 +3196,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3041,7 +3215,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3055,7 +3229,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3074,7 +3248,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3088,7 +3262,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3107,7 +3281,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3121,7 +3295,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3140,7 +3314,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3154,7 +3328,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3172,7 +3346,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3186,7 +3360,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3204,7 +3378,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3218,7 +3392,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3236,7 +3410,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3250,7 +3424,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3268,7 +3442,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3282,7 +3456,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3300,7 +3474,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3314,7 +3488,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3332,7 +3506,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3346,7 +3520,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3364,7 +3538,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3378,7 +3552,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3395,7 +3569,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(ACCEL_CAL_PAYLOAD_T) ) { ACCEL_CAL_PAYLOAD_T payload; @@ -3404,7 +3578,7 @@ result = setAccelCalibration( payload.xOffset, payload.yOffset, payload.zOffset ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3421,7 +3595,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3430,7 +3604,7 @@ result = setBloodFlowCalibration( payload.gain, payload.offset ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3447,7 +3621,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(LINEAR_F32_CAL_PAYLOAD_T) ) { LINEAR_F32_CAL_PAYLOAD_T payload; @@ -3456,11 +3630,11 @@ result = setDialInFlowCalibration( payload.gain, payload.offset ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleTestSetTreatmentParameter function handles a request to set * a specific treatment parameter value. @@ -3473,7 +3647,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(CRITICAL_DATAS_T) + sizeof(CRITICAL_DATAS_T) ) { CRITICAL_DATAS_T payload[2]; @@ -3482,11 +3656,11 @@ result = testSetTreatmentParameter( (TREATMENT_PARAM_T)payload[0].uInt, payload[1] ); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleHomeHDValve function handles a request to home an HD valve * @details Inputs: none @@ -3498,7 +3672,7 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( message->hdr.payloadLen == sizeof(U32) ) { U32 valve; @@ -3509,7 +3683,7 @@ result = TRUE; } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3527,7 +3701,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3541,7 +3715,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3568,7 +3742,7 @@ result = TRUE; } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3586,7 +3760,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3600,7 +3774,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3619,7 +3793,7 @@ OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(OVERRIDE_VALVES_PWM_DIR_SET_PAYLOAD_T) ); @@ -3633,12 +3807,12 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } #endif -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapBroadcastIntervalOverrideRequest function handles a * request to override the air trap data broadcast interval. @@ -3652,7 +3826,7 @@ TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_PAYLOAD_T) ); @@ -3666,11 +3840,11 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/************************************************************************* +/*********************************************************************//** * @brief * The handleSetAirTrapLevelSensorOverrideRequest function handles a request to * override an air trap level sensor. @@ -3684,7 +3858,7 @@ TEST_OVERRIDE_ARRAY_PAYLOAD_T payload; BOOL result = FALSE; - // verify payload length + // Verify payload length if ( sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) == message->hdr.payloadLen ) { memcpy( &payload, message->payload, sizeof(TEST_OVERRIDE_ARRAY_PAYLOAD_T) ); @@ -3698,7 +3872,7 @@ } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3715,20 +3889,20 @@ { BOOL result = FALSE; - // verify payload length + // Verify payload length if ( 0 == message->hdr.payloadLen ) { - // tester must be logged in + // Tester must be logged in if ( TRUE == isTestingActivated() ) - { // s/w reset of processor - result = TRUE; // reset will prevent this from getting transmitted though + { // S/w reset of processor + result = TRUE; // Reset will prevent this from getting transmitted though #ifndef _VECTORCAST_ - systemREG1->SYSECR = (0x2) << 14; // reset processor + systemREG1->SYSECR = (0x2) << 14; // Reset processor #endif } } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3751,7 +3925,7 @@ result = homeBloodPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3774,7 +3948,7 @@ result = homeDialInPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3797,7 +3971,7 @@ result = homeDialOutPump(); } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } @@ -3825,75 +3999,8 @@ result = TRUE; } - // respond to request + // Respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } -/*********************************************************************//** - * @brief - * The handleTestHDCalibrationDataRequest function handles a request for - * HD calibration data. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( 0 == message->hdr.payloadLen ) - { - CALIBRATION_DATA_T cal; - MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - - // get calibration data - result = getCalibrationData( &cal ); - if ( TRUE == result ) - { - // create a message record - blankMessage( &msg ); - msg.hdr.msgID = MSG_ID_HD_CALIBRATION_DATA; - msg.hdr.payloadLen = sizeof( CALIBRATION_DATA_T ); - - memcpy( payloadPtr, &cal, sizeof( CALIBRATION_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 ); - } - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - -/*********************************************************************//** - * @brief - * The handleTestEraseHDCalibrationDataRequest function handles a request for - * HD calibration data erasure. - * @details - * Inputs : none - * Outputs : message handled - * @param message a pointer to the message to handle - * @return none - *************************************************************************/ -void handleTestEraseHDCalibrationDataRequest( MESSAGE_T *message ) -{ - BOOL result = FALSE; - - if ( message->hdr.payloadLen == sizeof(U32) ) - { - U32 key; - - memcpy( &key, message->payload, sizeof(U32) ); - - result = testResetCalibrationData( key ); - } - - // respond to request - sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} - /**@}*/