]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Added support for STmin and improved readability and requirement tags. Added requirem...
authorUlrikHagstrom <ulrik.hagstrom@movimento.se>
Wed, 28 Apr 2010 07:42:46 +0000 (09:42 +0200)
committerUlrikHagstrom <ulrik.hagstrom@movimento.se>
Wed, 28 Apr 2010 07:42:46 +0000 (09:42 +0200)
communication/CanTp/CanTp.c
diagnostic/Dcm/Dcm_Dsl.c
include/CanTp.h
include/CanTp_Types.h

index 582f6770062841d74c175ac79826fe9e8299d60a..722a3f5f90bfeda47850ac020631bac9eaa2baa9 100644 (file)
@@ -196,10 +196,10 @@ typedef struct {
  */\r
 typedef struct {\r
        ISO15765TransferControlType iso15765;\r
-       PduInfoType *bufferPduRouter; // The PDUR make an instance of this.\r
+       PduInfoType *pdurBuffer; // The PDUR make an instance of this.\r
        PduLengthType pdurBufferCount; // Number of bytes in PDUR buffer.\r
-       PduLengthType pduLenghtTotalBytes; // Total length of the PDU.\r
-       PduLengthType pduTransferedBytesCount; // Counter ongoing transfer.\r
+       PduLengthType transferTotal; // Total length of the PDU.\r
+       PduLengthType transferCount; // Counter ongoing transfer.\r
        CanIfSduType canFrameBuffer; // Temp storage of SDU data.\r
        CanTp_TransferInstanceMode mode; // CanTp030.\r
 } CanTp_ChannelPrivateType;\r
@@ -396,10 +396,10 @@ void initRx15765RuntimeData(const CanTp_RxNSduType *rxConfigParams,
        rxRuntimeParams->iso15765.framesHandledCount = 0;\r
        rxRuntimeParams->iso15765.nextFlowControlCount = 0;\r
        rxRuntimeParams->pdurBufferCount = 0;\r
-       rxRuntimeParams->pduLenghtTotalBytes = 0;\r
-       rxRuntimeParams->pduTransferedBytesCount = 0;\r
+       rxRuntimeParams->transferTotal = 0;\r
+       rxRuntimeParams->transferCount = 0;\r
        rxRuntimeParams->mode = CANTP_RX_WAIT; /** @req CANTP030 */\r
-       rxRuntimeParams->bufferPduRouter = NULL;\r
+       rxRuntimeParams->pdurBuffer = NULL;\r
 }\r
 \r
 // - - - - - - - - - - - - - -\r
@@ -412,10 +412,10 @@ void initTx15765RuntimeData(const CanTp_TxNSduType *txConfigParams,
        txRuntimeParams->iso15765.framesHandledCount = 0;\r
        txRuntimeParams->iso15765.nextFlowControlCount = 0;\r
        txRuntimeParams->pdurBufferCount = 0;\r
-       txRuntimeParams->pduLenghtTotalBytes = 0;\r
-       txRuntimeParams->pduTransferedBytesCount = 0;\r
+       txRuntimeParams->transferTotal = 0;\r
+       txRuntimeParams->transferCount = 0;\r
        txRuntimeParams->mode = CANTP_TX_WAIT; /** @req CANTP030 */\r
-       txRuntimeParams->bufferPduRouter = NULL;\r
+       txRuntimeParams->pdurBuffer = NULL;\r
 \r
 }\r
 \r
@@ -431,10 +431,10 @@ static INLINE BufReq_ReturnType copySegmentToPduRRxBuffer(const CanTp_RxNSduType
 \r
        while ((*bytesWrittenSuccessfully < segmentSize) && error == FALSE) {\r
                // Copy the data that resides in the buffer.\r
-               if (rxRuntime->bufferPduRouter != NULL) {\r
+               if (rxRuntime->pdurBuffer != NULL) {\r
                        while ((*bytesWrittenSuccessfully < segmentSize ) &&\r
-                                       (rxRuntime->bufferPduRouter->SduLength > rxRuntime->pdurBufferCount)) {\r
-                               rxRuntime->bufferPduRouter->SduDataPtr[rxRuntime->pdurBufferCount++]\r
+                                       (rxRuntime->pdurBuffer->SduLength > rxRuntime->pdurBufferCount)) {\r
+                               rxRuntime->pdurBuffer->SduDataPtr[rxRuntime->pdurBufferCount++]\r
                                                = segment[(*bytesWrittenSuccessfully)++];\r
                        }\r
                }\r
@@ -442,14 +442,14 @@ static INLINE BufReq_ReturnType copySegmentToPduRRxBuffer(const CanTp_RxNSduType
                        // We need to request a new buffer from the SDUR.\r
                        // qqq: TODO: We should do a timeout here.\r
                        ret = PduR_CanTpProvideRxBuffer(rxConfig->PduR_PduId,  /** @req CANTP079 */ /** @req CANTP080 */ /** @req CANTP064 */\r
-                                                       rxRuntime->pduLenghtTotalBytes,\r
-                                                       &rxRuntime->bufferPduRouter);\r
+                                                       rxRuntime->transferTotal,\r
+                                                       &rxRuntime->pdurBuffer);\r
                        if (ret == BUFREQ_OK) {\r
-                               VALIDATE( rxRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+                               VALIDATE( rxRuntime->pdurBuffer->SduDataPtr != NULL,\r
                                                SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_RX_BUFFER );\r
                                rxRuntime->pdurBufferCount = 0; // The buffer is emptied.\r
                        } else if (ret == BUFREQ_BUSY) {\r
-                               rxRuntime->pduTransferedBytesCount += *bytesWrittenSuccessfully;\r
+                               rxRuntime->transferCount += *bytesWrittenSuccessfully;\r
                                error = TRUE;\r
                                break;\r
                        } else {\r
@@ -457,7 +457,7 @@ static INLINE BufReq_ReturnType copySegmentToPduRRxBuffer(const CanTp_RxNSduType
                                break;\r
                        }\r
                } else {\r
-                       rxRuntime->pduTransferedBytesCount += segmentSize; //== bytesWrittenSuccessfully\r
+                       rxRuntime->transferCount += segmentSize; //== bytesWrittenSuccessfully\r
                        ret = BUFREQ_OK;\r
                        break;\r
                }\r
@@ -544,7 +544,7 @@ static INLINE void sendFlowControlFrame(const CanTp_RxNSduType *rxConfig,
        {\r
                sduData[indexCount++] = ISO15765_TPCI_FC\r
                                | ISO15765_FLOW_CONTROL_STATUS_CTS;\r
-               spaceFreePduRBuffer = rxRuntime->bufferPduRouter->SduLength -\r
+               spaceFreePduRBuffer = rxRuntime->pdurBuffer->SduLength -\r
                                rxRuntime->pdurBufferCount;\r
                if (rxConfig->CanTpAddressingFormant == CANTP_EXTENDED) { /** @req CANTP094 *//** @req CANTP095 */\r
                        computedBs = spaceFreePduRBuffer / MAX_PAYLOAD_SF_EXT_ADDR + 1;  // + 1 is for local buffer.\r
@@ -568,7 +568,7 @@ static INLINE void sendFlowControlFrame(const CanTp_RxNSduType *rxConfig,
                                | ISO15765_FLOW_CONTROL_STATUS_WAIT;\r
                pduInfo.SduLength = indexCount;\r
                break;\r
-       case BUFREQ_OVFL: //* qqq req: CanTp 081 */\r
+       case BUFREQ_OVFL: /** @req CANTP081 */\r
                sduData[indexCount++] = ISO15765_TPCI_FC\r
                                | ISO15765_FLOW_CONTROL_STATUS_OVFLW;\r
                pduInfo.SduLength = indexCount;\r
@@ -614,8 +614,8 @@ static INLINE void handleConsecutiveFrame(const CanTp_RxNSduType *rxConfig,
                rxRuntime->mode = CANTP_RX_WAIT;\r
        } else {\r
                currentSegmentMaxSize = CANIF_PDU_MAX_LENGTH - indexCount;\r
-               bytesLeftToCopy = rxRuntime->pduLenghtTotalBytes\r
-                               - rxRuntime->pduTransferedBytesCount;\r
+               bytesLeftToCopy = rxRuntime->transferTotal\r
+                               - rxRuntime->transferCount;\r
                if (bytesLeftToCopy < currentSegmentMaxSize) {\r
                        currentSegmentSize = bytesLeftToCopy; // 1-5.\r
                } else {\r
@@ -663,7 +663,7 @@ static INLINE void handleConsecutiveFrame(const CanTp_RxNSduType *rxConfig,
                                sendFlowControlFrame(rxConfig, rxRuntime, ret);  /** @req CANTP082 */\r
                        }\r
                } else if (ret == BUFREQ_OK) {\r
-                       bytesLeftToTransfer = rxRuntime->pduLenghtTotalBytes - rxRuntime->pduTransferedBytesCount;\r
+                       bytesLeftToTransfer = rxRuntime->transferTotal - rxRuntime->transferCount;\r
                        if (bytesLeftToTransfer > 0) {\r
                                rxRuntime->iso15765.framesHandledCount++;\r
                                COUNT_DECREMENT(rxRuntime->iso15765.nextFlowControlCount);\r
@@ -702,8 +702,8 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
        // Always copy from the PDUR buffer data to the canFrameBuffer because if\r
        // we are unlucky the application give us very small buffers.\r
        consecutiveFrameMaxPayload  = CANIF_PDU_MAX_LENGTH - indexCount;\r
-       remaningSduDataSize = txRuntime->pduLenghtTotalBytes\r
-                       - txRuntime->pduTransferedBytesCount;\r
+       remaningSduDataSize = txRuntime->transferTotal\r
+                       - txRuntime->transferCount;\r
 \r
        // Calculate number of valid bytes that reside in this CF.\r
        if ( remaningSduDataSize < consecutiveFrameMaxPayload  ) {\r
@@ -713,14 +713,14 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
        }\r
        copyCount = txRuntime->canFrameBuffer.byteCount; // maybe some bytes already reside in the buffer that we need to handle before proceeding with application buffer data.\r
        while (copyCount < consecutiveFrameActualPayload) {\r
-               if ( txRuntime->bufferPduRouter->SduLength > txRuntime->pdurBufferCount ) {\r
+               if ( txRuntime->pdurBuffer->SduLength > txRuntime->pdurBufferCount ) {\r
                        txRuntime->canFrameBuffer.data[copyCount] =\r
-                                       txRuntime->bufferPduRouter->SduDataPtr[txRuntime->pdurBufferCount++];\r
+                                       txRuntime->pdurBuffer->SduDataPtr[txRuntime->pdurBufferCount++];\r
                        copyCount++;\r
                        txRuntime->canFrameBuffer.byteCount++;\r
                } else {\r
                        BufReq_ReturnType pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId, /** @req CANTP226 */ /** @req CANTP086 */ /** @req CANTP117 */\r
-                                       &txRuntime->bufferPduRouter, 0);\r
+                                       &txRuntime->pdurBuffer, 0);\r
                        if (pdurResp == BUFREQ_OK) {\r
                                txRuntime->pdurBufferCount = 0;\r
                                continue;\r
@@ -746,9 +746,9 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
                        // the scenario where the CAN queue is full.\r
                        txRuntime->iso15765.framesHandledCount++;\r
                        COUNT_DECREMENT(txRuntime->iso15765.nextFlowControlCount);\r
-                       txRuntime->pduTransferedBytesCount += txRuntime->canFrameBuffer.byteCount;\r
+                       txRuntime->transferCount += txRuntime->canFrameBuffer.byteCount;\r
                        txRuntime->canFrameBuffer.byteCount = 0;\r
-                       DEBUG( DEBUG_MEDIUM, "pduTransferedBytesCount:%d\n", txRuntime->pduTransferedBytesCount);\r
+                       DEBUG( DEBUG_MEDIUM, "transferCount:%d\n", txRuntime->transferCount);\r
                }\r
        } else {\r
                DEBUG( DEBUG_MEDIUM, "Unexpected error, should not happen!\n");\r
@@ -762,7 +762,7 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
 static INLINE void handleConsecutiveFrameSent(\r
                const CanTp_TxNSduType *txConfig, CanTp_ChannelPrivateType *txRuntime) {\r
 \r
-       if (txRuntime->pduLenghtTotalBytes <= txRuntime->pduTransferedBytesCount) {\r
+       if (txRuntime->transferTotal <= txRuntime->transferCount) {\r
                // Transfer finished!\r
                txRuntime->iso15765.state = IDLE;\r
                txRuntime->mode = CANTP_TX_WAIT;\r
@@ -803,6 +803,7 @@ static INLINE void handleFlowControlFrame(const CanTp_TxNSduType *txConfig,
                txRuntime->iso15765.BS = txPduData->SduDataPtr[indexCount++];\r
                txRuntime->iso15765.nextFlowControlCount = txRuntime->iso15765.BS;\r
                txRuntime->iso15765.STmin = txPduData->SduDataPtr[indexCount++];\r
+               DEBUG( DEBUG_MEDIUM, "txRuntime->iso15765.STmin = %d\n", txRuntime->iso15765.STmin);\r
                ret = sendConsecutiveFrame(txConfig, txRuntime);\r
                if (ret == E_OK) {\r
                        handleConsecutiveFrameSent(txConfig, txRuntime);\r
@@ -836,7 +837,7 @@ static INLINE void handleSingleFrame(const CanTp_RxNSduType *rxConfig,
        uint8 *data = NULL;\r
        PduLengthType bytesWrittenToSduRBuffer;\r
 \r
-       DEBUG( DEBUG_MEDIUM, "handleSingleFrame called!\n");\r
+\r
        if (rxRuntime->iso15765.state != IDLE) {\r
                DEBUG( DEBUG_MEDIUM, "Single frame received and channel not IDLE!\n");\r
        }\r
@@ -844,7 +845,7 @@ static INLINE void handleSingleFrame(const CanTp_RxNSduType *rxConfig,
        pduLength = getPduLength(&rxConfig->CanTpAddressingFormant, SINGLE_FRAME,\r
                        rxPduData);\r
 \r
-       VALIDATE_NO_RV( rxRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+       VALIDATE_NO_RV( rxRuntime->pdurBuffer->SduDataPtr != NULL,\r
                        SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_INVALID_RX_LENGTH );\r
 \r
        if (rxConfig->CanTpAddressingFormant == CANTP_STANDARD) { /** @req CANTP094 *//** @req CANTP095 */\r
@@ -852,7 +853,7 @@ static INLINE void handleSingleFrame(const CanTp_RxNSduType *rxConfig,
        } else {\r
                data = &rxPduData->SduDataPtr[2];\r
        }\r
-       rxRuntime->pduLenghtTotalBytes = pduLength;\r
+       rxRuntime->transferTotal = pduLength;\r
        rxRuntime->iso15765.state = SF_OR_FF_RECEIVED_WAITING_PDUR_BUFFER;\r
        rxRuntime->mode = CANTP_RX_PROCESSING;\r
        rxRuntime->iso15765.stateTimeoutCount =\r
@@ -896,9 +897,9 @@ static INLINE void handleFirstFrame(const CanTp_RxNSduType *rxConfig,
        (void) initRx15765RuntimeData(rxConfig, rxRuntime); /** @req CANTP124 */\r
        pduLength = getPduLength(&rxConfig->CanTpAddressingFormant, FIRST_FRAME,\r
                        rxPduData);\r
-       rxRuntime->pduLenghtTotalBytes = pduLength;\r
+       rxRuntime->transferTotal = pduLength;\r
 \r
-       VALIDATE_NO_RV( rxRuntime->pduLenghtTotalBytes != 0,\r
+       VALIDATE_NO_RV( rxRuntime->transferTotal != 0,\r
                        SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_INVALID_RX_LENGTH );\r
 \r
        // Validate that that there is a reason for using the segmented transfers and\r
@@ -967,11 +968,11 @@ static INLINE Std_ReturnType calcRequiredProtocolFrameType(
 \r
        Std_ReturnType ret;\r
        if (txConfig->CanTpAddressingMode == CANTP_EXTENDED) {\r
-               if ( txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
+               if ( txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
                        VALIDATE( txConfig->CanTpTxTaType == CANTP_FUNCTIONAL,\r
                                        SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TATYPE );\r
                }\r
-               if (txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR) {\r
+               if (txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR) {\r
                        if (txConfig->CanTpTxTaType == CANTP_PHYSICAL) {\r
                                *iso15765Frame = FIRST_FRAME;\r
                                ret = E_OK;\r
@@ -984,11 +985,11 @@ static INLINE Std_ReturnType calcRequiredProtocolFrameType(
                        ret = E_OK;\r
                }\r
        } else {\r
-               if ( txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
+               if ( txRuntime->transferTotal > MAX_PAYLOAD_CF_EXT_ADDR ) {\r
                        VALIDATE( txConfig->CanTpTxTaType == CANTP_FUNCTIONAL,\r
                                        SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TATYPE );\r
                }\r
-               if (txRuntime->pduLenghtTotalBytes > MAX_PAYLOAD_CF_STD_ADDR) {\r
+               if (txRuntime->transferTotal > MAX_PAYLOAD_CF_STD_ADDR) {\r
                        if (txConfig->CanTpTxTaType == CANTP_PHYSICAL) {\r
                                *iso15765Frame = FIRST_FRAME;\r
                                ret = E_OK;\r
@@ -1018,9 +1019,9 @@ static INLINE Std_ReturnType sendSingleFrame(const CanTp_TxNSduType *txConfig,
        if (txConfig->CanTpAddressingMode == CANTP_EXTENDED) { /** @req CANTP094 *//** @req CANTP095 */\r
                sduData[indexCount++] = (uint8) txConfig->CanTpNTa->CanTpNTa; // Target address.\r
        }\r
-       sduData[indexCount++] = ISO15765_TPCI_SF | txRuntime->pduLenghtTotalBytes;\r
-       for (int i = 0; i < txRuntime->pduLenghtTotalBytes; i++) {\r
-               sduData[indexCount++] = txRuntime->bufferPduRouter->SduDataPtr[i];\r
+       sduData[indexCount++] = ISO15765_TPCI_SF | txRuntime->transferTotal;\r
+       for (int i = 0; i < txRuntime->transferTotal; i++) {\r
+               sduData[indexCount++] = txRuntime->pdurBuffer->SduDataPtr[i];\r
        }\r
 \r
        pduInfo.SduDataPtr = sduData;\r
@@ -1045,15 +1046,15 @@ static INLINE Std_ReturnType sendFirstFrame(const CanTp_TxNSduType *txConfig,
                sduData[indexCount++] = (uint8) txConfig->CanTpNTa->CanTpNTa; // Target address.\r
        }\r
        sduData[indexCount++] = ISO15765_TPCI_FF | (uint8)(\r
-                       (txRuntime->pduLenghtTotalBytes & 0xf00) >> 8);\r
-       sduData[indexCount++] = (uint8)(txRuntime->pduLenghtTotalBytes & 0xff);\r
+                       (txRuntime->transferTotal & 0xf00) >> 8);\r
+       sduData[indexCount++] = (uint8)(txRuntime->transferTotal & 0xff);\r
        for (i = 0; indexCount < CANIF_PDU_MAX_LENGTH; i++) {\r
-               sduData[indexCount++] = txRuntime->bufferPduRouter->SduDataPtr[i];\r
+               sduData[indexCount++] = txRuntime->pdurBuffer->SduDataPtr[i];\r
                txRuntime->pdurBufferCount++;\r
-               if (txRuntime->pdurBufferCount > txRuntime->bufferPduRouter->SduLength) {\r
+               if (txRuntime->pdurBufferCount > txRuntime->pdurBuffer->SduLength) {\r
                        // qqq: TODO: Report failure - this is unexpected.\r
                }\r
-               txRuntime->pduTransferedBytesCount++;\r
+               txRuntime->transferCount++;\r
        }\r
        pduInfo.SduDataPtr = sduData;\r
        pduInfo.SduLength = indexCount;\r
@@ -1071,9 +1072,9 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
        ISO15765FrameType iso15765Frame = INVALID_FRAME;\r
 \r
        pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId,\r
-                       &txRuntime->bufferPduRouter, 0);  /** @req CANTP226 */ /** @req CANTP186 */\r
+                       &txRuntime->pdurBuffer, 0);  /** @req CANTP226 */ /** @req CANTP186 */\r
        //if (txRuntime->iso15765.stateTimeoutCount != 0) {   qqq: WHY WAS THIS DONE?\r
-               VALIDATE( txRuntime->bufferPduRouter->SduDataPtr != NULL,\r
+               VALIDATE( txRuntime->pdurBuffer->SduDataPtr != NULL,\r
                                SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TX_BUFFER );\r
                if (pdurResp == BUFREQ_OK) {\r
                        res = calcRequiredProtocolFrameType(txConfig, txRuntime, &iso15765Frame);\r
@@ -1148,10 +1149,9 @@ Std_ReturnType CanTp_Transmit(PduIdType CanTpTxSduId,
        if (txRuntime->mode != CANTP_TX_PROCESSING) {\r
                txRuntime->pdurBufferCount = 0;\r
                txRuntime->pdurBufferCount = 0;\r
-               txRuntime->pduTransferedBytesCount = 0;\r
+               txRuntime->transferCount = 0;\r
                txRuntime->iso15765.framesHandledCount = 0;\r
-               //txRuntime->iso15765->framesHandledCount = 0;\r
-               txRuntime->pduLenghtTotalBytes = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
+               txRuntime->transferTotal = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
                txRuntime->iso15765.stateTimeoutCount =\r
                                CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNcs);\r
                txRuntime->mode = CANTP_TX_PROCESSING;\r
@@ -1280,7 +1280,7 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
                        handleSingleFrame(rxConfigParams, runtimeParams, CanTpRxPduPtr);\r
                }\r
                else\r
-                       DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ingnored!\n");\r
+                       DEBUG( DEBUG_MEDIUM, "Single frame received on ISO15765-Tx flow control - is ignored!\n");\r
                break;\r
        }\r
        case FIRST_FRAME: {\r
@@ -1356,7 +1356,7 @@ void CanTp_TxConfirmation(PduIdType PduId) /** req: CanTp215 **/ /** @req CANTP0
 \r
 // - - - - - - - - - - - - - -\r
 \r
-void CanTp_Shutdown() /** req : CanTp202 **//** req : CanTp200 **//** req : CanTp211 **/ /** @req CANTP010 */\r
+void CanTp_Shutdown() /** req : CanTp202 **//** req : CanTp200 **//** req : CanTp211 **//** @req CANTP010 */\r
 {\r
        VALIDATE_NO_RV( CanTpRunTimeData.internalState == CANTP_ON,\r
                        SERVICE_ID_CANTP_SHUTDOWN, CANTP_E_UNINIT ); /** @req CANTP031 */\r
@@ -1430,22 +1430,28 @@ void CanTp_MainFunction() /** @req CANTP213 */
                                txRuntimeListItem->mode = CANTP_TX_WAIT;\r
                                break;\r
                        }\r
-                       case TX_WAIT_CAN_TP_TRANSMIT_PENDING:\r
+                       case TX_WAIT_CAN_TP_TRANSMIT_PENDING: {\r
                                (void) canTpTransmitHelper(txConfigListItem, txRuntimeListItem);/** @req CANTP184 */ /** @req CANTP089 */\r
                                break;\r
-                       case TX_WAIT_SEND_CONSECUTIVE_FRAME:\r
-                               ret = sendConsecutiveFrame(txConfigListItem, txRuntimeListItem);\r
-                               /* qqq: TODO: We have a CAN error, put in log-file? */\r
-                               if ( ret == E_OK ) {\r
-                                       handleConsecutiveFrameSent(txConfigListItem, txRuntimeListItem);\r
+                       }\r
+                       case TX_WAIT_SEND_CONSECUTIVE_FRAME: {\r
+                               TIMER_DECREMENT (rxRuntimeListItem->iso15765.stateTimeoutCount); // Make sure that STmin timer has expired.\r
+                               if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
+                                       ret = sendConsecutiveFrame(txConfigListItem, txRuntimeListItem);\r
+                                       if ( ret == E_OK ) {\r
+                                               handleConsecutiveFrameSent(txConfigListItem, txRuntimeListItem);\r
+                                       } else {\r
+                                               DEBUG( DEBUG_MEDIUM, "ERROR: Consecutive frame could not be sent!\n");\r
+                                               PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
+                                                               (NotifResultType) NTFRSLT_E_NOT_OK); /** @req CANTP204 */\r
+                                               txRuntimeListItem->iso15765.state = IDLE;\r
+                                               txRuntimeListItem->mode = CANTP_TX_WAIT;\r
+                                       }\r
                                } else {\r
-                                       DEBUG( DEBUG_MEDIUM, "ERROR: Consecutive frame could not be sent!\n");\r
-                                       PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
-                                                       (NotifResultType) NTFRSLT_E_NOT_OK); /** @req CANTP204 */\r
-                                       txRuntimeListItem->iso15765.state = IDLE;\r
-                                       txRuntimeListItem->mode = CANTP_TX_WAIT;\r
+                                       DEBUG( DEBUG_MEDIUM, "Waiting for STmin timer to expire!\n");\r
                                }\r
                                break;\r
+                       }\r
                        case TX_WAIT_FLOW_CONTROL:\r
                                //DEBUG( DEBUG_MEDIUM, "Waiting for flow control!\n");\r
                                if (txRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
@@ -1492,8 +1498,8 @@ void CanTp_MainFunction() /** @req CANTP213 */
                                                                rxRuntimeListItem->canFrameBuffer.data,\r
                                                                rxRuntimeListItem->canFrameBuffer.byteCount,\r
                                                                &bytesWrittenToSduRBuffer);\r
-                                       bytesRemaining = rxRuntimeListItem->pduLenghtTotalBytes -\r
-                                                       rxRuntimeListItem->pduTransferedBytesCount;\r
+                                       bytesRemaining = rxRuntimeListItem->transferTotal -\r
+                                                       rxRuntimeListItem->transferCount;\r
                                        if (bytesRemaining > 0) {\r
                                                sendFlowControlFrame( rxConfigListItem, rxRuntimeListItem, ret ); /** @req CANTP224 (Busy or CTS) */\r
                                        }\r
index 045f58c8ad4d291d67aea27f28c8c459f968b574..c2daa15352e210d1a6fbb44fdb6fa917eaab03a9 100644 (file)
@@ -99,11 +99,12 @@ void stopS3SessionTimer(Dcm_DslRunTimeProtocolParametersType *runtime) {
 //\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
+\r
+       /** @req DCM139 **/\r
+\r
        switch (runtime->sessionControl) {\r
        case DCM_DEFAULT_SESSION: // "default".\r
                break;\r
@@ -160,7 +161,7 @@ void DslGetCurrentServiceTable(
 \r
 // - - - - - - - - - - -\r
 \r
-Std_ReturnType DslGetActiveProtocol(Dcm_ProtocolType *protocolId) {\r
+Std_ReturnType DslGetActiveProtocol(Dcm_ProtocolType *protocolId) { /** @req DCM340 **/\r
        Std_ReturnType ret = E_NOT_OK;\r
        const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
        activeProtocol = DcmDslRunTimeData.activeProtocol;\r
@@ -173,7 +174,7 @@ Std_ReturnType DslGetActiveProtocol(Dcm_ProtocolType *protocolId) {
 \r
 // - - - - - - - - - - -\r
 \r
-void DslSetSecurityLevel(Dcm_SecLevelType secLevel) {\r
+void DslSetSecurityLevel(Dcm_SecLevelType secLevel) { /** @req DCM020 **/\r
        const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
        activeProtocol = DcmDslRunTimeData.activeProtocol;\r
@@ -183,7 +184,7 @@ void DslSetSecurityLevel(Dcm_SecLevelType secLevel) {
 \r
 // - - - - - - - - - - -\r
 \r
-Std_ReturnType DslGetSecurityLevel(Dcm_SecLevelType *secLevel) {\r
+Std_ReturnType DslGetSecurityLevel(Dcm_SecLevelType *secLevel) {  /** @req DCM020 **//** @req DCM338 **/\r
        Std_ReturnType ret = E_NOT_OK;\r
        const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
@@ -198,7 +199,7 @@ Std_ReturnType DslGetSecurityLevel(Dcm_SecLevelType *secLevel) {
 \r
 // - - - - - - - - - - -\r
 \r
-void DslSetSesCtrlType(Dcm_SesCtrlType sesCtrl) {\r
+void DslSetSesCtrlType(Dcm_SesCtrlType sesCtrl) {  /** @req DCM022 **/\r
        const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
        activeProtocol = DcmDslRunTimeData.activeProtocol;\r
@@ -213,7 +214,7 @@ void DslSetSesCtrlType(Dcm_SesCtrlType sesCtrl) {
 \r
 // - - - - - - - - - - -\r
 \r
-Std_ReturnType DslGetSesCtrlType(Dcm_SesCtrlType *sesCtrlType) {\r
+Std_ReturnType DslGetSesCtrlType(Dcm_SesCtrlType *sesCtrlType) { /** @req DCM022 **//** @req DCM339 **/\r
        Std_ReturnType ret = E_NOT_OK;\r
        const Dcm_DslProtocolRowType *activeProtocol = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
@@ -297,6 +298,8 @@ void releaseExternalRxTxBuffersHelper(PduIdType rxPduIdRef) {
        }\r
 }\r
 \r
+// - - - - - - - - - - -\r
+\r
 /*\r
  *  This function is called from the DSD module to the DSL when\r
  *  a response to a diagnostic request has been copied into the\r
@@ -310,6 +313,8 @@ void DslDsdProcessingDone(PduIdType rxPduIdRef,
        const Dcm_DslProtocolRowType *protocolRow = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
 \r
+\r
+\r
        DEBUG( DEBUG_MEDIUM, "DslDsdProcessingDone rxPduIdRef=%d\n", rxPduIdRef);\r
 \r
        if (findRxPduIdParentConfigurationLeafs(rxPduIdRef, &protocolRx, &mainConnection,\r
@@ -317,7 +322,7 @@ void DslDsdProcessingDone(PduIdType rxPduIdRef,
                imask_t state = McuE_EnterCriticalSection();\r
                switch (responseResult) {\r
                case DSD_TX_RESPONSE_READY:\r
-                       runtime->externalTxBufferStatus = DSD_PENDING_RESPONSE_SIGNALED;\r
+                       runtime->externalTxBufferStatus = DSD_PENDING_RESPONSE_SIGNALED; /** @req DCM114 **/\r
                        break;\r
                case DSD_TX_RESPONSE_SUPPRESSED:\r
                        releaseExternalRxTxBuffersHelper(rxPduIdRef);\r
@@ -343,17 +348,19 @@ void sendResponse(const Dcm_DslProtocolRowType *protocol,
        const Dcm_DslProtocolRowType *protocolRow = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
 \r
+       /** @req DCM119 **/\r
        imask_t state = McuE_EnterCriticalSection();\r
        if (findRxPduIdParentConfigurationLeafs(protocol->DslRunTimeProtocolParameters->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
                if (runtime->localTxBuffer.status == NOT_IN_USE) {\r
-                       runtime->localTxBuffer.status = PROVIDED_TO_DSD; // For readability (yes, it will later be overwritten).\r
+                       runtime->localTxBuffer.status = PROVIDED_TO_DSD;\r
                        runtime->localTxBuffer.buffer[0] = SID_NEGATIVE_RESPONSE;\r
                        runtime->localTxBuffer.buffer[1] = protocol->DslProtocolRxBufferID->pduInfo.SduDataPtr[2];\r
-                       runtime->localTxBuffer.buffer[2] = responseCode; // 0x78.\r
+                       runtime->localTxBuffer.buffer[2] = responseCode;\r
                        runtime->localTxBuffer.PduInfo.SduDataPtr = runtime->localTxBuffer.buffer;\r
                        runtime->localTxBuffer.PduInfo.SduLength = 3;\r
-                       runtime->localTxBuffer.status = DCM_TRANSMIT_SIGNALED; // In the DslProvideTxBuffer 'callback' this state signals it is the local buffer we are intressted in sending.\r
-                       PduR_DcmTransmit(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, &(runtime->localTxBuffer.PduInfo));\r
+                       runtime->localTxBuffer.status = DCM_TRANSMIT_SIGNALED; // In the DslProvideTxBuffer 'callback' this state signals it is the local buffer we are interested in sending.\r
+                       PduR_DcmTransmit(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
+                                       &(runtime->localTxBuffer.PduInfo));/** @req DCM115, the P2ServerMin has not been implemented. **/\r
                }\r
        }\r
        McuE_ExitCriticalSection(state);\r
@@ -393,7 +400,7 @@ boolean isTesterPresentCommand(const PduInfoType *rxPdu) {
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
 //     Implements 'void Dcm_Init(void)' for DSL.\r
 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r
-void DslInit(void) {\r
+void DslInit(void) { /** @req DCM037 - for DSL submodule. **/\r
        const Dcm_DslProtocolRowType *listEntry = NULL;\r
        Dcm_DslRunTimeProtocolParametersType *runtime = NULL;\r
 \r
@@ -404,7 +411,7 @@ void DslInit(void) {
                runtime->externalTxBufferStatus = DCM_IDLE;\r
                runtime->localRxBuffer.status = DCM_IDLE;\r
                runtime->localTxBuffer.status = DCM_IDLE;\r
-               runtime->securityLevel = DCM_SEC_LEV_LOCKED;\r
+               runtime->securityLevel = DCM_SEC_LEV_LOCKED; /** @req DCM033 **/\r
                runtime->sessionControl = DCM_DEFAULT_SESSION;\r
                listEntry->DslProtocolRxBufferID->externalBufferRuntimeData->status\r
                                = BUFFER_AVAILABLE;\r
@@ -433,7 +440,7 @@ void DslMain(void) {
                        if (runtime->sessionControl != DCM_DEFAULT_SESSION) { // Timeout if tester present is lost.\r
                                DECREMENT(runtime->S3ServerTimeoutCount);\r
                                if (runtime->S3ServerTimeoutCount == 0) {\r
-                                       changeDiagnosticSession(runtime, DCM_DEFAULT_SESSION);\r
+                                       changeDiagnosticSession(runtime, DCM_DEFAULT_SESSION); /** @req DCM140 **/\r
                                }\r
                        }\r
                        switch (runtime->externalTxBufferStatus) { // #### TX buffer state. ####\r
@@ -451,12 +458,10 @@ void DslMain(void) {
                                        if (DCM_Config.Dsl->DslDiagResp != NULL) {\r
                                                if (DCM_Config.Dsl->DslDiagResp->DslDiagRespForceRespPendEn == TRUE) {\r
                                                        if (runtime->responsePendingCount != 0) {\r
-                                                               DEBUG( DEBUG_MEDIUM, "No response withing timeout, sending response pending!\n");\r
-                                                               sendResponse(protocolRowEntry, DCM_E_RESPONSEPENDING);\r
+                                                               sendResponse(protocolRowEntry, DCM_E_RESPONSEPENDING);  /** @req DCM024 **/\r
                                                                DECREMENT( runtime->responsePendingCount );\r
                                                        } else {\r
-                                                               DEBUG( DEBUG_MEDIUM, "Sent all response pending, now sending general reject!\n");\r
-                                                               sendResponse(protocolRowEntry, DCM_E_GENERALREJECT);\r
+                                                               sendResponse(protocolRowEntry, DCM_E_GENERALREJECT); /** @req DCM120 **/\r
                                                                releaseExternalRxTxBuffers(protocolRowEntry, runtime);\r
                                                        }\r
                                                } else {\r
@@ -473,20 +478,29 @@ 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, "Current polite index=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
+                                       int ii;\r
                                        const Dcm_DslProtocolRxType *protocolRx = NULL;\r
                                        const Dcm_DslMainConnectionType *mainConnection = NULL;\r
                                        const Dcm_DslConnectionType *connection = NULL;\r
                                        const Dcm_DslProtocolRowType *protocolRow = NULL;\r
                                        if (findRxPduIdParentConfigurationLeafs(runtime->diagReqestRxPduId, &protocolRx, &mainConnection, &connection, &protocolRow, &runtime)) {\r
                                                const uint32 txPduId = mainConnection->DslProtocolTx->DcmDslProtocolTxPduId;\r
-                                               DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.\n", txPduId);\r
+                                               DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DCM_TRANSMIT_SIGNALED.\n" );\r
                                                runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
-                                               DEBUG( DEBUG_MEDIUM, "Calling PduR_DcmTransmit with txPduId = %d from DslMain\n", txPduId);\r
+\r
+                                               DEBUG( DEBUG_MEDIUM, "DO NOT CHECK INTO REPO: **** FAKING DSD RESPONSE TO BE 50 bytes !!!!! ********\n", txPduId);\r
+                                               runtime->diagnosticResponseFromDsd.SduLength = runtime->diagnosticRequestFromTester.SduLength;\r
+                                               for (ii=0; ii<runtime->diagnosticRequestFromTester.SduLength; ii++) {\r
+                                                       runtime->diagnosticResponseFromDsd.SduDataPtr[ii] =\r
+                                                                       runtime->diagnosticRequestFromTester.SduDataPtr[ii];\r
+                                               }\r
+\r
+\r
                                                PduR_DcmTransmit(txPduId, &runtime->diagnosticResponseFromDsd); /** @req DCM237 **//* Will trigger PduR (CanTP) to call DslProvideTxBuffer(). */\r
                                        } else {\r
+                                               DEBUG( DEBUG_MEDIUM, "***** WARNING, THIS IS UNEXPECTED !!! ********.\n" );\r
                                                const uint32 txPduId = protocolRowEntry->DslConnection->DslMainConnection->DslProtocolTx->DcmDslProtocolTxPduId;\r
                                                DEBUG( DEBUG_MEDIUM, "runtime->externalTxBufferStatus enter state DSD_PENDING_RESPONSE_SIGNALED.\n", txPduId);\r
                                                runtime->externalTxBufferStatus = DCM_TRANSMIT_SIGNALED;\r
@@ -518,7 +532,7 @@ void DslMain(void) {
 //  received a FF or a single frame and needs to obtain a buffer from the\r
 //  receiver so that received data can be forwarded.\r
 \r
-BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,\r
+BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId, /** @req DCM094 **/\r
                PduLengthType tpSduLength, const PduInfoType **pduInfoPtr) {\r
        BufReq_ReturnType ret = BUFREQ_NOT_OK;\r
        const Dcm_DslProtocolRxType *protocolRx = NULL;\r
@@ -533,7 +547,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
                        &connection, &protocolRow, &runtime)) {\r
                const Dcm_DslBufferType *externalRxBuffer =\r
                                protocolRow->DslProtocolRxBufferID;\r
-               if (externalRxBuffer->pduInfo.SduLength >= tpSduLength) { // First validate that we have a chance receiving the chunk of data.\r
+               if (externalRxBuffer->pduInfo.SduLength >= tpSduLength) { /** @req DCM443 **/\r
                        if ((runtime->externalRxBufferStatus == NOT_IN_USE)\r
                                        && (externalRxBuffer->externalBufferRuntimeData->status\r
                                                        == BUFFER_AVAILABLE)) {\r
@@ -546,7 +560,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
                                runtime->diagnosticRequestFromTester.SduLength = tpSduLength;\r
                                //*pduInfoPtr = &(externalRxBuffer->pduInfo);\r
                                *pduInfoPtr = &(runtime->diagnosticRequestFromTester);\r
-                               runtime->externalRxBufferStatus = PROVIDED_TO_PDUR;\r
+                               runtime->externalRxBufferStatus = PROVIDED_TO_PDUR; /** @req DCM342 **/\r
                                ret = BUFREQ_OK;\r
                        } else {\r
                                DEBUG( DEBUG_MEDIUM, "Local buffer available!\n");\r
@@ -567,14 +581,14 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
                                        // The buffer is in use by the PduR, we can not help this because then\r
                                        // we would have two different Rx-indications with same PduId but we\r
                                        // will not know which buffer the indication should free.\r
-                                       ret = BUFREQ_BUSY;\r
+                                       ret = BUFREQ_BUSY; /** @req DCM445 **/\r
                                }\r
                        }\r
                } else {\r
-                       ret = BUFREQ_OVFL; // Required size is too big.\r
+                       ret = BUFREQ_OVFL; /** @req DCM444 **/\r
                }\r
                if (ret == BUFREQ_OK) {\r
-                       stopS3SessionTimer(runtime); /** req: DCM141 **/\r
+                       stopS3SessionTimer(runtime); /** @req DCM141 **/\r
                }\r
        }\r
        McuE_ExitCriticalSection(state);\r
@@ -588,7 +602,7 @@ BufReq_ReturnType DslProvideRxBufferToPdur(PduIdType dcmRxPduId,
 //     received the diagnostic request, copied it to the provided buffer and need to indicate\r
 //     this to the DCM (DSL) module via propritary API.\r
 \r
-void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {\r
+void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {  /** @req DCM093 **/\r
        const Dcm_DslProtocolRxType *protocolRx = NULL;\r
        const Dcm_DslMainConnectionType *mainConnection = NULL;\r
        const Dcm_DslConnectionType *connection = NULL;\r
@@ -598,74 +612,79 @@ void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {
        Std_ReturnType higherLayerResp;\r
        imask_t state;\r
 \r
-       // qqq: handle the actual result code.\r
+       /** @req DCM345, this needs to be verified when connection to CanIf works. **/\r
+\r
        if (findRxPduIdParentConfigurationLeafs(dcmRxPduId, &protocolRx, &mainConnection,\r
                        &connection, &protocolRow, &runtime)) {\r
                timeParams = protocolRow->DslProtocolTimeLimit;\r
                // We need to find out in what buffer we can find our Rx data (it can\r
                // be either in the normal RX-buffer or the 'extra' buffer for implementing\r
                // the Concurrent "Test Present" functionality.\r
+               state = McuE_EnterCriticalSection();\r
                if (runtime->externalRxBufferStatus == PROVIDED_TO_PDUR) {\r
-                       if (isTesterPresentCommand(\r
-                                       &(protocolRow->DslProtocolRxBufferID->pduInfo))) {\r
-                               state = McuE_EnterCriticalSection();\r
-                               startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
-                               runtime->externalRxBufferStatus = NOT_IN_USE;\r
-                               protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
-                               McuE_ExitCriticalSection(state);\r
-                       } else {\r
-                               if (runtime->protocolStarted == FALSE) {\r
-                                       higherLayerResp = StartProtocolHelper(\r
-                                                       protocolRow->DslProtocolID);\r
-                                       if (higherLayerResp == E_OK) {\r
-                                               runtime->protocolStarted = TRUE;\r
-                                               DcmDslRunTimeData.activeProtocol = protocolRow;\r
+                       if ( result == NTFRSLT_OK ) { /** @req DCM111 **/\r
+                               if (isTesterPresentCommand(\r
+                                               &(protocolRow->DslProtocolRxBufferID->pduInfo))) {\r
+                                       startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+                                       runtime->externalRxBufferStatus = NOT_IN_USE;\r
+                                       protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
+                               } else {\r
+                                       if (runtime->protocolStarted == FALSE) {\r
+                                               higherLayerResp = StartProtocolHelper(\r
+                                                               protocolRow->DslProtocolID); /** @req DCM036 **/\r
+                                               if (higherLayerResp == E_OK) {\r
+                                                       runtime->protocolStarted = TRUE;\r
+                                                       DcmDslRunTimeData.activeProtocol = protocolRow;\r
+                                               }\r
                                        }\r
-                               }\r
-                               if (runtime->protocolStarted == TRUE) {\r
-                                       if (runtime->diagnosticActiveComM == FALSE) {\r
-                                               ComM_DCM_ActivateDiagnostic(); /* @DCM163 */\r
-                                               runtime->diagnosticActiveComM = TRUE;\r
+                                       if (runtime->protocolStarted == TRUE) {\r
+                                               if (runtime->diagnosticActiveComM == FALSE) {\r
+                                                       ComM_DCM_ActivateDiagnostic(); /* @DCM163 */\r
+                                                       runtime->diagnosticActiveComM = TRUE;\r
+                                               }\r
+                                               runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
+                                                               timeParams->TimStrP2ServerMax); /* See 9.2.2. */\r
+                                               runtime->externalRxBufferStatus = PROVIDED_TO_DSD; /** @req DCM241 **/\r
+                                               runtime->externalTxBufferStatus = PROVIDED_TO_DSD; /** @req DCM241 **/\r
+                                               timeParams = protocolRow->DslProtocolTimeLimit;\r
+                                               runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
+                                                               timeParams->TimStrP2ServerMax); /* Reinitiate timer, see 9.2.2. */\r
+                                               runtime->responsePendingCount = DCM_Config.Dsl->DslDiagResp->DslDiagRespMaxNumRespPend;\r
+                                               runtime->diagnosticResponseFromDsd.SduDataPtr\r
+                                                               = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
+                                               runtime->diagnosticResponseFromDsd.SduLength\r
+                                                               = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
+                                               DEBUG( DEBUG_MEDIUM, "DsdDslDataIndication(DcmDslProtocolTxPduId=%d, dcmRxPduId=%d)\n",\r
+                                                               mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, dcmRxPduId);\r
+                                               runtime->diagReqestRxPduId = dcmRxPduId;\r
+                                               DsdDslDataIndication(  // qqq: We are in a critical section, how much time will this consume?\r
+                                                               &(runtime->diagnosticRequestFromTester),\r
+                                                               protocolRow->DslProtocolSIDTable,\r
+                                                               protocolRx->DslProtocolAddrType,\r
+                                                               mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
+                                                               &(runtime->diagnosticResponseFromDsd),\r
+                                                               dcmRxPduId);\r
                                        }\r
-                                       state = McuE_EnterCriticalSection();\r
-                                       runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
-                                                       timeParams->TimStrP2ServerMax); /* See 9.2.2. */\r
-                                       runtime->externalRxBufferStatus = PROVIDED_TO_DSD;\r
-                                       runtime->externalTxBufferStatus = PROVIDED_TO_DSD; // Used in main.\r
-                                       timeParams = protocolRow->DslProtocolTimeLimit;\r
-                                       runtime->stateTimeoutCount = DCM_CONVERT_MS_TO_MAIN_CYCLES(\r
-                                                       timeParams->TimStrP2ServerMax); /* Reinitiate timer, see 9.2.2. */\r
-                                       runtime->responsePendingCount = DCM_Config.Dsl->DslDiagResp->DslDiagRespMaxNumRespPend; // qqq ugly.\r
-                                       McuE_ExitCriticalSection(state);\r
-                                       runtime->diagnosticResponseFromDsd.SduDataPtr\r
-                                                       = protocolRow->DslProtocolTxBufferID->pduInfo.SduDataPtr;\r
-                                       runtime->diagnosticResponseFromDsd.SduLength\r
-                                                       = protocolRow->DslProtocolTxBufferID->pduInfo.SduLength;\r
-                                       DEBUG( DEBUG_MEDIUM, "DsdDslDataIndication(DcmDslProtocolTxPduId=%d, dcmRxPduId=%d)\n",\r
-                                                       mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, dcmRxPduId);\r
-                                       runtime->diagReqestRxPduId = dcmRxPduId;\r
-                                       DsdDslDataIndication(\r
-                                                       &(runtime->diagnosticRequestFromTester),\r
-                                                       protocolRow->DslProtocolSIDTable,\r
-                                                       protocolRx->DslProtocolAddrType,\r
-                                                       mainConnection->DslProtocolTx->DcmDslProtocolTxPduId,\r
-                                                       &(runtime->diagnosticResponseFromDsd),\r
-                                                       dcmRxPduId);\r
                                }\r
+                       } else { /** @req DCM344 **/\r
+                               // The indication was not equal to NTFRSLT_OK, release the resources and no forward to DSD.\r
+                               runtime->externalRxBufferStatus = NOT_IN_USE;\r
+                               protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status = BUFFER_AVAILABLE;\r
                        }\r
                } else {\r
                        // It is the local buffer that was provided to the PduR, that buffer\r
                        // is only used for tester present reception in parallel to diagnostic\r
                        // requests.\r
-                       state = McuE_EnterCriticalSection();\r
                        if (runtime->localRxBuffer.status == PROVIDED_TO_PDUR) {\r
-                               if (isTesterPresentCommand(&(runtime->localRxBuffer.PduInfo))) {\r
-                                       startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+                               if ( result == NTFRSLT_OK ) { // Make sure that the data in buffer is valid.\r
+                                       if (isTesterPresentCommand(&(runtime->localRxBuffer.PduInfo))) {\r
+                                               startS3SessionTimer(runtime, protocolRow); /** @req DCM141 **//** @req DCM112 **//** @req DCM113 **/\r
+                                       }\r
                                }\r
                                runtime->localRxBuffer.status = NOT_IN_USE;\r
                        }\r
-                       McuE_ExitCriticalSection(state);\r
                }\r
+               McuE_ExitCriticalSection(state);\r
        }\r
 }\r
 \r
@@ -679,7 +698,7 @@ void DslRxIndicationFromPduR(PduIdType dcmRxPduId, NotifResultType result) {
 //  it has detected that the pending request has been answered by DSD\r
 //  (or any other module?).\r
 \r
-BufReq_ReturnType DslProvideTxBuffer(PduIdType dcmTxPduId,\r
+BufReq_ReturnType DslProvideTxBuffer(PduIdType dcmTxPduId,     /** @req DCM092 **/\r
                const PduInfoType **pduInfoPtr, PduLengthType length) {\r
        BufReq_ReturnType ret = BUFREQ_NOT_OK;\r
        const Dcm_DslProtocolTxType *protocolTx = NULL;\r
@@ -693,8 +712,9 @@ BufReq_ReturnType DslProvideTxBuffer(PduIdType dcmTxPduId,
                        &connection, &protocolRow, &runtime)) {\r
                switch (runtime->externalTxBufferStatus) { // ### EXTERNAL TX BUFFER ###\r
                case DCM_TRANSMIT_SIGNALED: {\r
+                       /** @req DCM346 - length verification is already done if this state is reached. **/\r
                        *pduInfoPtr = &(protocolRow->DslProtocolTxBufferID->pduInfo);\r
-                       runtime->externalTxBufferStatus = PROVIDED_TO_PDUR;\r
+                       runtime->externalTxBufferStatus = PROVIDED_TO_PDUR; /** @req DCM349 **/\r
                        ret = BUFREQ_OK;\r
                        break;\r
                }\r
@@ -751,21 +771,10 @@ void DslTxConfirmation(PduIdType dcmTxPduId, NotifResultType result) {
                case PROVIDED_TO_PDUR: {\r
                        ComM_DCM_InactivateDiagnostic();\r
                        startS3SessionTimer(runtime, protocolRow); // @DCM141\r
-                       releaseExternalRxTxBuffers(protocolRow, runtime);\r
-                       /*\r
-                        protocolRow->DslProtocolTxBufferID->externalBufferRuntimeData->status\r
-                        = BUFFER_AVAILABLE;\r
-                        protocolRow->DslProtocolRxBufferID->externalBufferRuntimeData->status\r
-                        = BUFFER_AVAILABLE;\r
-                       runtime->externalTxBufferStatus = DCM_IDLE;\r
-                       runtime->externalRxBufferStatus = DCM_IDLE;\r
-                        */\r
-                       DEBUG( DEBUG_MEDIUM, "Released external buffer sucessfully!\n");\r
+                       releaseExternalRxTxBuffers(protocolRow, runtime); /** @req DCM118 **//** @req DCM353 **//** @req DCM354 **/\r
                        externalBufferReleased = TRUE;\r
-\r
+                       DEBUG( DEBUG_MEDIUM, "Released external buffer OK!\n");\r
                        DsdDataConfirmation(mainConnection->DslProtocolTx->DcmDslProtocolTxPduId, result); /** @req DCM117 **//** @req DCM235 **/\r
-\r
-\r
                        break;\r
                }\r
                default:\r
@@ -774,11 +783,11 @@ void DslTxConfirmation(PduIdType dcmTxPduId, NotifResultType result) {
                if (externalBufferReleased == FALSE) {\r
                        switch (runtime->localTxBuffer.status) { // ### LOCAL TX BUFFER ###\r
                        case PROVIDED_TO_PDUR:\r
-                               DEBUG( DEBUG_MEDIUM, "Released local buffer buffer!\n");\r
+                               DEBUG( DEBUG_MEDIUM, "Released local buffer buffer OK!\n");\r
                                runtime->localTxBuffer.status = DCM_IDLE;\r
                                break;\r
                        default:\r
-                               DEBUG( DEBUG_MEDIUM, "WARNING! DslTxConfirmation could not release any buffer!\n");\r
+                               DEBUG( DEBUG_MEDIUM, "WARNING! DslTxConfirmation could not release external or local buffer!\n");\r
                                break;\r
                        }\r
                }\r
index c60387d2d66e7e2939863b2d8fec290ab3fed50a..53d0b53d0b97ad2a256d53c05d937db1e56559c4 100644 (file)
@@ -20,6 +20,8 @@
  * TBD.\r
  */\r
 \r
+/** @req CANTP157 */\r
+\r
 #ifndef CANTP_H_\r
 #define CANTP_H_\r
 \r
@@ -33,7 +35,7 @@
 \r
 #include "ComStack_Types.h"\r
 #include "Std_Types.h"\r
-#include "CanTp_Cfg.h"\r
+#include "CanTp_Cfg.h"  /** @req CANTP221 */\r
 //#include "Dem.h"  // TODO: req: CanTp156\r
 \r
 /*\r
index d508b659c0ab8e78e07c48013acdc0a44475fdbc..263e920d8972c0142e0f88f437bbd17d1b9f96e2 100644 (file)
@@ -13,6 +13,7 @@
  * for more details.\r
  * -------------------------------- Arctic Core ------------------------------*/\r
 \r
+/** @req CANTP160 */\r
 \r
 #ifndef CANTP_TYPES_H_\r
 #define CANTP_TYPES_H_\r