1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
8 Description: source file for Epl-Obd-Userspace-module
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
23 3. Neither the name of SYSTEC electronic GmbH nor the names of its
24 contributors may be used to endorse or promote products derived
25 from this software without prior written permission. For written
26 permission, please contact info@systec-electronic.com.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32 COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 POSSIBILITY OF SUCH DAMAGE.
43 If a provision of this License is or becomes illegal, invalid or
44 unenforceable in any jurisdiction, that shall not affect:
45 1. the validity or enforceability in that jurisdiction of any other
46 provision of this License; or
47 2. the validity or enforceability in other jurisdictions of that or
48 any other provision of this License.
50 -------------------------------------------------------------------------
52 $RCSfile: EplObdu.c,v $
56 $Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
63 -------------------------------------------------------------------------
67 2006/06/19 k.t.: start of the implementation
69 ****************************************************************************/
72 #include "user/EplObdu.h"
73 #include "user/EplObduCal.h"
75 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
76 /***************************************************************************/
79 /* G L O B A L D E F I N I T I O N S */
82 /***************************************************************************/
84 //---------------------------------------------------------------------------
86 //---------------------------------------------------------------------------
88 //---------------------------------------------------------------------------
90 //---------------------------------------------------------------------------
92 //---------------------------------------------------------------------------
94 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
97 // local function prototypes
98 //---------------------------------------------------------------------------
102 //=========================================================================//
104 // P U B L I C F U N C T I O N S //
106 //=========================================================================//
108 //---------------------------------------------------------------------------
110 // Function: EplObduWriteEntry()
112 // Description: Function writes data to an OBD entry. Strings
113 // are stored with added '\0' character.
115 // Parameters: uiIndex_p = Index of the OD entry
116 // uiSubIndex_p = Subindex of the OD Entry
117 // pSrcData_p = Pointer to the data to write
118 // Size_p = Size of the data in Byte
120 // Return: tEplKernel = Errorcode
125 //---------------------------------------------------------------------------
126 EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry (unsigned int uiIndex_p,
127 unsigned int uiSubIndex_p,
133 Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
139 //---------------------------------------------------------------------------
141 // Function: EplObduReadEntry()
143 // Description: The function reads an object entry. The application
144 // can always read the data even if attrib kEplObdAccRead
145 // is not set. The attrib is only checked up for SDO transfer.
147 // Parameters: uiIndex_p = Index oof the OD entry to read
148 // uiSubIndex_p = Subindex to read
149 // pDstData_p = pointer to the buffer for data
150 // Offset_p = offset in data for read access
151 // pSize_p = IN: Size of the buffer
152 // OUT: number of readed Bytes
154 // Return: tEplKernel = errorcode
158 //---------------------------------------------------------------------------
159 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry (unsigned int uiIndex_p,
160 unsigned int uiSubIndex_p,
162 tEplObdSize* pSize_p)
166 Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
172 //---------------------------------------------------------------------------
174 // Function: EplObdAccessOdPart()
176 // Description: restores default values of one part of OD
178 // Parameters: ObdPart_p = od-part to reset
179 // Direction_p = directory flag for
181 // Return: tEplKernel = errorcode
185 //---------------------------------------------------------------------------
186 EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart (tEplObdPart ObdPart_p,
187 tEplObdDir Direction_p)
191 Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
196 //---------------------------------------------------------------------------
198 // Function: EplObduDefineVar()
200 // Description: defines a variable in OD
202 // Parameters: pEplVarParam_p = varentry
204 // Return: tEplKernel = errorcode
208 //---------------------------------------------------------------------------
209 EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar (tEplVarParam MEM* pVarParam_p)
213 Ret = EplObduCalDefineVar(pVarParam_p);
218 //---------------------------------------------------------------------------
220 // Function: EplObduGetObjectDataPtr()
222 // Description: It returnes the current data pointer. But if object is an
223 // constant object it returnes the default pointer.
225 // Parameters: uiIndex_p = Index of the entry
226 // uiSubindex_p = Subindex of the entry
228 // Return: void * = pointer to object data
232 //---------------------------------------------------------------------------
233 EPLDLLEXPORT void* PUBLIC EplObduGetObjectDataPtr (unsigned int uiIndex_p,
234 unsigned int uiSubIndex_p)
238 pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
243 //---------------------------------------------------------------------------
245 // Function: EplObduRegisterUserOd()
247 // Description: function registers the user OD
249 // Parameters: pUserOd_p =pointer to user ODd
251 // Return: tEplKernel = errorcode
255 //---------------------------------------------------------------------------
256 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
257 EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd (tEplObdEntryPtr pUserOd_p)
261 Ret = EplObduCalRegisterUserOd(pUserOd_p);
267 //---------------------------------------------------------------------------
269 // Function: EplObduInitVarEntry()
271 // Description: function to initialize VarEntry dependened on object type
273 // Parameters: pVarEntry_p = pointer to var entry structure
274 // bType_p = object type
275 // ObdSize_p = size of object data
281 //---------------------------------------------------------------------------
282 EPLDLLEXPORT void PUBLIC EplObduInitVarEntry (tEplObdVarEntry MEM* pVarEntry_p,
283 BYTE bType_p, tEplObdSize ObdSize_p)
285 EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
288 //---------------------------------------------------------------------------
290 // Function: EplObduGetDataSize()
292 // Description: function to initialize VarEntry dependened on object type
294 // gets the data size of an object
295 // for string objects it returnes the string length
297 // Parameters: uiIndex_p = Index
298 // uiSubIndex_p= Subindex
300 // Return: tEplObdSize
304 //---------------------------------------------------------------------------
305 EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
306 unsigned int uiSubIndex_p)
310 Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
315 //---------------------------------------------------------------------------
317 // Function: EplObduGetNodeId()
319 // Description: function returns nodeid from entry 0x1F93
324 // Return: unsigned int = Node Id
328 //---------------------------------------------------------------------------
329 EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
331 unsigned int uiNodeId;
333 uiNodeId = EplObduCalGetNodeId();
338 //---------------------------------------------------------------------------
340 // Function: EplObduSetNodeId()
342 // Description: function sets nodeid in entry 0x1F93
345 // Parameters: uiNodeId_p = Node Id to set
346 // NodeIdType_p= Type on which way the Node Id was set
348 // Return: tEplKernel = Errorcode
352 //---------------------------------------------------------------------------
353 EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
354 tEplObdNodeIdType NodeIdType_p)
358 Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
363 //---------------------------------------------------------------------------
365 // Function: EplObduGetAccessType()
367 // Description: Function returns accesstype of the entry
369 // Parameters: uiIndex_p = Index of the OD entry
370 // uiSubIndex_p = Subindex of the OD Entry
371 // pAccessTyp_p = pointer to buffer to store accesstyp
373 // Return: tEplKernel = Errorcode
378 //---------------------------------------------------------------------------
379 EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
380 unsigned int uiSubIndex_p,
381 tEplObdAccess* pAccessTyp_p)
383 tEplObdAccess AccessType;
385 AccessType = EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
390 //---------------------------------------------------------------------------
392 // Function: EplObdReaduEntryToLe()
394 // Description: The function reads an object entry from the byteoder
395 // of the system to the little endian byteorder for numeric values.
396 // For other types a normal read will be processed. This is usefull for
397 // the PDO and SDO module. The application
398 // can always read the data even if attrib kEplObdAccRead
399 // is not set. The attrib is only checked up for SDO transfer.
401 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
402 // uiIndex_p = Index of the OD entry to read
403 // uiSubIndex_p = Subindex to read
404 // pDstData_p = pointer to the buffer for data
405 // Offset_p = offset in data for read access
406 // pSize_p = IN: Size of the buffer
407 // OUT: number of readed Bytes
409 // Return: tEplKernel
413 //---------------------------------------------------------------------------
414 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe (unsigned int uiIndex_p,
415 unsigned int uiSubIndex_p,
417 tEplObdSize * pSize_p)
421 Ret = EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
426 //---------------------------------------------------------------------------
428 // Function: EplObduWriteEntryFromLe()
430 // Description: Function writes data to an OBD entry from a source with
431 // little endian byteorder to the od with system specuific
432 // byteorder. Not numeric values will only by copied. Strings
433 // are stored with added '\0' character.
435 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
436 // uiIndex_p = Index of the OD entry
437 // uiSubIndex_p = Subindex of the OD Entry
438 // pSrcData_p = Pointer to the data to write
439 // Size_p = Size of the data in Byte
441 // Return: tEplKernel = Errorcode
446 //---------------------------------------------------------------------------
447 EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe (unsigned int uiIndex_p,
448 unsigned int uiSubIndex_p,
454 Ret = EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
459 //---------------------------------------------------------------------------
461 // Function: EplObduSearchVarEntry()
463 // Description: gets variable from OD
465 // Parameters: uiIndex_p = index of the var entry to search
466 // uiSubindex_p = subindex of var entry to search
467 // ppVarEntry_p = pointer to the pointer to the varentry
469 // Return: tEplKernel
473 //---------------------------------------------------------------------------
474 EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry (EPL_MCO_DECL_INSTANCE_PTR_
475 unsigned int uiIndex_p,
476 unsigned int uiSubindex_p,
477 tEplObdVarEntry MEM** ppVarEntry_p)
481 Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
485 //=========================================================================//
487 // P R I V A T E F U N C T I O N S //
489 //=========================================================================//
491 //---------------------------------------------------------------------------
507 //---------------------------------------------------------------------------
509 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)