Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r57fe78d545ac91ba3f8d38ff76079a0d7ec8c0db -r4e1b1e718c7df521980c6cbfbe94f53720292913 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 57fe78d545ac91ba3f8d38ff76079a0d7ec8c0db) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 4e1b1e718c7df521980c6cbfbe94f53720292913) @@ -238,7 +238,7 @@ msg.hdr.payloadLen = sizeof( ACK_RESPONSE_PAYLOAD_T ); //Populate message - memcpy( msg->payload, &cmd, 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 ); @@ -264,7 +264,7 @@ UI_RESPONSE_PAYLOAD_T cmd; // Populate data structure - cmd.accepted = accepted + cmd.accepted = accepted; cmd.rejection_reason = reason; // Create a message record @@ -273,7 +273,7 @@ msg.hdr.payloadLen = sizeof( UI_RESPONSE_PAYLOAD_T ); // Populate message - memcpy( msg->payload, &cmd, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + memcpy( &msg.payload, &cmd, sizeof( UI_RESPONSE_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer @@ -297,17 +297,23 @@ * @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; + // Populate data structure + 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 ); + // Populate message + 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 ); @@ -377,27 +383,23 @@ { 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; + // Populate data structure + 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 ) ); + // Populate message + 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 );