Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -re47489aaf3c818c6f438434ff6b2cf1cafc4210c -r9e5e0295b749e0cfb6017338fea63e6e4086e57b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision e47489aaf3c818c6f438434ff6b2cf1cafc4210c) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9e5e0295b749e0cfb6017338fea63e6e4086e57b) @@ -88,18 +88,34 @@ } FS_OVERRIDE_PAYLOAD_T; #pragma pack(pop) +typedef BOOL (*OverrideFuncPtr)( TEST_OVERRIDE_PAYLOAD_T ); + // ********** private data ********** static BOOL testerLoggedIn = FALSE; ///< Flag indicates whether tester logged in or not. static volatile U16 nextSeqNo = 1; ///< Next sequence number. /// 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 }; + +/// Override command handling function lookup table +static const U16 OVERRIDE_CMD_FUNCTION_HANDLER_LOOKUP[3][2] = { + { MSG_ID_TEMPERATURE_SENSORS_PUBLISH_INTERVAL_OVERRIDE, 0 }, + { MSG_ID_HEATERS_PUBLISH_INTERVAL_ORVERRIDE, 1 }, + { MSG_ID_LOAD_CELL_SEND_INTERVAL_OVERRIDE, 2 } +}; +/// Override command handling function table +static const OverrideFuncPtr OVERRIDE_CMD_FUNCTION_HANDLERS[3] = { + &testTemperatureSensorsPublishIntervalOverride, + &testHeatersPublishIntervalOverride, + &testLoadCellDataPublishIntervalOverride +}; // ********** private function prototypes ********** static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ); static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ); static BOOL sendUIResponseMsg( MSG_ID_T msgID, UI_RESPONSE_PAYLOAD_T *uiResponse ); +static OverrideFuncPtr getOverrideCmdHandler( U16 msgID ); /*********************************************************************//** * @brief @@ -2186,6 +2202,61 @@ sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); } + + + + +static OverrideFuncPtr getOverrideCmdHandler( U16 msgID ) +{ + U32 i; + OverrideFuncPtr func = 0; + + // Search for the index associated with the given override command message ID and then use index to get the handling function + for ( i = 0; i < 3; i++ ) + { + if ( OVERRIDE_CMD_FUNCTION_HANDLER_LOOKUP[i][0] == msgID ) + { + func = OVERRIDE_CMD_FUNCTION_HANDLERS[i]; + break; + } + } + + return func; +} + +void handleTestOverrideCommand( MESSAGE_T *message ) +{ + TEST_OVERRIDE_PAYLOAD_T payload; + BOOL result = FALSE; // assume we will NAK until we have successful handling of message + + // verify Dialin user is logged in + if ( TRUE == isTestingActivated() ) + { + // verify payload length + if ( sizeof( TEST_OVERRIDE_PAYLOAD_T ) == message->hdr.payloadLen ) + { + OverrideFuncPtr ovFuncPtr; + + // Copy message payload to local override record + memcpy( &payload, message->payload, sizeof( TEST_OVERRIDE_PAYLOAD_T ) ); + // Find the appropriate override command handling function to call + ovFuncPtr = getOverrideCmdHandler( message->hdr.msgID ); + // Ensure a handler is found before calling it + if ( ovFuncPtr != 0 ) + { // Call the appropriate override command handling function with the given override parameters + result = (*ovFuncPtr)( payload ); + } + } + } + + // ACK/NAK request + sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); +} + + + + + /*********************************************************************//** * @brief * The handleTestTemperatureSensorsDataPublishOverrideRequest function handles @@ -2196,7 +2267,7 @@ * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestTemperatureSensorsDataPublishOverrideRequest( MESSAGE_T *message ) +/*void handleTestTemperatureSensorsDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -2217,7 +2288,7 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} +}*/ /*********************************************************************//** * @brief @@ -2228,7 +2299,7 @@ * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestHeatersDataPublishOverrideRequest( MESSAGE_T *message ) +/*void handleTestHeatersDataPublishOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -2249,7 +2320,7 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} +}*/ /*********************************************************************//** * @brief @@ -2260,7 +2331,7 @@ * @param message a pointer to the message to handle * @return none *************************************************************************/ -void handleTestLoadCellDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) +/*void handleTestLoadCellDataBroadcastIntervalOverrideRequest( MESSAGE_T *message ) { TEST_OVERRIDE_PAYLOAD_T payload; BOOL result = FALSE; @@ -2281,7 +2352,7 @@ // respond to request sendTestAckResponseMsg( (MSG_ID_T)message->hdr.msgID, result ); -} +}*/ /*********************************************************************//** * @brief