]> rtime.felk.cvut.cz Git - arc.git/blob - communication/PduR/PduR_Routing.c
74f83db54769e17ec76a3d5f28cd66ddbdd606ed
[arc.git] / communication / PduR / PduR_Routing.c
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 \r
17 #include "PduR.h"\r
18 \r
19 \r
20 #include <string.h>\r
21 #include "debug.h"\r
22 #if defined(USE_DEM)\r
23 #include "Dem.h"\r
24 #endif\r
25 \r
26 \r
27 #if PDUR_CANIF_SUPPORT == STD_ON\r
28 #include "CanIf.h"\r
29 #endif\r
30 #if PDUR_CANTP_SUPPORT == STD_ON\r
31 #include "CanTp.h"\r
32 #endif\r
33 #if PDUR_LINIF_SUPPORT == STD_ON\r
34 #include "LinIf.h"\r
35 #endif\r
36 #if PDUR_COM_SUPPORT == STD_ON\r
37 #include "Com.h"\r
38 #endif\r
39 #if PDUR_DCM_SUPPORT == STD_ON\r
40 #include "Dcm.h"\r
41 #endif\r
42 #if PDUR_SOAD_SUPPORT == STD_ON\r
43 #include "SoAd.h"\r
44 #endif\r
45 \r
46 \r
47 #if PDUR_ZERO_COST_OPERATION == STD_OFF\r
48 \r
49 Std_ReturnType PduR_ARC_RouteTransmit(const PduRDestPdu_type * destination, const PduInfoType * pduInfo) {\r
50         Std_ReturnType retVal = E_NOT_OK;\r
51         switch (destination->DestModule) {\r
52         case ARC_PDUR_CANIF:\r
53 #if PDUR_CANIF_SUPPORT == STD_ON\r
54                 retVal = CanIf_Transmit(destination->DestPduId, pduInfo);\r
55 #endif\r
56                 break;\r
57         case ARC_PDUR_LINIF:\r
58 #if PDUR_LINIF_SUPPORT == STD_ON\r
59                 retVal = LinIf_Transmit(destination->DestPduId, pduInfo);\r
60 #endif\r
61                 break;\r
62         case ARC_PDUR_CANTP:\r
63 #if PDUR_CANTP_SUPPORT == STD_ON\r
64                 retVal = CanTp_Transmit(destination->DestPduId, pduInfo);\r
65 #endif\r
66                 break;\r
67         case ARC_PDUR_SOADIF:\r
68 #if PDUR_SOAD_SUPPORT == STD_ON\r
69                 retVal = SoAdIf_Transmit(destination->DestPduId, pduInfo);\r
70 #endif\r
71                 break;\r
72         case ARC_PDUR_SOADTP:\r
73 #if PDUR_SOAD_SUPPORT == STD_ON\r
74                 retVal = SoAdTp_Transmit(destination->DestPduId, pduInfo);\r
75 #endif\r
76                 break;\r
77         default:\r
78                 retVal = E_NOT_OK;\r
79                 break;\r
80         }\r
81         // TODO error reporting here.\r
82         return retVal;\r
83 }\r
84 \r
85 void PduR_ARC_RouteRxIndication(const PduRDestPdu_type * destination, const PduInfoType *PduInfo) {\r
86 \r
87         switch (destination->DestModule) {\r
88         case ARC_PDUR_COM:\r
89 #if PDUR_COM_SUPPORT == STD_ON\r
90                 Com_RxIndication(destination->DestPduId, PduInfo);\r
91 #endif\r
92                 break;\r
93         case ARC_PDUR_DCM:\r
94 #if PDUR_DCM_SUPPORT == STD_ON\r
95                 Dcm_RxIndication(destination->DestPduId, *PduInfo->SduDataPtr);\r
96 #endif\r
97                 break;\r
98         default:\r
99                 break;\r
100         }\r
101         // TODO error reporting here.\r
102 }\r
103 \r
104 void PduR_ARC_RouteTxConfirmation(const PduRRoutingPath_type *route, uint8 result) {\r
105         switch (route->SrcModule) {\r
106         case ARC_PDUR_COM:\r
107 #if PDUR_COM_SUPPORT == STD_ON\r
108                 Com_TxConfirmation(route->SrcPduId);\r
109 #endif\r
110                 break;\r
111         case ARC_PDUR_DCM:\r
112 #if PDUR_DCM_SUPPORT == STD_ON\r
113                 Dcm_TxConfirmation(route->SrcPduId, result);\r
114 #endif\r
115                 break;\r
116         default:\r
117                 break;\r
118         }\r
119         // TODO error reporting here.\r
120 }\r
121 \r
122 Std_ReturnType PduR_ARC_RouteTriggerTransmit(const PduRRoutingPath_type *route, PduInfoType * pduInfo) {\r
123         Std_ReturnType retVal = E_NOT_OK;\r
124         switch (route->SrcModule) {\r
125         case ARC_PDUR_COM:\r
126 #if PDUR_COM_SUPPORT == STD_ON\r
127                 retVal = Com_TriggerTransmit(route->SrcPduId, pduInfo);\r
128 #endif\r
129                 break;\r
130         default:\r
131                 retVal = E_NOT_OK;\r
132                 break;\r
133         }\r
134         // TODO error reporting here.\r
135         return retVal;\r
136 }\r
137 \r
138 BufReq_ReturnType PduR_ARC_RouteProvideRxBuffer(const PduRDestPdu_type * destination, PduLengthType TpSduLength, PduInfoType** PduInfoPtr) {\r
139         BufReq_ReturnType retVal;\r
140         switch (destination->DestModule) {\r
141         case ARC_PDUR_DCM:\r
142 #if PDUR_DCM_SUPPORT == STD_ON\r
143                 retVal = Dcm_ProvideRxBuffer(destination->DestPduId, TpSduLength, PduInfoPtr);\r
144 #endif\r
145                 break;\r
146         default:\r
147                 retVal = BUFREQ_NOT_OK;\r
148                 break;\r
149         }\r
150         // TODO error reporting here.\r
151         return retVal;\r
152 }\r
153 \r
154 BufReq_ReturnType PduR_ARC_RouteProvideTxBuffer(const PduRRoutingPath_type *route, PduLengthType TpSduLength, PduInfoType** PduInfoPtr) {\r
155         BufReq_ReturnType retVal;\r
156         switch (route->SrcModule) {\r
157         case ARC_PDUR_DCM:\r
158 #if PDUR_DCM_SUPPORT == STD_ON\r
159                 retVal = Dcm_ProvideTxBuffer(route->SrcPduId, PduInfoPtr, TpSduLength);\r
160 #endif\r
161                 break;\r
162         default:\r
163                 retVal = BUFREQ_NOT_OK;\r
164                 break;\r
165         }\r
166         // TODO error reporting here.\r
167         return retVal;\r
168 }\r
169 \r
170 #endif\r