]> rtime.felk.cvut.cz Git - arc.git/commitdiff
WIP: Searching for the FC TxTdu when receiving FC Pdu.
authorjohn <devnull@localhost>
Wed, 30 Nov 2011 15:48:16 +0000 (16:48 +0100)
committerjohn <devnull@localhost>
Wed, 30 Nov 2011 15:48:16 +0000 (16:48 +0100)
communication/CanTp/CanTp.c
include/CanTp_Types.h

index c5d3a8b6dcee218cffb5822dafe97432e59e276d..0a70c51680572f978f9ba40edc49707cbb58420a 100644 (file)
@@ -1103,6 +1103,36 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
 \r
 // - - - - - - - - - - - - - -\r
 \r
+static Std_ReturnType getFcIndex(const PduIdType rxId, const CanTp_AddressingFormantType *formatType,\r
+               const PduInfoType *CanTpRxPduPtr, CanTp_TxNSduType* txConfig ) {\r
+       Std_ReturnType retValue = E_NOK;\r
+       boolean bIsExtended = (*formatType == CANTP_EXTENDED);\r
+       uint8 txId = START_OF_TX_CONFIG;\r
+\r
+       /* TODO: John - Manage if there are no Tx configs */\r
+       do {\r
+               txConfig = &CanTpConfig.CanTpNSduList[txId].configData;\r
+               if( txConfig->CanTp_FcPduId == rxId ) {\r
+                       if( !(CANTP_EXTENDED == *formatType) &&\r
+                                       CANTP_EXTENDED != txConfig->CanTpAddressingFormant ) {\r
+                               retValue = E_OK;\r
+                               break;\r
+                       } else {\r
+\r
+                               if( CANTP_EXTENDED == txConfig->CanTpAddressingFormant &&\r
+                                               CanTpRxPduPtr->SduDataPtr[0] == txConfig->CanTp_NSaType->CanTpNSa ) {\r
+                                       /* TA in received frame matches SA in the tx channel */\r
+                                       retValue = E_OK;\r
+                                       break;\r
+                               }\r
+                       }\r
+               }\r
+       } while( &CanTpConfig.CanTpNSduList[txId].listItemType != CANTP_END_OF_LIST );\r
+\r
+       return retValue;\r
+}\r
+// - - - - - - - - - - - - - -\r
+\r
 \r
 Std_ReturnType CanTp_Transmit(PduIdType CanTpTxSduId,\r
                const PduInfoType *CanTpTxInfoPtr)  /** @req CANTP176 */\r
@@ -1235,10 +1265,7 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
                        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
-               rxConfigParams = NULL;\r
+               DEBUG( DEBUG_MEDIUM, "Received pduId which is not RECEIVE - ignoring!\n");\r
        } else {\r
                rxConfigParams = (CanTp_RxNSduType*)&CanTpConfig.CanTpNSduList[CanTpRxPduId].configData;  /** @req CANTP120 */\r
                addressingFormat = &rxConfigParams->CanTpAddressingFormant;\r
@@ -1246,7 +1273,20 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
                txConfigParams = NULL;\r
        }\r
 \r
+       /* TODO: John - Note that the addressing format is taken from the rxConfig\r
+        * (since we don't know if there is a tx config yet */\r
        frameType = getFrameType(addressingFormat, CanTpRxPduPtr); /** @req CANTP094 *//** @req CANTP095 */\r
+\r
+       if( frameType == FLOW_CONTROL_CTS_FRAME ) {\r
+               Std_ReturnType ret = getFcIndex(CanTpRxPduId, addressingFormat, CanTpRxPduPtr, &rxConfigParams->CanTpNSa, &txConfigParams );\r
+               if( ret != E_OK ) {\r
+                       /* No Tx channel found - set to NULL in order to ignore */\r
+                       txConfigParams = NULL;\r
+               }\r
+               runtimeParams = &CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpRxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
+               rxConfigParams = NULL;\r
+       }\r
+\r
        switch (frameType) {\r
        case SINGLE_FRAME: {\r
                if (rxConfigParams != NULL) {\r
index e2f2c9e55f7c32e4bb1c6d4edcbd02fe960a69d4..2269c2746629adacb38ce5197143e2750db1f2a3 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