]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Added fcIndex outparameter to getFCIndex function.
authorjohn <devnull@localhost>
Mon, 5 Dec 2011 11:04:29 +0000 (12:04 +0100)
committerjohn <devnull@localhost>
Mon, 5 Dec 2011 11:04:29 +0000 (12:04 +0100)
Temporary solution - assuming standard addressing when receiving non-polite PduIndex.

communication/CanTp/CanTp.c

index ca76bb21ff78df959aaf72900627408e4c67b699..a1b35733f5b698f81cc6e0ac306610e80bb0188a 100644 (file)
@@ -1104,7 +1104,7 @@ static INLINE BufReq_ReturnType canTpTransmitHelper(const CanTp_TxNSduType *txCo
 // - - - - - - - - - - - - - -\r
 \r
 static Std_ReturnType getFcIndex(const PduIdType rxId, const CanTp_AddressingFormantType *formatType,\r
-               const PduInfoType *CanTpRxPduPtr ) {\r
+               const PduInfoType *CanTpRxPduPtr, uint16* fcIndex ) {\r
        Std_ReturnType retValue = E_NOT_OK;\r
        uint8 txId = START_OF_TX_CONFIG;\r
        CanTp_TxNSduType* txConfig;\r
@@ -1115,6 +1115,7 @@ static Std_ReturnType getFcIndex(const PduIdType rxId, const CanTp_AddressingFor
                if( txConfig->CanTp_FcPduId == rxId ) {\r
                        if( !(CANTP_EXTENDED == *formatType) &&\r
                                        CANTP_EXTENDED != txConfig->CanTpAddressingMode ) {\r
+                               *fcIndex = txId;\r
                                retValue = E_OK;\r
                                break;\r
                        } else {\r
@@ -1127,7 +1128,7 @@ static Std_ReturnType getFcIndex(const PduIdType rxId, const CanTp_AddressingFor
                                }\r
                        }\r
                }\r
-       } while( CanTpConfig.CanTpNSduList[txId].listItemType != CANTP_END_OF_LIST );\r
+       } while( CanTpConfig.CanTpNSduList[txId++].listItemType != CANTP_END_OF_LIST );\r
 \r
        return retValue;\r
 }\r
@@ -1254,6 +1255,8 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        const CanTp_AddressingFormantType *addressingFormat; // Configured\r
        CanTp_ChannelPrivateType *runtimeParams; // Params reside in RAM.\r
        ISO15765FrameType frameType;\r
+       uint16 fcIndex;\r
+       CanTp_AddressingFormantType standardAddressing = CANTP_STANDARD;\r
 \r
        DEBUG( DEBUG_MEDIUM, "CanTp_RxIndication: PduId=%d, [", CanTpRxPduId);\r
        for (int i=0; i<CanTpRxPduPtr->SduLength; i++) {\r
@@ -1264,13 +1267,20 @@ 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
-               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
-               runtimeParams = &CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
-               txConfigParams = NULL;\r
+       if( CanTpRxPduId < START_OF_NON_POLITE )\r
+       {\r
+               if ( CanTpConfig.CanTpNSduList[CanTpRxPduId].direction == IS015765_TRANSMIT ) {\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
+                       runtimeParams = &CanTpRunTimeData.runtimeDataList[rxConfigParams->CanTpRxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
+                       txConfigParams = NULL;\r
+               }\r
+       }\r
+       else {\r
+               /* TODO: John - Assume standard when receiving out of P-Index - probably needs refactoring to solve */\r
+               addressingFormat = &standardAddressing;\r
        }\r
 \r
        /* TODO: John - Note that the addressing format is taken from the rxConfig\r
@@ -1278,13 +1288,14 @@ void CanTp_RxIndication_Main(PduIdType CanTpRxPduId,
        frameType = getFrameType(addressingFormat, CanTpRxPduPtr); /** @req CANTP094 *//** @req CANTP095 */\r
 \r
        if( frameType == FLOW_CONTROL_CTS_FRAME ) {\r
-               Std_ReturnType ret = getFcIndex(CanTpRxPduId, addressingFormat, CanTpRxPduPtr );\r
+               Std_ReturnType ret = getFcIndex(CanTpRxPduId, addressingFormat, CanTpRxPduPtr, &fcIndex );\r
                if( ret != E_OK ) {\r
                        /* No Tx channel found - set to NULL in order to ignore */\r
                        txConfigParams = NULL;\r
                        runtimeParams = NULL;\r
                }\r
                else {\r
+                       txConfigParams = (CanTp_TxNSduType*)&CanTpConfig.CanTpNSduList[fcIndex].configData;\r
                        runtimeParams = &CanTpRunTimeData.runtimeDataList[txConfigParams->CanTpTxChannel];  /** @req CANTP096 *//** @req CANTP121 *//** @req CANTP122 *//** @req CANTP190 */\r
                }\r
                rxConfigParams = NULL;\r