]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Updated CanTp and DcmDsl.
authorpete <devnull@localhost>
Thu, 15 Apr 2010 12:10:27 +0000 (14:10 +0200)
committerpete <devnull@localhost>
Thu, 15 Apr 2010 12:10:27 +0000 (14:10 +0200)
communication/CanTp/CanTp.c
diagnostic/Dcm/Dcm_Dsl.c

index 7cf5df5b46634b5aab726caafc405456b9e50254..2672843dbc2cab397b546b0d2c23dbc91687bba9 100644 (file)
@@ -5,7 +5,7 @@
  *\r
  * This source code is free software; you can redistribute it and/or modify it\r
  * under the terms of the GNU General Public License version 2 as published by the\r
- * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
+ * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.                                           \r
  *\r
  * This program is distributed in the hope that it will be useful, but\r
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
@@ -890,6 +890,7 @@ static INLINE void handleFirstFrame(const CanTp_RxNSduType *rxConfig,
                return;\r
        }\r
 \r
+       rxRuntime->iso15765.framesHandledCount++; // First expected is one (1) according to Movimento Puma.\r
        rxRuntime->iso15765.state = SF_OR_FF_RECEIVED_WAITING_PDUR_BUFFER;\r
        rxRuntime->mode = CANTP_RX_PROCESSING;\r
        rxRuntime->iso15765.stateTimeoutCount =\r
@@ -1066,6 +1067,7 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
                                txRuntime->mode = CANTP_TX_WAIT;\r
                                break;\r
                        case FIRST_FRAME:\r
+                               txRuntime->iso15765.stateTimeoutCount = CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNbs * 1000);  /*CanTp: 264*/\r
                                txRuntime->iso15765.state = TX_WAIT_FLOW_CONTROL;\r
                                res = sendFirstFrame(txConfig, txRuntime); /* req: CanTp 232 */\r
                                if (res == E_OK) {\r
@@ -1237,27 +1239,29 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        case SINGLE_FRAME: {\r
                if (rxConfigParams != NULL)\r
                        handleSingleFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
-    else\r
-      DEBUG( DEBUG_LOW, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
+               else\r
+                       DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
                break;\r
        }\r
        case FIRST_FRAME: {\r
                if (rxConfigParams != NULL)\r
                        handleFirstFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
-    else\r
-      DEBUG( DEBUG_LOW, "First frame received on ISO15765-Tx flow control - is ignored!\n");\r
+               else\r
+                       DEBUG( DEBUG_MEDIUM, "First frame received on ISO15765-Tx flow control - is ignored!\n");\r
                break;\r
        }\r
        case CONSECUTIVE_FRAME: {\r
                if (rxConfigParams != NULL)\r
                        handleConsecutiveFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
-    else\r
-      DEBUG( DEBUG_LOW, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
+               else\r
+                       DEBUG( DEBUG_MEDIUM, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
                break;\r
        }\r
        case FLOW_CONTROL_CTS_FRAME: {\r
                if (txConfigParams != NULL)\r
                        handleFlowControlFrame(txConfigParams, runtimeParams, CanTpRxPduPtr);\r
+               else\r
+                       DEBUG( DEBUG_MEDIUM, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
                break;\r
        }\r
        case INVALID_FRAME: {\r
@@ -1338,7 +1342,7 @@ static inline boolean checkNasNarTimeout(CanTp_ChannelPrivateType *runtimeData)
 \r
 void CanTp_MainFunction() /** req : CanTp213 **/\r
 {\r
-       BufReq_ReturnType ret;\r
+  BufReq_ReturnType ret;\r
        CanTpFifoQueueItem item;\r
        PduLengthType bytesWrittenToSduRBuffer;\r
 \r
@@ -1407,9 +1411,12 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                                }\r
                                break;\r
                        case TX_WAIT_FLOW_CONTROL:\r
-                               if (txRuntimeListItem->iso15765.stateTimeoutCount == 0)\r
+                               if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
+                                       DEBUG( DEBUG_MEDIUM, "State TX_WAIT_FLOW_CONTROL timed out!\n");\r
                                        PduR_CanTpTxConfirmation(txConfigListItem->PduR_CanTpTxPduId,\r
                                                        NTFRSLT_NOT_OK); /* qqq: req: CanTp: 185. */\r
+                                       txRuntimeListItem->iso15765.state = IDLE;\r
+                               }\r
                                break;\r
                        default:\r
                                break;\r
index df0b4bea3ebecb8c479d330cc9a4798693ef2f56..ef6b781904e3f8304a4650cea6d63ddaa8e9075d 100644 (file)
@@ -80,34 +80,6 @@ void ComM_DCM_InactivateDiagnostic() {
        ;\r
 }\r
 \r
-void _DsdDslDataIndication(const PduInfoType *pduRxData,\r
-               const Dcm_DsdServiceTableType *protocolSIDTable,\r
-               Dcm_ProtocolAddrTypeType addrType,\r
-               PduIdType rxPduIdRef,\r
-               PduInfoType *pduTxData) {\r
-       DEBUG( DEBUG_MEDIUM, "_DsdDslDataIndication called!\n");\r
-\r
-       DEBUG( DEBUG_MEDIUM, "pduRxData->SduLength = %d\n", pduRxData->SduLength );\r
-       for (int i=0; i < pduRxData->SduLength; i++) {\r
-               DEBUG( DEBUG_MEDIUM, "Data[%d] = %02x\n", i, pduRxData->SduDataPtr[i] );\r
-       }\r
-\r
-       uint8 *p;\r
-\r
-       pduTxData->SduLength = 5;\r
-       p = pduTxData->SduDataPtr;\r
-\r
-\r
-       for (int i=0; i<pduTxData->SduLength; i++) {\r
-               *p = i;\r
-               p++;\r
-       }\r
-\r
-       // Simulate a diagnostic response.\r
-       DslDsdProcessingDone(rxPduIdRef, DSD_TX_RESPONSE_READY);\r
-\r
-}\r
-\r
 // ################# HELPER FUNCTIONS START #################\r
 \r
 //\r
@@ -134,6 +106,48 @@ void stopS3SessionTimer(Dcm_DslRunTimeProtocolParametersType *runtime) {
 \r
 // - - - - - - - - - - -\r
 \r
+#if 1\r
+//\r
+//     This function implements the requirement @DCM139 when\r
+//     transition from one session to another.\r
+//     qqq, strange observation: If S3 timeout we will not change security mode to\r
+//     locked and that is how I interper the requirement.\r
+//\r
+void changeDiagnosticSession( Dcm_DslRunTimeProtocolParametersType *runtime,\r
+       Dcm_SesCtrlType newSession) {\r
+       switch (runtime->sessionControl) {\r
+       case DCM_DEFAULT_SESSION: // "default".\r
+               break;\r
+\r
+       case DCM_PROGRAMMING_SESSION:\r
+       case DCM_EXTENDED_DIAGNOSTIC_SESSION:\r
+       case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:\r
+       case DCM_ALL_SESSION_LEVEL:\r
+               runtime->securityLevel = DCM_SEC_LEV_LOCKED; // "0x00".\r
+               break;\r
+\r
+       default:\r
+               // TODO: Log this error.\r
+               DEBUG(DEBUG_MEDIUM, "Old session invalid")\r
+               break;\r
+       }\r
+\r
+       switch (newSession) {\r
+       case DCM_DEFAULT_SESSION: // "default".\r
+       case DCM_PROGRAMMING_SESSION:\r
+       case DCM_EXTENDED_DIAGNOSTIC_SESSION:\r
+       case DCM_SAFTEY_SYSTEM_DIAGNOSTIC_SESSION:\r
+       case DCM_ALL_SESSION_LEVEL:\r
+               runtime->sessionControl = newSession;\r
+               break;\r
+\r
+       default:\r
+               // TODO: Log this error.\r
+               DEBUG(DEBUG_MEDIUM, "New session invalid")\r
+               break;\r
+       }\r
+}\r
+#else\r
 //\r
 //     This function implements the requirement @DCM139 when\r
 //     transition from one session to another.\r
@@ -163,7 +177,7 @@ void changeDiagnosticSession( Dcm_DslRunTimeProtocolParametersType *runtime,
                break;\r
        }\r
 }\r
-\r
+#endif\r
 \r
 // - - - - - - - - - - -\r
 \r
@@ -316,6 +330,7 @@ void DslDsdProcessingDone(PduIdType rxPduIdRef, DsdProcessingDoneResultType resp
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
 \r
        DEBUG( DEBUG_MEDIUM, "DslDsdProcessingDone!\n");\r
+\r
        if (findParentConfigurationLeafs(rxPduIdRef, &protocolRx, &mainConnection,\r
                        &connection, &protocolRow, &runtime)) {\r
                imask_t state = McuE_EnterCriticalSection();\r
@@ -471,15 +486,17 @@ void DslMain(void) {
                                if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
                                        const uint32 txPduId =\r
                                                        protocolRowEntry->DslConnection->DslMainConnection->DslProtocolTx->PduR_DcmDslTxPduId;\r
+                                       DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.", txPduId);\r
                                        runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
+                                       DEBUG( DEBUG_MEDIUM, "Calling PduR_DcmTransmit with txPduId = %d\n", txPduId);\r
                                        PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 **//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */\r
                                }\r
                                break;\r
                        case DCM_TRANSMIT_SIGNALED:\r
-                               DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
+                               //DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
                                break;\r
                        case PROVIDED_TO_PDUR: // The valid data is being transmitted by TP-layer.\r
-                               DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
+                               //DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
                                break;\r
                        default:\r
                                break;\r
@@ -506,7 +523,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
        const Dcm_DslProtocolRowType *protocolRow = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
 \r
-  DEBUG( DEBUG_MEDIUM, "DslProvideRxBufferToPdur called!\n");\r
+       DEBUG( DEBUG_MEDIUM, "DslProvideRxBufferToPdur called!\n");\r
        imask_t state = McuE_EnterCriticalSection();\r
        if (findParentConfigurationLeafs(dcmRxPduId, &protocolRx, &mainConnection,\r
                        &connection, &protocolRow, &runtime)) {\r
@@ -516,7 +533,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
                        if ((runtime->externalRxBufferStatus == NOT_IN_USE)\r
                                        && (externalRxBuffer->externalBufferRuntimeData->status\r
                                                        == BUFFER_AVAILABLE)) {\r
-        DEBUG( DEBUG_MEDIUM, "External buffer available!\n");\r
+                               DEBUG( DEBUG_MEDIUM, "External buffer available!\n");\r
                                // ### EXTERNAL BUFFER IS AVAILABLE; GRAB IT AND REMEBER THAT WE OWN IT! ###\r
                                externalRxBuffer->externalBufferRuntimeData->status\r
                                                = BUFFER_BUSY;\r
@@ -527,7 +544,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
                                runtime->externalRxBufferStatus = PROVIDED_TO_PDUR;\r
                                ret = BUFREQ_OK;\r
                        } else {\r
-        DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
+                               DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
                                if (runtime->externalRxBufferStatus == PROVIDED_TO_DSD) {\r
                                        // ### EXTERNAL BUFFER IS IN USE BY THE DSD, TRY TO USE LOCAL BUFFER! ###\r
                                        if (runtime->localRxBuffer.status == NOT_IN_USE) {\r
@@ -615,13 +632,11 @@ void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {
                                        McuE_ExitCriticalSection(state);\r
                                        runtime->diagnosticResponseFromDsd.SduDataPtr = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
                                        runtime->diagnosticResponseFromDsd.SduLength = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
-                                       _DsdDslDataIndication(\r
-                                                       //&protocolRow->DslProtocolRxBufferID->pduInfo,\r
+                                       DsdDslDataIndication(\r
                                                        &(runtime->diagnosticRequestFromTester),\r
                                                        protocolRow->DslProtocolSIDTable,\r
                                                        protocolRx->DslProtocolAddrType,\r
                                                        mainConnection->DslProtocolTx->PduR_DcmDslTxPduId,\r
-                                                       //&protocolRow->DslProtocolTxBufferID->pduInfo);\r
                                                        &(runtime->diagnosticResponseFromDsd));\r
                                     \r
                                }\r