1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: source file for communication abstraction layer
9 for the Epl-Obd-Userspace-Modul
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions
17 1. Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
20 2. Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
24 3. Neither the name of SYSTEC electronic GmbH nor the names of its
25 contributors may be used to endorse or promote products derived
26 from this software without prior written permission. For written
27 permission, please contact info@systec-electronic.com.
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40 POSSIBILITY OF SUCH DAMAGE.
44 If a provision of this License is or becomes illegal, invalid or
45 unenforceable in any jurisdiction, that shall not affect:
46 1. the validity or enforceability in that jurisdiction of any other
47 provision of this License; or
48 2. the validity or enforceability in other jurisdictions of that or
49 any other provision of this License.
51 -------------------------------------------------------------------------
53 $RCSfile: EplObduCal.c,v $
57 $Revision: 1.6 $ $Date: 2008/10/17 15:32:32 $
64 -------------------------------------------------------------------------
68 2006/06/19 k.t.: start of the implementation
70 ****************************************************************************/
72 #include "user/EplObduCal.h"
73 #include "kernel/EplObdk.h"
75 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0) && (EPL_OBD_USE_KERNEL != FALSE)
77 /***************************************************************************/
80 /* G L O B A L D E F I N I T I O N S */
83 /***************************************************************************/
85 //---------------------------------------------------------------------------
87 //---------------------------------------------------------------------------
89 //---------------------------------------------------------------------------
91 //---------------------------------------------------------------------------
93 //---------------------------------------------------------------------------
95 //---------------------------------------------------------------------------
97 //---------------------------------------------------------------------------
98 // local function prototypes
99 //---------------------------------------------------------------------------
101 //=========================================================================//
103 // P U B L I C F U N C T I O N S //
105 //=========================================================================//
107 //---------------------------------------------------------------------------
109 // Function: EplObduCalWriteEntry()
111 // Description: Function encapsulate access of function EplObdWriteEntry
113 // Parameters: uiIndex_p = Index of the OD entry
114 // uiSubIndex_p = Subindex of the OD Entry
115 // pSrcData_p = Pointer to the data to write
116 // Size_p = Size of the data in Byte
118 // Return: tEplKernel = Errorcode
123 //---------------------------------------------------------------------------
124 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntry(unsigned int uiIndex_p,
125 unsigned int uiSubIndex_p,
131 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
132 Ret = EplObdWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
134 Ret = kEplSuccessful;
140 //---------------------------------------------------------------------------
142 // Function: EplObduCalReadEntry()
144 // Description: Function encapsulate access of function EplObdReadEntry
146 // Parameters: uiIndex_p = Index oof the OD entry to read
147 // uiSubIndex_p = Subindex to read
148 // pDstData_p = pointer to the buffer for data
149 // Offset_p = offset in data for read access
150 // pSize_p = IN: Size of the buffer
151 // OUT: number of readed Bytes
153 // Return: tEplKernel = errorcode
157 //---------------------------------------------------------------------------
158 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntry(unsigned int uiIndex_p,
159 unsigned int uiSubIndex_p,
161 tEplObdSize * pSize_p)
165 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
166 Ret = EplObdReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
168 Ret = kEplSuccessful;
174 //---------------------------------------------------------------------------
176 // Function: EplObduCalAccessOdPart()
178 // Description: Function encapsulate access of function EplObdAccessOdPart
180 // Parameters: ObdPart_p = od-part to reset
181 // Direction_p = directory flag for
183 // Return: tEplKernel = errorcode
187 //---------------------------------------------------------------------------
188 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalAccessOdPart(tEplObdPart ObdPart_p,
189 tEplObdDir Direction_p)
193 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
194 Ret = EplObdAccessOdPart(ObdPart_p, Direction_p);
196 Ret = kEplSuccessful;
202 //---------------------------------------------------------------------------
204 // Function: EplObduCalDefineVar()
206 // Description: Function encapsulate access of function EplObdDefineVar
208 // Parameters: pEplVarParam_p = varentry
210 // Return: tEplKernel = errorcode
214 //---------------------------------------------------------------------------
215 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalDefineVar(tEplVarParam MEM *
220 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
221 Ret = EplObdDefineVar(pVarParam_p);
223 Ret = kEplSuccessful;
229 //---------------------------------------------------------------------------
231 // Function: EplObduCalGetObjectDataPtr()
233 // Description: Function encapsulate access of function EplObdGetObjectDataPtr
235 // Parameters: uiIndex_p = Index of the entry
236 // uiSubindex_p = Subindex of the entry
238 // Return: void * = pointer to object data
242 //---------------------------------------------------------------------------
243 EPLDLLEXPORT void *PUBLIC EplObduCalGetObjectDataPtr(unsigned int uiIndex_p,
244 unsigned int uiSubIndex_p)
248 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
249 pData = EplObdGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
257 //---------------------------------------------------------------------------
259 // Function: EplObduCalRegisterUserOd()
261 // Description: Function encapsulate access of function EplObdRegisterUserOd
263 // Parameters: pUserOd_p = pointer to user OD
265 // Return: tEplKernel = errorcode
269 //---------------------------------------------------------------------------
270 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
271 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalRegisterUserOd(tEplObdEntryPtr
276 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
277 Ret = EplObdRegisterUserOd(pUserOd_p);
279 Ret = kEplSuccessful;
286 //---------------------------------------------------------------------------
288 // Function: EplObduCalInitVarEntry()
290 // Description: Function encapsulate access of function EplObdInitVarEntry
292 // Parameters: pVarEntry_p = pointer to var entry structure
293 // bType_p = object type
294 // ObdSize_p = size of object data
300 //---------------------------------------------------------------------------
301 EPLDLLEXPORT void PUBLIC EplObduCalInitVarEntry(tEplObdVarEntry MEM *
302 pVarEntry_p, BYTE bType_p,
303 tEplObdSize ObdSize_p)
305 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
306 EplObdInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
310 //---------------------------------------------------------------------------
312 // Function: EplObduCalGetDataSize()
314 // Description: Function encapsulate access of function EplObdGetDataSize
316 // gets the data size of an object
317 // for string objects it returnes the string length
319 // Parameters: uiIndex_p = Index
320 // uiSubIndex_p= Subindex
322 // Return: tEplObdSize
326 //---------------------------------------------------------------------------
327 EPLDLLEXPORT tEplObdSize PUBLIC EplObduCalGetDataSize(unsigned int uiIndex_p,
328 unsigned int uiSubIndex_p)
332 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
333 Size = EplObdGetDataSize(uiIndex_p, uiSubIndex_p);
341 //---------------------------------------------------------------------------
343 // Function: EplObduCalGetNodeId()
345 // Description: Function encapsulate access of function EplObdGetNodeId
350 // Return: unsigned int = Node Id
354 //---------------------------------------------------------------------------
355 EPLDLLEXPORT unsigned int PUBLIC EplObduCalGetNodeId()
357 unsigned int uiNodeId;
359 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
360 uiNodeId = EplObdGetNodeId();
368 //---------------------------------------------------------------------------
370 // Function: EplObduCalSetNodeId()
372 // Description: Function encapsulate access of function EplObdSetNodeId
375 // Parameters: uiNodeId_p = Node Id to set
376 // NodeIdType_p= Type on which way the Node Id was set
378 // Return: tEplKernel = Errorcode
382 //---------------------------------------------------------------------------
383 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalSetNodeId(unsigned int uiNodeId_p,
389 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
390 Ret = EplObdSetNodeId(uiNodeId_p, NodeIdType_p);
392 Ret = kEplSuccessful;
398 //---------------------------------------------------------------------------
400 // Function: EplObduCalGetAccessType()
402 // Description: Function encapsulate access of function EplObdGetAccessType
404 // Parameters: uiIndex_p = Index of the OD entry
405 // uiSubIndex_p = Subindex of the OD Entry
406 // pAccessTyp_p = pointer to buffer to store accesstype
408 // Return: tEplKernel = errorcode
413 //---------------------------------------------------------------------------
414 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalGetAccessType(unsigned int uiIndex_p,
420 tEplObdAccess AccesType;
422 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
423 AccesType = EplObdGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
432 //---------------------------------------------------------------------------
434 // Function: EplObduCalReadEntryToLe()
436 // Description: Function encapsulate access of function EplObdReadEntryToLe
438 // Parameters: uiIndex_p = Index of the OD entry to read
439 // uiSubIndex_p = Subindex to read
440 // pDstData_p = pointer to the buffer for data
441 // Offset_p = offset in data for read access
442 // pSize_p = IN: Size of the buffer
443 // OUT: number of readed Bytes
445 // Return: tEplKernel
449 //---------------------------------------------------------------------------
450 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalReadEntryToLe(unsigned int uiIndex_p,
454 tEplObdSize * pSize_p)
458 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
459 Ret = EplObdReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
461 Ret = kEplSuccessful;
467 //---------------------------------------------------------------------------
469 // Function: EplObduCalWriteEntryFromLe()
471 // Description: Function encapsulate access of function EplObdWriteEntryFromLe
473 // Parameters: uiIndex_p = Index of the OD entry
474 // uiSubIndex_p = Subindex of the OD Entry
475 // pSrcData_p = Pointer to the data to write
476 // Size_p = Size of the data in Byte
478 // Return: tEplKernel = Errorcode
483 //---------------------------------------------------------------------------
484 EPLDLLEXPORT tEplKernel PUBLIC EplObduCalWriteEntryFromLe(unsigned int
493 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
495 EplObdWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
497 Ret = kEplSuccessful;
502 //---------------------------------------------------------------------------
504 // Function: EplObduCalSearchVarEntry()
506 // Description: gets variable from OD
508 // Parameters: uiIndex_p = index of the var entry to search
509 // uiSubindex_p = subindex of var entry to search
510 // ppVarEntry_p = pointer to the pointer to the varentry
512 // Return: tEplKernel
516 //---------------------------------------------------------------------------
517 EPLDLLEXPORT tEplKernel PUBLIC
518 EplObduCalSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_ unsigned int uiIndex_p,
519 unsigned int uiSubindex_p,
520 tEplObdVarEntry MEM ** ppVarEntry_p)
524 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDK)) != 0)
525 Ret = EplObdSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
527 Ret = kEplSuccessful;
532 //=========================================================================//
534 // P R I V A T E F U N C T I O N S //
536 //=========================================================================//
538 //---------------------------------------------------------------------------
554 //---------------------------------------------------------------------------
556 #endif //(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)