Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -rd47a7266da716ae65dd414b50002d72cb38f63fb -ref1d6b657a58e367d823e09bfbf38cb52552d64f --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision d47a7266da716ae65dd414b50002d72cb38f63fb) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision ef1d6b657a58e367d823e09bfbf38cb52552d64f) @@ -227,12 +227,15 @@ { BOOL result; MESSAGE_T msg; + ACK_RESPONSE_PAYLOAD_T cmd; + cmd.acknowledgement = ack; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = (U08)ack; + msg.hdr.payloadLen = sizeof( ACK_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &cmd, sizeof( ACK_RESPONSE_PAYLOAD_T ) ); // 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 ); @@ -255,17 +258,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T cmd; + cmd.accepted = accepted; + cmd.rejectionReason = reason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = msgID; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ); + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &cmd, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - 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 result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -287,17 +290,21 @@ * @param cmd 0=prompt user to confirm, 1=cancel prompt, 2=reject user off request * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendOffButtonMsgToUI( U08 cmd ) +BOOL sendOffButtonMsgToUI( U08 prompt ) { BOOL result; MESSAGE_T msg; + UI_OFF_BUTTON_RESPONSE_PAYLOAD_T cmd; + cmd.userRequest = prompt; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_OFF_BUTTON_PRESS; - msg.hdr.payloadLen = sizeof( U08 ); - msg.payload[ 0 ] = cmd; + msg.hdr.payloadLen = sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ); + memcpy(&msg.payload, &cmd, sizeof( UI_OFF_BUTTON_RESPONSE_PAYLOAD_T ) ); + // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -367,27 +374,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; - U32 e = (U32)event; - // Convert the two data types enums to U32. The enums are interpreted as a U08 by the compiler - U32 dataType1 = (U32)dat1.dataType; - U32 dataType2 = (U32)dat2.dataType; + EVENT_PAYLOAD_T eventStruct; + eventStruct.event = (U32)event; + eventStruct.dataType1 = (U32)dat1.dataType; + eventStruct.data1 = dat1.data; + eventStruct.dataType2 = (U32)dat2.dataType; + eventStruct.data2 = dat2.data; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_EVENT; // The payload length is the event ID, 2 event datas and the events data types for each of the event data - msg.hdr.payloadLen = sizeof( U32 ) + 2 * sizeof( EVENT_DATAS_T ) + 2 * sizeof( U32 ); + msg.hdr.payloadLen = sizeof( EVENT_PAYLOAD_T ); - memcpy( payloadPtr, &e, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dataType1, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dat1.data, sizeof( EVENT_DATAS_T ) ); - payloadPtr += sizeof( EVENT_DATAS_T ); - memcpy( payloadPtr, &dataType2, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dat2.data, sizeof( EVENT_DATAS_T ) ); + memcpy( &msg.payload, &eventStruct, sizeof( EVENT_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); @@ -416,28 +417,23 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ufResponse; + ufResponse.accepted = accepted; + ufResponse.rejectionReason = reason; + ufResponse.ufVolume = volume_mL; + ufResponse.durationInMinutes = time_min; + ufResponse.timeDiff = timeDiff; + ufResponse.ufRate = ufRate_mL_min; + ufResponse.rateDiff = rateDiff; + ufResponse.oldUFRate = oldUFRate_mL_min; + // 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 ); + msg.hdr.payloadLen = sizeof( UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &timeDiff, sizeof( S32 ) ); - payloadPtr += sizeof( S32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &rateDiff, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &oldUFRate_mL_min, sizeof( F32 ) ); + memcpy( &msg.payload, &ufResponse, sizeof( UF_SETTINGS_CHANGE_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -463,22 +459,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ufConfirm; + // Populate Messsage + ufConfirm.accepted = accepted; + ufConfirm.rejectionReason = reason; + ufConfirm.volume = volume_mL; + ufConfirm.duration = time_min; + ufConfirm.ufRate = ufRate_mL_min; + // 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 ); + msg.hdr.payloadLen = sizeof( UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &ufRate_mL_min, sizeof( F32 ) ); + memcpy( &msg.payload, &ufConfirm, sizeof( UF_SETTINGS_CONFIRMATION_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -503,21 +498,19 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T treatmentResponse; + treatmentResponse.accepted = accepted; + treatmentResponse.rejectionReason = reason; + treatmentResponse.duration = time_min; + treatmentResponse.volume = volume_mL; + // 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 ); + msg.hdr.payloadLen = sizeof( TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &treatmentResponse, sizeof( TREATMENT_TIME_CHANGE_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &time_min, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &volume_mL, sizeof( F32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -541,21 +534,19 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T rateResponse; + rateResponse.accepted = accepted; + rateResponse.rejectionReason = reason; + rateResponse.bloodRate = bloodRate; + rateResponse.dialRate = dialRate; + // 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 ); + msg.hdr.payloadLen = sizeof( BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &rateResponse, sizeof( BLOOD_DIAL_RATE_CHANGE_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &bloodRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &dialRate, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -606,17 +597,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T heparinResponse; + heparinResponse.accepted = accepted; + heparinResponse.rejectionReason = rejReason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_HEPARIN_PAUSE_RESUME_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) * 2; + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &heparinResponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -638,17 +629,17 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + UI_RESPONSE_PAYLOAD_T audioVolumeResponse; + audioVolumeResponse.accepted = accepted; + audioVolumeResponse.rejectionReason = rejReason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_ALARM_AUDIO_VOLUME_SET_RESPONSE; - msg.hdr.payloadLen = sizeof( U32 ) * 2; + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); + memcpy( &msg.payload, &audioVolumeResponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); - memcpy( payloadPtr, &accepted, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &rejReason, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -673,25 +664,21 @@ { BOOL result; MESSAGE_T msg; - U08 *payloadPtr = msg.payload; + TREATMENT_PARAM_BROADCAST_PAYLOAD_T paramRanges; + paramRanges.minTreatmentTime = minTime; + paramRanges.maxTreatmentTime = maxTime; + paramRanges.minUFVolume = minUFVol; + paramRanges.maxUFVolume = maxUFVol; + paramRanges.minDialRate = minDialRate; + paramRanges.maxDialRate = maxDialRate; + // 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 ); + msg.hdr.payloadLen = sizeof( TREATMENT_PARAM_BROADCAST_PAYLOAD_T ); + memcpy( &msg.payload, ¶mRanges, sizeof( TREATMENT_PARAM_BROADCAST_PAYLOAD_T ) ); - memcpy( payloadPtr, &minTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxTime, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &minUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &maxUFVol, sizeof( F32 ) ); - payloadPtr += sizeof( F32 ); - memcpy( payloadPtr, &minDialRate, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); - memcpy( payloadPtr, &maxDialRate, sizeof( U32 ) ); - // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_REQUIRED ); @@ -740,7 +727,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -761,7 +748,7 @@ } else { - sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, FALSE ); + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_HD_2_UI, ACK_NOT_REQUIRED ); } } @@ -815,17 +802,19 @@ BOOL sendTreatmentLogData( BOOL accepted, U32 reason, TREATMENT_LOG_DATA_PAYLOAD_T *logDataPtr ) { MESSAGE_T msg; + UI_RESPONSE_PAYLOAD_T UIReponse; U08 *payloadPtr = msg.payload; + UIReponse.accepted = accepted; + UIReponse.rejectionReason = reason; + // Create a message record blankMessage( &msg ); msg.hdr.msgID = MSG_ID_HD_TREATMENT_LOG_DATA_RESPONSE; - msg.hdr.payloadLen = sizeof( BOOL ) + sizeof( U32 ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); + msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ) + sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ); - memcpy( payloadPtr, &accepted, sizeof( BOOL ) ); - payloadPtr += sizeof( BOOL ); - memcpy( payloadPtr, &reason, sizeof( U32 ) ); - payloadPtr += sizeof( U32 ); + memcpy( payloadPtr, &UIReponse, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + payloadPtr += sizeof( UI_RESPONSE_PAYLOAD_T ); memcpy( payloadPtr, logDataPtr, sizeof( TREATMENT_LOG_DATA_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer