]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Merge with 680a2337adf0a3dc7e9e59b222c35d2d5553f336
authorjohn <devnull@localhost>
Tue, 20 Dec 2011 16:29:13 +0000 (17:29 +0100)
committerjohn <devnull@localhost>
Tue, 20 Dec 2011 16:29:13 +0000 (17:29 +0100)
communication/CanTp/CanTp.c
include/CanTp_Types.h

index c5d3a8b6dcee218cffb5822dafe97432e59e276d..81fc62faf7e1b27f5ba3088baeb2fad88dc83bd3 100644 (file)
@@ -1101,6 +1101,7 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
        return pdurResp;\r
 }\r
 \r
+\r
 // - - - - - - - - - - - - - -\r
 \r
 \r
@@ -1111,6 +1112,7 @@ Std_ReturnType CanTp_Transmit(PduIdType CanTpTxSduId,
        CanTp_ChannelPrivateType *txRuntime = NULL;\r
        BufReq_ReturnType res = BUFREQ_NOT_OK;\r
        Std_ReturnType ret = 0;\r
+       PduIdType CanTp_InternalTxNSduId;\r
 \r
        DEBUG( DEBUG_MEDIUM, "CanTp_Transmit called in polite index: %d!\n", CanTpTxSduId);\r
 \r
@@ -1120,36 +1122,41 @@ Std_ReturnType CanTp_Transmit(PduIdType CanTpTxSduId,
                        SERVICE_ID_CANTP_TRANSMIT, CANTP_E_UNINIT ); /** @req CANTP031 */\r
        VALIDATE( CanTpTxSduId < CANTP_NSDU_CONFIG_LIST_SIZE, SERVICE_ID_CANTP_TRANSMIT, CANTP_E_INVALID_TX_ID );\r
 \r
-       txConfig =&CanTpConfig.CanTpNSduList[CanTpTxSduId].configData.CanTpTxNSdu;\r
-\r
-       txRuntime = &CanTpRunTimeData.runtimeDataList[txConfig->CanTpTxChannel]; // Runtime data.\r
-       if (txRuntime->iso15765.state == IDLE) {\r
-               txRuntime->pdurBufferCount = 0;\r
-               txRuntime->pdurBufferCount = 0;\r
-               txRuntime->transferCount = 0;\r
-               txRuntime->iso15765.framesHandledCount = 0;\r
-               txRuntime->transferTotal = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
-               txRuntime->iso15765.stateTimeoutCount = CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNcs);\r
-               txRuntime->mode = CANTP_TX_PROCESSING;\r
-               txRuntime->iso15765.state = TX_WAIT_CAN_TP_TRANSMIT_CAN_TP_PROVIDE_TX_BUFFER;\r
-\r
-               res = canTpTransmitHelper(txConfig, txRuntime);\r
-               switch (res) {\r
-               case BUFREQ_OK:\r
-               case BUFREQ_BUSY:\r
-                       ret = E_OK;\r
-                       break;\r
-               case BUFREQ_NOT_OK:\r
-                       ret = E_NOT_OK; /** @req CANTP072 */\r
-                       break;\r
-               default:\r
-                       ret = E_NOT_OK;\r
-                       break;\r
+       if( CanTpConfig.CanTpRxIdList[CanTpTxSduId].CanTpNSduIndex != 0xFFFF ) {\r
+               CanTp_InternalTxNSduId = CanTpConfig.CanTpRxIdList[CanTpTxSduId].CanTpNSduIndex;\r
+\r
+               txConfig =&CanTpConfig.CanTpNSduList[CanTp_InternalTxNSduId].configData.CanTpTxNSdu;\r
+\r
+               txRuntime = &CanTpRunTimeData.runtimeDataList[txConfig->CanTpTxChannel]; // Runtime data.\r
+               if (txRuntime->iso15765.state == IDLE) {\r
+                       txRuntime->pdurBufferCount = 0;\r
+                       txRuntime->pdurBufferCount = 0;\r
+                       txRuntime->transferCount = 0;\r
+                       txRuntime->iso15765.framesHandledCount = 0;\r
+                       txRuntime->transferTotal = CanTpTxInfoPtr->SduLength; /** @req CANTP225 */\r
+                       txRuntime->iso15765.stateTimeoutCount = CANTP_CONVERT_MS_TO_MAIN_CYCLES(txConfig->CanTpNcs);\r
+                       txRuntime->mode = CANTP_TX_PROCESSING;\r
+                       txRuntime->iso15765.state = TX_WAIT_CAN_TP_TRANSMIT_CAN_TP_PROVIDE_TX_BUFFER;\r
+\r
+                       res = canTpTransmitHelper(txConfig, txRuntime);\r
+                       switch (res) {\r
+                       case BUFREQ_OK:\r
+                       case BUFREQ_BUSY:\r
+                               ret = E_OK;\r
+                               break;\r
+                       case BUFREQ_NOT_OK:\r
+                               ret = E_NOT_OK; /** @req CANTP072 */\r
+                               break;\r
+                       default:\r
+                               ret = E_NOT_OK;\r
+                               break;\r
+                       }\r
+               } else {\r
+                       DEBUG( DEBUG_MEDIUM, "CanTp can't transmit, it is already occupied!\n", CanTpTxSduId);\r
+                       ret = E_NOT_OK;  /** @req CANTP123 *//** @req CANTP206 */\r
                }\r
-       } else {\r
-               DEBUG( DEBUG_MEDIUM, "CanTp can't transmit, it is already occupied!\n", CanTpTxSduId);\r
-               ret = E_NOT_OK;  /** @req CANTP123 *//** @req CANTP206 */\r
        }\r
+\r
        return ret; // CAN level error code.\r
 }\r
 \r
@@ -1224,6 +1231,7 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        const CanTp_AddressingFormantType *addressingFormat; // Configured\r
        CanTp_ChannelPrivateType *runtimeParams; // Params reside in RAM.\r
        ISO15765FrameType frameType;\r
+       PduIdType CanTpTxNSduId, CanTpRxNSduId;\r
 \r
        DEBUG( DEBUG_MEDIUM, "CanTp_RxIndication: PduId=%d, [", CanTpRxPduId);\r
        for (int i=0; i<CanTpRxPduPtr->SduLength; i++) {\r
@@ -1234,19 +1242,35 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        VALIDATE_NO_RV( CanTpRunTimeData.internalState == CANTP_ON,\r
                        SERVICE_ID_CANTP_RX_INDICATION, CANTP_E_UNINIT ); /** @req CANTP031 */\r
 \r
-       if ( CanTpConfig.CanTpNSduList[CanTpRxPduId].direction == IS015765_TRANSMIT ) {\r
-               txConfigParams = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[CanTpRxPduId].configData;  /** @req CANTP120 */\r
-               addressingFormat = &txConfigParams->CanTpAddressingMode;\r
-               runtimeParams = &CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel]; /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
+       addressingFormat = &CanTpConfig.CanTpRxIdList[CanTpRxPduId].CanTpAddressingMode;\r
+\r
+       /* TODO John - Use a different indication of not set than 0xFFFF? */\r
+       frameType = getFrameType(addressingFormat, CanTpRxPduPtr); /** @req CANTP094 *//** @req CANTP095 */\r
+       if( frameType == FLOW_CONTROL_CTS_FRAME ) {\r
+               if( CanTpConfig.CanTpRxIdList[CanTpRxPduId].CanTpReferringTxIndex != 0xFFFF ) {\r
+                       CanTpTxNSduId = CanTpConfig.CanTpRxIdList[CanTpRxPduId].CanTpReferringTxIndex;\r
+                       txConfigParams = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[CanTpTxNSduId].configData;\r
+                       runtimeParams = &CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel];\r
+               }\r
+               else {\r
+                       txConfigParams = NULL;\r
+               }\r
                rxConfigParams = NULL;\r
-       } else {\r
-               rxConfigParams = (CanTp_RxNSduType*)&CanTpConfig.CanTpNSduList[CanTpRxPduId].configData;  /** @req CANTP120 */\r
-               addressingFormat = &rxConfigParams->CanTpAddressingFormant;\r
-               runtimeParams = &CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
+       }\r
+       else {\r
+               if( CanTpConfig.CanTpRxIdList[CanTpRxPduId].CanTpNSduIndex != 0xFFFF ) {\r
+                       CanTpRxNSduId = CanTpConfig.CanTpRxIdList[CanTpRxPduId].CanTpNSduIndex;\r
+                       rxConfigParams = (CanTp_RxNSduType*)&CanTpConfig.CanTpNSduList[CanTpRxNSduId].configData;  /** @req CANTP120 */\r
+                       runtimeParams = &CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
+               }\r
+               else {\r
+                       rxConfigParams = NULL;\r
+               }\r
                txConfigParams = NULL;\r
        }\r
 \r
-       frameType = getFrameType(addressingFormat, CanTpRxPduPtr); /** @req CANTP094 *//** @req CANTP095 */\r
+\r
+\r
        switch (frameType) {\r
        case SINGLE_FRAME: {\r
                if (rxConfigParams != NULL) {\r
@@ -1299,6 +1323,7 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
 \r
 void CanTp_TxConfirmation(PduIdType CanTpTxPduId) /** @req CANTP076 */\r
 {\r
+       PduIdType CanTpNSduId;\r
        const CanTp_RxNSduType *rxConfigParams = NULL;\r
        const CanTp_TxNSduType *txConfigParams = NULL;\r
 \r
@@ -1310,16 +1335,21 @@ void CanTp_TxConfirmation(PduIdType CanTpTxPduId) /** @req CANTP076 */
                        SERVICE_ID_CANTP_TX_CONFIRMATION, CANTP_E_INVALID_TX_ID ); /** @req CANTP158 */\r
 \r
        /** @req CANTP236 */\r
-       if ( CanTpConfig.CanTpNSduList[CanTpTxPduId].direction == IS015765_TRANSMIT ) {\r
-               txConfigParams = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[CanTpTxPduId].configData;\r
-               CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel].iso15765.NasNarPending = FALSE;\r
+       if( CanTpConfig.CanTpRxIdList[CanTpTxPduId].CanTpNSduIndex != 0xFFFF ) {\r
+               CanTpNSduId = CanTpConfig.CanTpRxIdList[CanTpTxPduId].CanTpNSduIndex;\r
+               if ( CanTpConfig.CanTpNSduList[CanTpNSduId].direction == IS015765_TRANSMIT ) {\r
+                       txConfigParams = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[CanTpNSduId].configData;\r
+                       CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel].iso15765.NasNarPending = FALSE;\r
 #if (CANTP_IMMEDIATE_TX_CONFIRMATION == STD_OFF)\r
-               CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel].iso15765.txConfirmed = TRUE;\r
+                       CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel].iso15765.txConfirmed = TRUE;\r
 #endif\r
-       } else {\r
-               rxConfigParams = (CanTp_RxNSduType*)&CanTpConfig.CanTpNSduList[CanTpTxPduId].configData;\r
-               CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel].iso15765.NasNarPending = FALSE;\r
+               } else {\r
+                       rxConfigParams = (CanTp_RxNSduType*)&CanTpConfig.CanTpNSduList[CanTpNSduId].configData;\r
+                       CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel].iso15765.NasNarPending = FALSE;\r
+               }\r
        }\r
+\r
+\r
 }\r
 \r
 // - - - - - - - - - - - - - -\r
index e2f2c9e55f7c32e4bb1c6d4edcbd02fe960a69d4..8aa714b7391cbe60e6b0c466bace6cc15beb4bea 100644 (file)
@@ -65,7 +65,7 @@ typedef struct {
 } CanTp_NSaType; /** @req CANTP253 */\r
 \r
 typedef struct {\r
-       uint32 CanTpNTa; /** @req CANTP255 */\r
+       uint32 CanTpNTa; /** @req CANTP255 */ /* TODO John: Why is this 32-bit */\r
 } CanTp_NTaType; /** @req CANTP139 */\r
 \r
 typedef struct {\r
@@ -89,6 +89,7 @@ typedef struct {
 \r
 \r
 typedef struct {\r
+       const PduIdType CanTp_FcPduId; // When recieving this Pdu this conf can be used (if TA match in extended).\r
        const PduIdType CanIf_FcPduId; // The polite CanIf PDU index.\r
        const PduIdType PduR_PduId; // The polite PduR index.\r
        const CanTp_AddressingFormantType CanTpAddressingFormant;       /** @req CANTP242 */\r
@@ -114,6 +115,7 @@ typedef struct {
 typedef struct {\r
        const PduIdType CanIf_PduId; // The polite CanIf index.\r
        const PduIdType PduR_PduId; // The polite PduR index.\r
+       const PduIdType CanTp_FcPduId;\r
        const CanTp_AddressingFormantType CanTpAddressingMode; /** @req CANTP262 */\r
        const uint16 CanTpNas; /** @req CANTP263 */ /* N_As timeout for transmission of any CAN frame. */\r
        const uint16 CanTpNbs; /** @req CANTP264 */ /* N_Bs timeout of transmission until reception of next Flow Control. */\r
@@ -156,6 +158,12 @@ typedef struct {
        } configData;\r
 } CanTp_NSduType;\r
 \r
+typedef struct {\r
+       const CanTp_AddressingFormantType CanTpAddressingMode;\r
+       const PduIdType CanTpNSduIndex;\r
+       const PduIdType CanTpReferringTxIndex;\r
+} CanTp_RxIdType;\r
+\r
 // - - - - - - - - - - -\r
 \r
 /** Top level config container for CANTP implementation. */\r
@@ -166,6 +174,8 @@ typedef struct {
        /** */\r
        const CanTp_NSduType *CanTpNSduList;\r
 \r
+       const CanTp_RxIdType *CanTpRxIdList;\r
+\r
        /**  */\r
        //const CanTp_RxNSduType        *CanTpRxNSduList;\r
 \r