Index: firmware/App/Services/SystemComm.c =================================================================== diff -u -r844f98879b7425c207b58562e623ab960adbc357 -r61222dea4dcdad959cf343b65a6f92216b252f30 --- firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 844f98879b7425c207b58562e623ab960adbc357) +++ firmware/App/Services/SystemComm.c (.../SystemComm.c) (revision 61222dea4dcdad959cf343b65a6f92216b252f30) @@ -1779,6 +1779,10 @@ handleTestPostTreatmentModeSendIntervalOverrideRequest( message ); break; + case MSG_ID_HD_BLOCK_MESSAGE_TRANSMISSION: + handleTestBlockMessagesRequest( message ); + break; + default: // Unrecognized message ID received - ignore break; Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r730ae95f8c4a298e1fec8b8b34064a1fbb76a7f2 -r61222dea4dcdad959cf343b65a6f92216b252f30 --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 730ae95f8c4a298e1fec8b8b34064a1fbb76a7f2) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 61222dea4dcdad959cf343b65a6f92216b252f30) @@ -54,12 +54,24 @@ #ifdef DEBUG_ENABLED #define DEBUG_EVENT_MAX_TEXT_LEN 40 -#endif +#endif + +#define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. + +#pragma pack(push,1) +/// Payload record structure for block message transmission request. +typedef struct +{ + U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; +} BLOCKED_MSGS_DATA_T; +#pragma pack(pop) // ********** private data ********** static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether an external tester (connected PC) has sent a valid login message. -static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. +static volatile U16 nextSeqNo = 1; ///< Value of sequence number to use for next transmitted message. +/// List of message IDs that are requested not to be transmitted. +static BLOCKED_MSGS_DATA_T blockedMessagesForXmit = { 0, 0, 0, 0, 0, 0, 0, 0 }; // ********** private function prototypes ********** @@ -75,7 +87,7 @@ * bit of the sequence # is set if ACK is required per parameter. A sync byte * is inserted at the beginning of the message and an 8-bit CRC is appended to * the end of the message. The message is queued for transmission in the given buffer. - * @details Inputs: none + * @details Inputs: blockedMessagesForXmit * @details Outputs: given data array populated with serialized message data and queued for transmit. * @param msg message to serialize * @param buffer outgoing buffer that message should be queued in @@ -85,69 +97,92 @@ static U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { BOOL result = 0; - BOOL error = FALSE; + BOOL error = FALSE; + BOOL blocked = FALSE; U32 msgSize = 0; U32 sizeMod, sizePad; U32 i; U08 crc; - U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data - - // Prefix data with message sync byte - data[ msgSize++ ] = MESSAGE_SYNC_BYTE; - - // Set sequence # and ACK bit (unless this is an ACK to a received message) - if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) + U08 data[ MAX_ACK_MSG_SIZE ]; // Byte array to populate with message data + + // Check to see if tester has requested this message not be transmited + if ( TRUE == isTestingActivated() ) + { + U32 i; + + for ( i = 0; i < MAX_MSGS_BLOCKED_FOR_XMIT; i++ ) + { + if ( msg.hdr.msgID == blockedMessagesForXmit.blockedMessages[ i ] ) + { + blocked = TRUE; + break; + } + } + } + // If transmission of this message is blocked, don't serialize/queue message + if ( blocked != TRUE ) { - // Thread protect next sequence # access & increment - _disable_IRQ(); - msg.hdr.seqNo = nextSeqNo; - nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); - _enable_IRQ(); - if ( TRUE == ackReq ) + // Prefix data with message sync byte + data[ msgSize++ ] = MESSAGE_SYNC_BYTE; + + // Set sequence # and ACK bit (unless this is an ACK to a received message) + if ( msg.hdr.msgID != MSG_ID_ACK_MESSAGE_THAT_REQUIRES_ACK ) { - msg.hdr.seqNo *= -1; + // Thread protect next sequence # access & increment + _disable_IRQ(); + msg.hdr.seqNo = nextSeqNo; + nextSeqNo = INC_WRAP( nextSeqNo, MIN_MSG_SEQ_NO, MAX_MSG_SEQ_NO ); + _enable_IRQ(); + if ( TRUE == ackReq ) + { + msg.hdr.seqNo *= -1; + } } - } - // Calculate message CRC - crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); + // Calculate message CRC + crc = crc8( (U08*)(&msg), sizeof( MESSAGE_HEADER_T ) + msg.hdr.payloadLen ); - // Serialize message header data - memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); - msgSize += sizeof( MESSAGE_HEADER_T ); + // Serialize message header data + memcpy( &data[ msgSize ], &( msg.hdr ), sizeof( MESSAGE_HEADER_T ) ); + msgSize += sizeof( MESSAGE_HEADER_T ); - // Serialize message payload (only used bytes per payloadLen field) - memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); - msgSize += msg.hdr.payloadLen; + // Serialize message payload (only used bytes per payloadLen field) + memcpy( &data[ msgSize ], &( msg.payload ), msg.hdr.payloadLen ); + msgSize += msg.hdr.payloadLen; - // Add 8-bit CRC - data[ msgSize++ ] = crc; + // Add 8-bit CRC + data[ msgSize++ ] = crc; - // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) - sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; - sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); - for ( i = 0; i < sizePad; i++ ) - { - data[ msgSize++ ] = 0; - } + // Pad with zero bytes to get length a multiple of CAN_MESSAGE_PAYLOAD_SIZE (8) + sizeMod = msgSize % CAN_MESSAGE_PAYLOAD_SIZE; + sizePad = ( sizeMod == 0 ? 0 : CAN_MESSAGE_PAYLOAD_SIZE - sizeMod ); + for ( i = 0; i < sizePad; i++ ) + { + data[ msgSize++ ] = 0; + } -#ifndef DISABLE_ACK_ERRORS - // If ACK required, add to pending ACK list - if ( TRUE == ackReq ) - { - if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + #ifndef DISABLE_ACK_ERRORS + // If ACK required, add to pending ACK list + if ( TRUE == ackReq ) { - error = TRUE; - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + if ( FALSE == addMsgToPendingACKList( &msg, buffer, data, msgSize ) ) + { + error = TRUE; + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_MSG_PENDING_ACK_LIST_FULL ) + } } - } -#endif + #endif - if ( FALSE == error ) - { - // Add serialized message data to appropriate out-going comm buffer - result = addToCommBuffer( buffer, data, msgSize ); - } + if ( FALSE == error ) + { + // Add serialized message data to appropriate out-going comm buffer + result = addToCommBuffer( buffer, data, msgSize ); + } + } + else + { + result = TRUE; // If message blocked, return successful transmission + } return result; } @@ -7493,6 +7528,33 @@ /*********************************************************************//** * @brief + * The handleTestBlockMessagesRequest function handles a request to + * block transmission of specific message(s). + * @details Inputs: none + * @details Outputs: message handled + * @param message : a pointer to the message to handle + * @return none + *************************************************************************/ +void handleTestBlockMessagesRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + + // Verify payload length + if ( sizeof(BLOCKED_MSGS_DATA_T) == message->hdr.payloadLen ) + { + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + memcpy( &blockedMessagesForXmit.blockedMessages[0], message->payload, sizeof(BLOCKED_MSGS_DATA_T) ); + } + } + + // Respond to request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + +/*********************************************************************//** + * @brief * The handleTestAlarmAudioVolumeOverrideRequest function handles a * request to override the alarm audio volume level. * @details Inputs: none Index: firmware/App/Services/SystemCommMessages.h =================================================================== diff -u -r730ae95f8c4a298e1fec8b8b34064a1fbb76a7f2 -r61222dea4dcdad959cf343b65a6f92216b252f30 --- firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 730ae95f8c4a298e1fec8b8b34064a1fbb76a7f2) +++ firmware/App/Services/SystemCommMessages.h (.../SystemCommMessages.h) (revision 61222dea4dcdad959cf343b65a6f92216b252f30) @@ -862,6 +862,10 @@ // MSG_ID_HD_FANS_RPM_OVERRIDE void handleFansRPMOverride( MESSAGE_T *message ); +// MSG_ID_HD_BLOCK_MESSAGE_TRANSMISSION +void handleTestBlockMessagesRequest( MESSAGE_T *message ); + + /**@}*/ #endif