]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Corrections in diagnostic communication.
authorUlrikHagstrom <ulrik.hagstrom@movimento.se>
Fri, 16 Apr 2010 10:29:10 +0000 (12:29 +0200)
committerUlrikHagstrom <ulrik.hagstrom@movimento.se>
Fri, 16 Apr 2010 10:29:10 +0000 (12:29 +0200)
communication/CanTp/CanTp.c
diagnostic/Dcm/Dcm_Dsd.c
diagnostic/Dcm/Dcm_Dsl.c
diagnostic/Dcm/Dcm_Internal.h

index 2672843dbc2cab397b546b0d2c23dbc91687bba9..86bc099fc240bae35e792ebe1f0ce98c15cff7eb 100644 (file)
@@ -28,6 +28,7 @@
 #include "SchM_CanTp.h" /** req: CanTp156.4 **/\r
 //#include "MemMap.h" /** req: CanTp156.5 **/\r
 #include "String.h"\r
+#define USE_DEBUG_PRINTF\r
 #include "debug.h"\r
 \r
 #if  ( CANTP_DEV_ERROR_DETECT == STD_ON )\r
@@ -301,9 +302,11 @@ static inline ISO15765FrameType getFrameType(
 \r
        switch (*formatType) {\r
        case CANTP_STANDARD:\r
+               DEBUG( DEBUG_MEDIUM, "CANTP_STANDARD\n")\r
                tpci = CanTpRxPduPtr->SduDataPtr[0];\r
                break;\r
        case CANTP_EXTENDED:\r
+               DEBUG( DEBUG_MEDIUM, "CANTP_EXTENDED\n")\r
                tpci = CanTpRxPduPtr->SduDataPtr[1];\r
                break;\r
        default:\r
@@ -701,7 +704,9 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
                        } else if (pdurResp == BUFREQ_BUSY) {\r
                                ret = E_OK; // We will remain in this state, called again later, not data lost/destoryed?\r
                        } else {\r
+                               DEBUG( DEBUG_MEDIUM, "sendConsecutiveFrame failed, no buffer provided!\n");\r
                                ret = E_NOT_OK; // Serious malfunction, function caller should cancel this transfer.\r
+                               break;\r
                        }\r
                }\r
        }\r
@@ -1117,7 +1122,13 @@ Std_ReturnType CanTp_Transmit(PduIdType CanTpTxSduId,
        VALIDATE( CanTpTxSduId < CANTP_NSDU_CONFIG_LIST_SIZE, SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TX_ID );\r
 \r
        txConfig = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[CanTpTxSduId].configData;\r
+\r
        txRuntime = &CanTpRunTimeData.runtimeDataList[txConfig->CanTpTxChannel]; // Runtime data.\r
+       txRuntime->pdurBufferCount = 0;\r
+       txRuntime->pdurBufferCount = 0;\r
+       txRuntime->pduTransferedBytesCount = 0;\r
+       txRuntime->iso15765.framesHandledCount = 0;\r
+       //txRuntime->iso15765->framesHandledCount = 0;\r
        txRuntime->pduLenghtTotalBytes = CanTpTxInfoPtr->SduLength;\r
        txRuntime->iso15765.stateTimeoutCount =\r
                        CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNcs);\r
@@ -1193,11 +1204,14 @@ void CanTp_RxIndication(PduIdType CanTpRxPduId,
        VALIDATE_NO_RV( CanTpRunTimeData.internalState == CANTP_ON,\r
                        SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_UNINIT ); /* req: CanTp031 */\r
 \r
+       DEBUG( DEBUG_MEDIUM, "CanTp_RxIndication: PduId=%d, [", CanTpRxPduId);\r
        item.PduId = CanTpRxPduId;\r
        item.SduLength = CanTpRxPduPtr->SduLength;\r
        for (int i=0; i<item.SduLength; i++) {\r
                item.SduData[i] = CanTpRxPduPtr->SduDataPtr[i];\r
+               DEBUG( DEBUG_MEDIUM, "%x, ", item.SduData[i]);\r
        }\r
+       DEBUG( DEBUG_MEDIUM, "]");\r
        if ( fifoQueueWrite( &CanTpRunTimeData.fifo, &item ) == FALSE ) {\r
                ; //qqq: TODO: Report overrun.\r
        }\r
@@ -1214,7 +1228,8 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        CanTp_ChannelPrivateType *runtimeParams; // Params reside in RAM.\r
        ISO15765FrameType frameType;\r
 \r
-       DEBUG( DEBUG_MEDIUM, "CanTp_RxIndication_Main, polite index: %d!\n", CanTpRxPduId );\r
+       DEBUG( DEBUG_MEDIUM, "CanTp_RxIndication - CanTpRxPduId: %x!\n", CanTpRxPduId );\r
+\r
 \r
        VALIDATE_NO_RV( CanTpRunTimeData.internalState == CANTP_ON,\r
                        SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_UNINIT ); /* req: CanTp031 */\r
@@ -1237,35 +1252,40 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        frameType = getFrameType(addressingFormat, CanTpRxPduPtr);\r
        switch (frameType) {\r
        case SINGLE_FRAME: {\r
-               if (rxConfigParams != NULL)\r
+               if (rxConfigParams != NULL) {\r
+                       DEBUG( DEBUG_MEDIUM, "calling handleSingleFrame!\n");\r
                        handleSingleFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
+               }\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
+               if (rxConfigParams != NULL) {\r
+                       DEBUG( DEBUG_MEDIUM, "calling handleFirstFrame!\n");\r
                        handleFirstFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
-               else\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
+               if (rxConfigParams != NULL) {\r
+                       DEBUG( DEBUG_MEDIUM, "calling handleConsecutiveFrame!\n");\r
                        handleConsecutiveFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
-               else\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
+               if (txConfigParams != NULL) {\r
+                       DEBUG( DEBUG_MEDIUM, "calling handleFlowControlFrame!\n");\r
                        handleFlowControlFrame(txConfigParams, runtimeParams, CanTpRxPduPtr);\r
-               else\r
-                       DEBUG( DEBUG_MEDIUM, "Consecutive frame received on ISO15765-Tx flow control - is ignored!\n");\r
+               else\r
+                       DEBUG( DEBUG_MEDIUM, "Flow control frame received on ISO15765-RX flow control - is ignored!\n");\r
                break;\r
        }\r
        case INVALID_FRAME: {\r
-               return; // qqq: Failure, should go to log-file.\r
+               DEBUG( DEBUG_MEDIUM, "INVALID_FRAME recived, doing nothing!!\n");\r
                break;\r
        }\r
        default:\r
index e44efbd8ff50b2a63d4c3456d18b3dafe4ab4b72..7041d87c06bbbbe75acb29ba500c72b0b93aa32a 100644 (file)
@@ -28,6 +28,7 @@ typedef struct {
        const Dcm_DsdServiceTableType   *serviceTable;\r
        Dcm_ProtocolAddrTypeType                addrType;\r
        PduIdType                                               txPduId;\r
+       PduIdType                                               rxPduId;\r
 } MsgDataType;\r
 \r
 // In "queue" to DSD\r
@@ -162,10 +163,10 @@ void DsdCreateAndSendNcr(Dcm_NegativeResponseCodeType responseCode)
                msgData.pduTxData->SduDataPtr[1] = currentSid;\r
                msgData.pduTxData->SduDataPtr[2] = responseCode;\r
                msgData.pduTxData->SduLength = 3;\r
-               DslDsdProcessingDone(msgData.txPduId, DSD_TX_RESPONSE_READY);   /** @req DCM114 **/ /** @req DCM232.1 **/\r
+               DslDsdProcessingDone(msgData.rxPduId, DSD_TX_RESPONSE_READY);   /** @req DCM114 **/ /** @req DCM232.1 **/\r
        }\r
        else {\r
-               DslDsdProcessingDone(msgData.txPduId, DSD_TX_RESPONSE_SUPPRESSED);\r
+               DslDsdProcessingDone(msgData.rxPduId, DSD_TX_RESPONSE_SUPPRESSED);\r
        }\r
 }\r
 \r
@@ -232,11 +233,11 @@ void DsdDspProcessingDone(Dcm_NegativeResponseCodeType responseCode)
                if (!suppressPosRspMsg) {       /** @req DCM200 **/ /** @req DCM231 **/\r
                        /** @req DCM222 **/\r
                        msgData.pduTxData->SduDataPtr[0] = currentSid | SID_RESPONSE_BIT;       /** @req DCM223 **/ /** @req DCM224 **/\r
-                       DslDsdProcessingDone(msgData.txPduId, DSD_TX_RESPONSE_READY);   /** @req DCM114 **/ /** @req DCM225 **/ /** @req DCM232.2 **/\r
+                       DslDsdProcessingDone(msgData.rxPduId, DSD_TX_RESPONSE_READY);   /** @req DCM114 **/ /** @req DCM225 **/ /** @req DCM232.2 **/\r
                }\r
                else {\r
                        DspDcmConfirmation(msgData.txPduId);    /** @req DCM236 **/ /** @req DCM240 **/\r
-                       DslDsdProcessingDone(msgData.txPduId, DSD_TX_RESPONSE_SUPPRESSED);\r
+                       DslDsdProcessingDone(msgData.rxPduId, DSD_TX_RESPONSE_SUPPRESSED);\r
                }\r
        }\r
        else {\r
@@ -252,8 +253,9 @@ void DsdDataConfirmation(PduIdType confirmPduId, NotifResultType result)
 }\r
 \r
 \r
-void DsdDslDataIndication(const PduInfoType *pduRxData, const Dcm_DsdServiceTableType *protocolSIDTable, Dcm_ProtocolAddrTypeType addrType, PduIdType txPduId, PduInfoType *pduTxData)\r
+void DsdDslDataIndication(const PduInfoType *pduRxData, const Dcm_DsdServiceTableType *protocolSIDTable, Dcm_ProtocolAddrTypeType addrType, PduIdType txPduId, PduInfoType *pduTxData, PduIdType rxContextPduId)\r
 {\r
+       msgData.rxPduId = rxContextPduId;\r
        msgData.txPduId = txPduId;\r
        msgData.pduRxData = pduRxData;\r
        msgData.pduTxData = pduTxData;\r
index ef6b781904e3f8304a4650cea6d63ddaa8e9075d..23dcea3551c503ce8324b40e6b6f80716ea75b98 100644 (file)
@@ -24,6 +24,8 @@
 #include "ComM_Dcm.h"\r
 #include "PduR_Dcm.h"\r
 #include "ComStack_Types.h"\r
+\r
+#define USE_DEBUG_PRINTF\r
 #include "debug.h"\r
 \r
 #define TIMER_DECREMENT(timer) \\r
@@ -437,6 +439,7 @@ void DslMain(void) {
        const Dcm_DslProtocolRowType *protocolRowEntry = NULL;\r
        const Dcm_DslProtocolTimingRowType *timeParams = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
+       int debug_count = 0;\r
 \r
        protocolRowEntry = DCM_Config.Dsl->DslProtocol->DslProtocolRowList;\r
        while (protocolRowEntry->Arc_EOL == FALSE) {\r
@@ -454,6 +457,7 @@ void DslMain(void) {
                                break;\r
                        case PROVIDED_TO_DSD:\r
                        {\r
+                               DEBUG( DEBUG_MEDIUM, "debug_count=%d\n", debug_count);\r
                                TIMER_DECREMENT(runtime->stateTimeoutCount);\r
                                DEBUG( DEBUG_MEDIUM, "state PROVIDED_TO_DSD!\n");\r
                                if (runtime->stateTimeoutCount == 0) {\r
@@ -482,6 +486,7 @@ void DslMain(void) {
                                // Make sure that response pending or general reject have not been issued,\r
                                // if so we can not transmit to PduR because we would not know from where\r
                                // the Tx confirmation resides later.\r
+                               DEBUG( DEBUG_MEDIUM, "debug_count=%d\n", debug_count);\r
                                DEBUG( DEBUG_MEDIUM, "state DSD_PENDING_RESPONSE_SIGNALED!\n");\r
                                if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
                                        const uint32 txPduId =\r
@@ -503,6 +508,7 @@ void DslMain(void) {
                        }\r
                }\r
                protocolRowEntry++;\r
+               debug_count++;\r
        }\r
 }\r
 \r
@@ -637,7 +643,8 @@ void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {
                                                        protocolRow->DslProtocolSIDTable,\r
                                                        protocolRx->DslProtocolAddrType,\r
                                                        mainConnection->DslProtocolTx->PduR_DcmDslTxPduId,\r
-                                                       &(runtime->diagnosticResponseFromDsd));\r
+                                                       &(runtime->diagnosticResponseFromDsd),\r
+                                                       dcmRxPduId);\r
                                     \r
                                }\r
                        }\r
@@ -750,7 +757,7 @@ void DslTxConfirmation(PduIdType dcmTxPduId, NotifResultType result) {
 */\r
                        DEBUG( DEBUG_MEDIUM, "Released external buffer sucessfully!\n");\r
                        externalBufferReleased = TRUE;\r
-                       DsdDataConfirmation(dcmTxPduId, result); /** @req DCM117 **//** @req DCM235 **/\r
+                       DsdDataConfirmation(mainConnection->DslProtocolTx->PduR_DcmDslTxPduId, result); /** @req DCM117 **//** @req DCM235 **/\r
                        break;\r
                }\r
                default:\r
index 0689701b572e708e245f4639117a52269e087b2a..a9a53d781fed915cc145d46a359273c783ea9dde 100644 (file)
@@ -81,7 +81,7 @@ void DsdMain(void);
 void DsdHandleRequest(void);\r
 void DsdDspProcessingDone(Dcm_NegativeResponseCodeType responseCode);\r
 void DsdDataConfirmation(PduIdType confirmPduId, NotifResultType result);\r
-void DsdDslDataIndication(const PduInfoType *pduRxData, const Dcm_DsdServiceTableType *protocolSIDTable, Dcm_ProtocolAddrTypeType addrType, PduIdType txPduId, PduInfoType *pduTxData);\r
+void DsdDslDataIndication(const PduInfoType *pduRxData, const Dcm_DsdServiceTableType *protocolSIDTable, Dcm_ProtocolAddrTypeType addrType, PduIdType txPduId, PduInfoType *pduTxData, PduIdType rxContextPduId);\r
 \r
 \r
 /*\r