]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Refactoring in CanTp.
authorpete <devnull@localhost>
Mon, 19 Apr 2010 10:51:07 +0000 (12:51 +0200)
committerpete <devnull@localhost>
Mon, 19 Apr 2010 10:51:07 +0000 (12:51 +0200)
communication/CanTp/CanTp.c
include/CanTp_Types.h

index 86bc099fc240bae35e792ebe1f0ce98c15cff7eb..611d67cef58bd3a36cabb92dbaba91154840d1fd 100644 (file)
@@ -431,7 +431,7 @@ static INLINE BufReq_ReturnType writeDataSegmentToPduRBuffer(const CanTp_RxNSduT
                if (*bytesWrittenSuccessfully < segmentSize ) {\r
                        // 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_CanTpTxPduId,\r
+                       ret = PduR_CanTpProvideRxBuffer(rxConfig->PduR_PduId,\r
                                                        rxRuntime->pduLenghtTotalBytes,\r
                                                        &rxRuntime->bufferPduRouter);\r
                        if (ret == BUFREQ_OK) {\r
@@ -486,7 +486,7 @@ static INLINE Std_ReturnType canReceivePaddingHelper(
        rxRuntime->iso15765.NasNarTimeoutCount =\r
                        CANTP_CONVERT_MS_TO_MAIN_CYCLES(rxConfig->CanTpNar * 1000); // req: CanTp075.\r
        rxRuntime->iso15765.NasNarPending = TRUE;\r
-       return CanIf_Transmit(rxConfig->CanIf_CanTxPduId, PduInfoPtr);\r
+       return CanIf_Transmit(rxConfig->CanIf_FcPduId, PduInfoPtr);\r
 }\r
 \r
 // - - - - - - - - - - - - - -\r
@@ -503,7 +503,7 @@ static INLINE Std_ReturnType canTansmitPaddingHelper(
        txRuntime->iso15765.NasNarTimeoutCount =\r
                        CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNas * 1000); // req: CanTp075.\r
        txRuntime->iso15765.NasNarPending = TRUE;\r
-       return CanIf_Transmit(txConfig->CanIf_CanTxPduId, PduInfoPtr);\r
+       return CanIf_Transmit(txConfig->CanIf_PduId, PduInfoPtr);\r
 }\r
 \r
 // - - - - - - - - - - - - - -\r
@@ -561,7 +561,7 @@ static INLINE void sendFlowControlFrame(const CanTp_RxNSduType *rxConfig,
        }\r
        ret = canReceivePaddingHelper(rxConfig, rxRuntime, &pduInfo);\r
        if (ret != E_OK) {\r
-               PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId,\r
+               PduR_CanTpRxIndication(rxConfig->PduR_PduId,\r
                                (NotifResultType) NTFRSLT_E_NOT_OK);\r
                rxRuntime->iso15765.state = IDLE;\r
                rxRuntime->mode = CANTP_RX_WAIT;\r
@@ -591,7 +591,7 @@ static INLINE void handleConsecutiveFrame(const CanTp_RxNSduType *rxConfig,
        if (segmentNumber != (rxRuntime->iso15765.framesHandledCount\r
                        & SEGMENT_NUMBER_MASK)) {\r
                DEBUG(DEBUG_MEDIUM,"Segmentation number error detected!\n");\r
-               PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId, NTFRSLT_E_WRONG_SN);\r
+               PduR_CanTpRxIndication(rxConfig->PduR_PduId, NTFRSLT_E_WRONG_SN);\r
                rxRuntime->iso15765.state = IDLE;\r
                rxRuntime->mode = CANTP_RX_WAIT;\r
        } else {\r
@@ -614,7 +614,7 @@ static INLINE void handleConsecutiveFrame(const CanTp_RxNSduType *rxConfig,
                                &bytesWrittenToSduRBuffer);\r
                if (ret == BUFREQ_NOT_OK) {\r
                        DEBUG( DEBUG_MEDIUM,"writeDataSegmentToPduRBuffer failed!\n");\r
-                       PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId, NTFRSLT_E_NO_BUFFER);\r
+                       PduR_CanTpRxIndication(rxConfig->PduR_PduId, NTFRSLT_E_NO_BUFFER);\r
                        rxRuntime->iso15765.state = IDLE;\r
                        rxRuntime->mode = CANTP_RX_WAIT;\r
                } else if (ret == BUFREQ_BUSY) {\r
@@ -646,7 +646,7 @@ static INLINE void handleConsecutiveFrame(const CanTp_RxNSduType *rxConfig,
                                DEBUG( DEBUG_MEDIUM,"RX FINISHED!\n");\r
                                rxRuntime->iso15765.state = IDLE;\r
                                rxRuntime->mode = CANTP_RX_WAIT;\r
-                               PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId, NTFRSLT_OK);\r
+                               PduR_CanTpRxIndication(rxConfig->PduR_PduId, NTFRSLT_OK);\r
                        }\r
                }\r
        }\r
@@ -696,7 +696,7 @@ static INLINE Std_ReturnType sendConsecutiveFrame(
                } else {\r
                        // More buffering is required.\r
                        BufReq_ReturnType pdurResp;\r
-                       pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_CanTpTxPduId,\r
+                       pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId,\r
                                        &txRuntime->bufferPduRouter, 0);\r
                        if (pdurResp == BUFREQ_OK) {\r
                                txRuntime->pdurBufferCount = 0;\r
@@ -745,7 +745,7 @@ static INLINE void handleConsecutiveFrameSent(
                DEBUG( DEBUG_MEDIUM, "----->LAST CONSECUTIVE FRAME SENT!!!\n");\r
                txRuntime->iso15765.state = IDLE;\r
                txRuntime->mode = CANTP_TX_WAIT;\r
-               PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId,\r
+               PduR_CanTpTxConfirmation(txConfig->PduR_PduId,\r
                                (NotifResultType) NTFRSLT_OK);\r
        } else if (txRuntime->iso15765.nextFlowControlCount == 0) {\r
                // It is time to receive a flow control.\r
@@ -762,7 +762,7 @@ static INLINE void handleConsecutiveFrameSent(
                txRuntime->iso15765.state = TX_WAIT_SEND_CONSECUTIVE_FRAME;\r
        } else {\r
                DEBUG( DEBUG_MEDIUM, "Sender failed!\n" );\r
-               PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId,\r
+               PduR_CanTpTxConfirmation(txConfig->PduR_PduId,\r
                                (NotifResultType) NTFRSLT_E_NOT_OK);\r
                txRuntime->iso15765.state = IDLE;\r
                txRuntime->mode = CANTP_TX_WAIT;\r
@@ -793,7 +793,7 @@ static INLINE void handleFlowControlFrame(const CanTp_TxNSduType *txConfig,
                        handleConsecutiveFrameSent(txConfig, txRuntime);\r
                } else {\r
                        DEBUG( DEBUG_MEDIUM, "handleConsecutiveFrameSent returned error!\n");\r
-                       PduR_CanTpRxIndication(txConfig->PduR_CanTpTxPduId,\r
+                       PduR_CanTpRxIndication(txConfig->PduR_PduId,\r
                                        (NotifResultType) NTFRSLT_E_NOT_OK);\r
                        txRuntime->iso15765.state = IDLE;\r
                        txRuntime->mode = CANTP_TX_WAIT;\r
@@ -807,7 +807,7 @@ static INLINE void handleFlowControlFrame(const CanTp_TxNSduType *txConfig,
                break;\r
        case ISO15765_FLOW_CONTROL_STATUS_OVFLW:\r
                DEBUG( DEBUG_MEDIUM, "----------------------->Flow Control: OVERFLOW!\n");\r
-               PduR_CanTpRxIndication(txConfig->PduR_CanTpTxPduId,\r
+               PduR_CanTpRxIndication(txConfig->PduR_PduId,\r
                                (NotifResultType) NTFRSLT_E_NOT_OK);\r
                txRuntime->iso15765.state = IDLE;\r
                txRuntime->mode = CANTP_TX_WAIT;\r
@@ -851,9 +851,9 @@ static INLINE void handleSingleFrame(const CanTp_RxNSduType *rxConfig,
        ret = writeDataSegmentToPduRBuffer(rxConfig, rxRuntime, data, pduLength,\r
                        &bytesWrittenToSduRBuffer);\r
        if (ret == BUFREQ_OK && rxRuntime->iso15765.stateTimeoutCount != 0) {\r
-               PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId, NTFRSLT_OK);\r
+               PduR_CanTpRxIndication(rxConfig->PduR_PduId, NTFRSLT_OK);\r
        } else {\r
-               PduR_CanTpRxIndication(rxConfig->PduR_CanTpTxPduId, NTFRSLT_E_NO_BUFFER);\r
+               PduR_CanTpRxIndication(rxConfig->PduR_PduId, NTFRSLT_E_NO_BUFFER);\r
        }\r
        rxRuntime->iso15765.state = IDLE;\r
        rxRuntime->mode = CANTP_RX_WAIT;\r
@@ -1053,7 +1053,7 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
        Std_ReturnType res = E_NOT_OK;\r
        ISO15765FrameType iso15765Frame = INVALID_FRAME;\r
 \r
-       pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_CanTpTxPduId,\r
+       pdurResp = PduR_CanTpProvideTxBuffer(txConfig->PduR_PduId,\r
                        &txRuntime->bufferPduRouter, 0);  // Req: CanTp 186.\r
        //if (txRuntime->iso15765.stateTimeoutCount != 0) {   qqq: WHY WAS THIS DONE?\r
                VALIDATE( txRuntime->bufferPduRouter->SduDataPtr != NULL,\r
@@ -1064,9 +1064,9 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
                        case SINGLE_FRAME:\r
                                res = sendSingleFrame(txConfig, txRuntime); /* req: CanTp 231  */\r
                                if (res == E_OK) {\r
-                                       PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId, NTFRSLT_OK);\r
+                                       PduR_CanTpTxConfirmation(txConfig->PduR_PduId, NTFRSLT_OK);\r
                                } else {\r
-                                       PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId, NTFRSLT_NOT_OK);\r
+                                       PduR_CanTpTxConfirmation(txConfig->PduR_PduId, NTFRSLT_NOT_OK);\r
                                }\r
                                txRuntime->iso15765.state = IDLE;\r
                                txRuntime->mode = CANTP_TX_WAIT;\r
@@ -1081,13 +1081,13 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
                                break;\r
                        case INVALID_FRAME:\r
                        default:\r
-                               PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId, NTFRSLT_NOT_OK);\r
+                               PduR_CanTpTxConfirmation(txConfig->PduR_PduId, NTFRSLT_NOT_OK);\r
                                txRuntime->iso15765.state = IDLE;\r
                                txRuntime->mode = CANTP_TX_WAIT;\r
                                break;\r
                        }\r
                } else if (pdurResp == BUFREQ_NOT_OK) {\r
-                       PduR_CanTpTxConfirmation(txConfig->PduR_CanTpTxPduId, NTFRSLT_NOT_OK);\r
+                       PduR_CanTpTxConfirmation(txConfig->PduR_PduId, NTFRSLT_NOT_OK);\r
                        txRuntime->iso15765.state = IDLE;\r
                        txRuntime->mode = CANTP_TX_WAIT;\r
                } else if (pdurResp == BUFREQ_BUSY) {\r
@@ -1410,7 +1410,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                        case TX_WAIT_CAN_TP_TRANSMIT_CAN_TP_PROVIDE_TX_BUFFER:\r
                                TIMER_DECREMENT (rxRuntimeListItem->iso15765.stateTimeoutCount);\r
                                if (txRuntimeListItem->iso15765.stateTimeoutCount == 0)\r
-                                       PduR_CanTpTxConfirmation(txConfigListItem->PduR_CanTpTxPduId,\r
+                                       PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
                                                        NTFRSLT_NOT_OK); /* qqq: req: CanTp: 185. */\r
                                txRuntimeListItem->iso15765.state = IDLE;\r
                                txRuntimeListItem->mode = CANTP_TX_WAIT;\r
@@ -1424,7 +1424,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                                if ( ret == E_OK ) {\r
                                        handleConsecutiveFrameSent(txConfigListItem, txRuntimeListItem);\r
                                } else {\r
-                                       PduR_CanTpRxIndication(txConfigListItem->PduR_CanTpTxPduId,\r
+                                       PduR_CanTpRxIndication(txConfigListItem->PduR_PduId,\r
                                                        (NotifResultType) NTFRSLT_E_NOT_OK);\r
                                        txRuntimeListItem->iso15765.state = IDLE;\r
                                        txRuntimeListItem->mode = CANTP_TX_WAIT;\r
@@ -1433,7 +1433,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                        case TX_WAIT_FLOW_CONTROL:\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
+                                       PduR_CanTpTxConfirmation(txConfigListItem->PduR_PduId,\r
                                                        NTFRSLT_NOT_OK); /* qqq: req: CanTp: 185. */\r
                                        txRuntimeListItem->iso15765.state = IDLE;\r
                                }\r
@@ -1451,7 +1451,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                                        DEBUG( DEBUG_MEDIUM, "TIMEOUT!\n");\r
                                        rxRuntimeListItem->iso15765.state = IDLE;\r
                                        rxRuntimeListItem->mode = CANTP_RX_WAIT;\r
-                                       PduR_CanTpTxConfirmation(rxConfigListItem->PduR_CanTpTxPduId,\r
+                                       PduR_CanTpTxConfirmation(rxConfigListItem->PduR_PduId,\r
                                                        NTFRSLT_NOT_OK);\r
                                }\r
                                break;\r
@@ -1464,7 +1464,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                                 * to send a flowcontrol clear to send (CTS).\r
                                 */\r
                                if (rxRuntimeListItem->iso15765.stateTimeoutCount == 0) {\r
-                                       PduR_CanTpTxConfirmation(rxConfigListItem->PduR_CanTpTxPduId,\r
+                                       PduR_CanTpTxConfirmation(rxConfigListItem->PduR_PduId,\r
                                                        NTFRSLT_NOT_OK);\r
                                        rxRuntimeListItem->iso15765.state = IDLE;\r
                                        rxRuntimeListItem->mode = CANTP_RX_WAIT;\r
@@ -1478,7 +1478,7 @@ void CanTp_MainFunction() /** req : CanTp213 **/
                                        if (ret == BUFREQ_OK ) {\r
                                                rxRuntimeListItem->iso15765.state = RX_WAIT_CONSECUTIVE_FRAME;\r
                                        } else if (ret == BUFREQ_NOT_OK ) {\r
-                                               PduR_CanTpTxConfirmation(rxConfigListItem->PduR_CanTpTxPduId,\r
+                                               PduR_CanTpTxConfirmation(rxConfigListItem->PduR_PduId,\r
                                                                NTFRSLT_NOT_OK);\r
                                        } else if ( ret == BUFREQ_BUSY ) {\r
                                                DEBUG( DEBUG_MEDIUM, "Still busy!\n");\r
index fc4dc6e97dc683a9874fb7e6e0086a54fded903c..265fb391b552f1db7bdd2a968a4a910997b13927 100644 (file)
@@ -77,8 +77,8 @@ typedef struct {
 \r
 \r
 typedef struct {\r
-       const int CanIf_CanTxPduId; // The polite CanIf PDU index.\r
-       const int PduR_CanTpTxPduId; // The polite PduR index.\r
+       const int CanIf_FcPduId; // The polite CanIf PDU index.\r
+       const int PduR_PduId; // The polite PduR index.\r
        const CanTp_AddressingFormantType CanTpAddressingFormant;\r
        const uint32 CanTpBs; /** req: CanTp243: Sets the maximum number of messages of N-PDUs before flow control. */\r
        const uint32 CanTpNar; /** req: CanTp244: Timeout for transmission of a CAN frame (ms). */\r
@@ -100,8 +100,8 @@ typedef struct {
 } CanTp_RxNSduType;\r
 \r
 typedef struct {\r
-       const int CanIf_CanTxPduId; // The polite CanIf index.\r
-       const int PduR_CanTpTxPduId; // The polite PduR index.\r
+       const int CanIf_PduId; // The polite CanIf index.\r
+       const int PduR_PduId; // The polite PduR index.\r
        const CanTp_AddressingFormantType CanTpAddressingMode; /** req: CanTp138: */\r
        const uint8 CanTpNas; /** req: CanTp263: N_As timeout for transmission of any CAN frame. */\r
        const uint8 CanTpNbs; /** req: CanTp264: N_Bs timeout of transmission until reception of next Flow Control. */\r