added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / staging / epl / EplObdu.c
blob218d152897cf6c8daf58753c61c78ffb1977fa0b
1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
6 Project: openPOWERLINK
8 Description: source file for Epl-Obd-Userspace-module
10 License:
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
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.
41 Severability Clause:
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 $
54 $Author: D.Krueger $
56 $Revision: 1.5 $ $Date: 2008/10/17 15:32:32 $
58 $State: Exp $
60 Build Environment:
61 GCC V3.4
63 -------------------------------------------------------------------------
65 Revision History:
67 2006/06/19 k.t.: start of the implementation
69 ****************************************************************************/
71 #include "EplInc.h"
72 #include "user/EplObdu.h"
73 #include "user/EplObduCal.h"
75 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
76 /***************************************************************************/
77 /* */
78 /* */
79 /* G L O B A L D E F I N I T I O N S */
80 /* */
81 /* */
82 /***************************************************************************/
84 //---------------------------------------------------------------------------
85 // const defines
86 //---------------------------------------------------------------------------
88 //---------------------------------------------------------------------------
89 // local types
90 //---------------------------------------------------------------------------
92 //---------------------------------------------------------------------------
93 // modul globale vars
94 //---------------------------------------------------------------------------
96 //---------------------------------------------------------------------------
97 // local function prototypes
98 //---------------------------------------------------------------------------
100 //=========================================================================//
101 // //
102 // P U B L I C F U N C T I O N S //
103 // //
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
121 // State:
123 //---------------------------------------------------------------------------
124 EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntry(unsigned int uiIndex_p,
125 unsigned int uiSubIndex_p,
126 void *pSrcData_p,
127 tEplObdSize Size_p)
129 tEplKernel Ret;
131 Ret = EplObduCalWriteEntry(uiIndex_p, uiSubIndex_p, pSrcData_p, Size_p);
133 return Ret;
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
153 // State:
155 //---------------------------------------------------------------------------
156 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntry(unsigned int uiIndex_p,
157 unsigned int uiSubIndex_p,
158 void *pDstData_p,
159 tEplObdSize * pSize_p)
161 tEplKernel Ret;
163 Ret = EplObduCalReadEntry(uiIndex_p, uiSubIndex_p, pDstData_p, pSize_p);
165 return Ret;
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
179 // State:
181 //---------------------------------------------------------------------------
182 EPLDLLEXPORT tEplKernel PUBLIC EplObduAccessOdPart(tEplObdPart ObdPart_p,
183 tEplObdDir Direction_p)
185 tEplKernel Ret;
187 Ret = EplObduCalAccessOdPart(ObdPart_p, Direction_p);
189 return Ret;
192 //---------------------------------------------------------------------------
194 // Function: EplObduDefineVar()
196 // Description: defines a variable in OD
198 // Parameters: pEplVarParam_p = varentry
200 // Return: tEplKernel = errorcode
202 // State:
204 //---------------------------------------------------------------------------
205 EPLDLLEXPORT tEplKernel PUBLIC EplObduDefineVar(tEplVarParam MEM * pVarParam_p)
207 tEplKernel Ret;
209 Ret = EplObduCalDefineVar(pVarParam_p);
211 return Ret;
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
226 // State:
228 //---------------------------------------------------------------------------
229 EPLDLLEXPORT void *PUBLIC EplObduGetObjectDataPtr(unsigned int uiIndex_p,
230 unsigned int uiSubIndex_p)
232 void *pData;
234 pData = EplObduCalGetObjectDataPtr(uiIndex_p, uiSubIndex_p);
236 return pData;
239 //---------------------------------------------------------------------------
241 // Function: EplObduRegisterUserOd()
243 // Description: function registers the user OD
245 // Parameters: pUserOd_p =pointer to user ODd
247 // Return: tEplKernel = errorcode
249 // State:
251 //---------------------------------------------------------------------------
252 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
253 EPLDLLEXPORT tEplKernel PUBLIC EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p)
255 tEplKernel Ret;
257 Ret = EplObduCalRegisterUserOd(pUserOd_p);
259 return Ret;
262 #endif
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
273 // Returns: none
275 // State:
277 //---------------------------------------------------------------------------
278 EPLDLLEXPORT void PUBLIC EplObduInitVarEntry(tEplObdVarEntry MEM * pVarEntry_p,
279 BYTE bType_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
299 // State:
301 //---------------------------------------------------------------------------
302 EPLDLLEXPORT tEplObdSize PUBLIC EplObduGetDataSize(unsigned int uiIndex_p,
303 unsigned int uiSubIndex_p)
305 tEplObdSize Size;
307 Size = EplObduCalGetDataSize(uiIndex_p, uiSubIndex_p);
309 return Size;
312 //---------------------------------------------------------------------------
314 // Function: EplObduGetNodeId()
316 // Description: function returns nodeid from entry 0x1F93
319 // Parameters:
321 // Return: unsigned int = Node Id
323 // State:
325 //---------------------------------------------------------------------------
326 EPLDLLEXPORT unsigned int PUBLIC EplObduGetNodeId()
328 unsigned int uiNodeId;
330 uiNodeId = EplObduCalGetNodeId();
332 return uiNodeId;
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
347 // State:
349 //---------------------------------------------------------------------------
350 EPLDLLEXPORT tEplKernel PUBLIC EplObduSetNodeId(unsigned int uiNodeId_p,
351 tEplObdNodeIdType NodeIdType_p)
353 tEplKernel Ret;
355 Ret = EplObduCalSetNodeId(uiNodeId_p, NodeIdType_p);
357 return Ret;
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
373 // State:
375 //---------------------------------------------------------------------------
376 EPLDLLEXPORT tEplKernel PUBLIC EplObduGetAccessType(unsigned int uiIndex_p,
377 unsigned int uiSubIndex_p,
378 tEplObdAccess *
379 pAccessTyp_p)
381 tEplObdAccess AccessType;
383 AccessType =
384 EplObduCalGetAccessType(uiIndex_p, uiSubIndex_p, pAccessTyp_p);
386 return AccessType;
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
410 // State:
412 //---------------------------------------------------------------------------
413 EPLDLLEXPORT tEplKernel PUBLIC EplObduReadEntryToLe(unsigned int uiIndex_p,
414 unsigned int uiSubIndex_p,
415 void *pDstData_p,
416 tEplObdSize * pSize_p)
418 tEplKernel Ret;
420 Ret =
421 EplObduCalReadEntryToLe(uiIndex_p, uiSubIndex_p, pDstData_p,
422 pSize_p);
424 return Ret;
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
445 // State:
447 //---------------------------------------------------------------------------
448 EPLDLLEXPORT tEplKernel PUBLIC EplObduWriteEntryFromLe(unsigned int uiIndex_p,
449 unsigned int
450 uiSubIndex_p,
451 void *pSrcData_p,
452 tEplObdSize Size_p)
454 tEplKernel Ret;
456 Ret =
457 EplObduCalWriteEntryFromLe(uiIndex_p, uiSubIndex_p, pSrcData_p,
458 Size_p);
460 return Ret;
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
475 // State:
477 //---------------------------------------------------------------------------
478 EPLDLLEXPORT tEplKernel PUBLIC EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
479 unsigned int uiIndex_p,
480 unsigned int uiSubindex_p,
481 tEplObdVarEntry MEM **
482 ppVarEntry_p)
484 tEplKernel Ret;
486 Ret = EplObduCalSearchVarEntry(uiIndex_p, uiSubindex_p, ppVarEntry_p);
488 return Ret;
491 //=========================================================================//
492 // //
493 // P R I V A T E F U N C T I O N S //
494 // //
495 //=========================================================================//
497 //---------------------------------------------------------------------------
499 // Function:
501 // Description:
505 // Parameters:
508 // Returns:
511 // State:
513 //---------------------------------------------------------------------------
515 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)
517 // EOF