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 //---------------------------------------------------------------------------
100 //=========================================================================//
102 // P U B L I C F U N C T I O N S //
104 //=========================================================================//
106 //---------------------------------------------------------------------------
108 // Function: EplObduWriteEntry()
110 // Description: Function writes data to an OBD entry. Strings
111 // are stored with added '\0' character.
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 EplObduWriteEntry(unsigned int uiIndex_p,
125 unsigned int uiSubIndex_p,
131 Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
136 //---------------------------------------------------------------------------
138 // Function: EplObduReadEntry()
140 // Description: The function reads an object entry. The application
141 // can always read the data even if attrib kEplObdAccRead
142 // is not set. The attrib is only checked up for SDO transfer.
144 // Parameters: uiIndex_p = Index oof the OD entry to read
145 // uiSubIndex_p = Subindex to read
146 // pDstData_p = pointer to the buffer for data
147 // Offset_p = offset in data for read access
148 // pSize_p = IN: Size of the buffer
149 // OUT: number of readed Bytes
151 // Return: tEplKernel = errorcode
155 //---------------------------------------------------------------------------
156 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry(unsigned int uiIndex_p,
157 unsigned int uiSubIndex_p,
159 tEplObdSize * pSize_p)
163 Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
168 //---------------------------------------------------------------------------
170 // Function: EplObdAccessOdPart()
172 // Description: restores default values of one part of OD
174 // Parameters: ObdPart_p = od-part to reset
175 // Direction_p = directory flag for
177 // Return: tEplKernel = errorcode
181 //---------------------------------------------------------------------------
182 EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart(tEplObdPart ObdPart_p,
183 tEplObdDir Direction_p)
187 Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
192 //---------------------------------------------------------------------------
194 // Function: EplObduDefineVar()
196 // Description: defines a variable in OD
198 // Parameters: pEplVarParam_p = varentry
200 // Return: tEplKernel = errorcode
204 //---------------------------------------------------------------------------
205 EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar(tEplVarParam MEM * pVarParam_p)
209 Ret = EplObduCalDefineVar(pVarParam_p);
214 //---------------------------------------------------------------------------
216 // Function: EplObduGetObjectDataPtr()
218 // Description: It returnes the current data pointer. But if object is an
219 // constant object it returnes the default pointer.
221 // Parameters: uiIndex_p = Index of the entry
222 // uiSubindex_p = Subindex of the entry
224 // Return: void * = pointer to object data
228 //---------------------------------------------------------------------------
229 EPLDLLEXPORT void *PUBLIC EplObduGetObjectDataPtr(unsigned int uiIndex_p,
230 unsigned int uiSubIndex_p)
234 pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
239 //---------------------------------------------------------------------------
241 // Function: EplObduRegisterUserOd()
243 // Description: function registers the user OD
245 // Parameters: pUserOd_p =pointer to user ODd
247 // Return: tEplKernel = errorcode
251 //---------------------------------------------------------------------------
252 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
253 EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
257 Ret = EplObduCalRegisterUserOd(pUserOd_p);
263 //---------------------------------------------------------------------------
265 // Function: EplObduInitVarEntry()
267 // Description: function to initialize VarEntry dependened on object type
269 // Parameters: pVarEntry_p = pointer to var entry structure
270 // bType_p = object type
271 // ObdSize_p = size of object data
277 //---------------------------------------------------------------------------
278 EPLDLLEXPORT void PUBLIC EplObduInitVarEntry(tEplObdVarEntry MEM * pVarEntry_p,
280 tEplObdSize ObdSize_p)
282 EplObduCalInitVarEntry(pVarEntry_p, bType_p, ObdSize_p);
285 //---------------------------------------------------------------------------
287 // Function: EplObduGetDataSize()
289 // Description: function to initialize VarEntry dependened on object type
291 // gets the data size of an object
292 // for string objects it returnes the string length
294 // Parameters: uiIndex_p = Index
295 // uiSubIndex_p= Subindex
297 // Return: tEplObdSize
301 //---------------------------------------------------------------------------
302 EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
303 unsigned int uiSubIndex_p)
307 Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
312 //---------------------------------------------------------------------------
314 // Function: EplObduGetNodeId()
316 // Description: function returns nodeid from entry 0x1F93
321 // Return: unsigned int = Node Id
325 //---------------------------------------------------------------------------
326 EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
328 unsigned int uiNodeId;
330 uiNodeId = EplObduCalGetNodeId();
335 //---------------------------------------------------------------------------
337 // Function: EplObduSetNodeId()
339 // Description: function sets nodeid in entry 0x1F93
342 // Parameters: uiNodeId_p = Node Id to set
343 // NodeIdType_p= Type on which way the Node Id was set
345 // Return: tEplKernel = Errorcode
349 //---------------------------------------------------------------------------
350 EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
351 tEplObdNodeIdType NodeIdType_p)
355 Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
360 //---------------------------------------------------------------------------
362 // Function: EplObduGetAccessType()
364 // Description: Function returns accesstype of the entry
366 // Parameters: uiIndex_p = Index of the OD entry
367 // uiSubIndex_p = Subindex of the OD Entry
368 // pAccessTyp_p = pointer to buffer to store accesstyp
370 // Return: tEplKernel = Errorcode
375 //---------------------------------------------------------------------------
376 EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
377 unsigned int uiSubIndex_p,
381 tEplObdAccess AccessType;
384 EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
389 //---------------------------------------------------------------------------
391 // Function: EplObdReaduEntryToLe()
393 // Description: The function reads an object entry from the byteoder
394 // of the system to the little endian byteorder for numeric values.
395 // For other types a normal read will be processed. This is usefull for
396 // the PDO and SDO module. The application
397 // can always read the data even if attrib kEplObdAccRead
398 // is not set. The attrib is only checked up for SDO transfer.
400 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
401 // uiIndex_p = Index of the OD entry to read
402 // uiSubIndex_p = Subindex to read
403 // pDstData_p = pointer to the buffer for data
404 // Offset_p = offset in data for read access
405 // pSize_p = IN: Size of the buffer
406 // OUT: number of readed Bytes
408 // Return: tEplKernel
412 //---------------------------------------------------------------------------
413 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe(unsigned int uiIndex_p,
414 unsigned int uiSubIndex_p,
416 tEplObdSize * pSize_p)
421 EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
427 //---------------------------------------------------------------------------
429 // Function: EplObduWriteEntryFromLe()
431 // Description: Function writes data to an OBD entry from a source with
432 // little endian byteorder to the od with system specuific
433 // byteorder. Not numeric values will only by copied. Strings
434 // are stored with added '\0' character.
436 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
437 // uiIndex_p = Index of the OD entry
438 // uiSubIndex_p = Subindex of the OD Entry
439 // pSrcData_p = Pointer to the data to write
440 // Size_p = Size of the data in Byte
442 // Return: tEplKernel = Errorcode
447 //---------------------------------------------------------------------------
448 EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe(unsigned int uiIndex_p,
457 EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
463 //---------------------------------------------------------------------------
465 // Function: EplObduSearchVarEntry()
467 // Description: gets variable from OD
469 // Parameters: uiIndex_p = index of the var entry to search
470 // uiSubindex_p = subindex of var entry to search
471 // ppVarEntry_p = pointer to the pointer to the varentry
473 // Return: tEplKernel
477 //---------------------------------------------------------------------------
478 EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
479 unsigned int uiIndex_p,
480 unsigned int uiSubindex_p,
481 tEplObdVarEntry MEM **
486 Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
491 //=========================================================================//
493 // P R I V A T E F U N C T I O N S //
495 //=========================================================================//
497 //---------------------------------------------------------------------------
513 //---------------------------------------------------------------------------
515 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)