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 tEplKernel
EplObduWriteEntry(unsigned int uiIndex_p
,
125 unsigned int uiSubIndex_p
,
126 void *pSrcData_p
, tEplObdSize Size_p
)
130 Ret
= EplObduCalWriteEntry(uiIndex_p
, uiSubIndex_p
, pSrcData_p
, Size_p
);
135 //---------------------------------------------------------------------------
137 // Function: EplObduReadEntry()
139 // Description: The function reads an object entry. The application
140 // can always read the data even if attrib kEplObdAccRead
141 // is not set. The attrib is only checked up for SDO transfer.
143 // Parameters: uiIndex_p = Index oof the OD entry to read
144 // uiSubIndex_p = Subindex to read
145 // pDstData_p = pointer to the buffer for data
146 // Offset_p = offset in data for read access
147 // pSize_p = IN: Size of the buffer
148 // OUT: number of readed Bytes
150 // Return: tEplKernel = errorcode
154 //---------------------------------------------------------------------------
155 tEplKernel
EplObduReadEntry(unsigned int uiIndex_p
,
156 unsigned int uiSubIndex_p
,
158 tEplObdSize
*pSize_p
)
162 Ret
= EplObduCalReadEntry(uiIndex_p
, uiSubIndex_p
, pDstData_p
, pSize_p
);
167 //---------------------------------------------------------------------------
169 // Function: EplObdAccessOdPart()
171 // Description: restores default values of one part of OD
173 // Parameters: ObdPart_p = od-part to reset
174 // Direction_p = directory flag for
176 // Return: tEplKernel = errorcode
180 //---------------------------------------------------------------------------
181 tEplKernel
EplObduAccessOdPart(tEplObdPart ObdPart_p
, tEplObdDir Direction_p
)
185 Ret
= EplObduCalAccessOdPart(ObdPart_p
, Direction_p
);
190 //---------------------------------------------------------------------------
192 // Function: EplObduDefineVar()
194 // Description: defines a variable in OD
196 // Parameters: pEplVarParam_p = varentry
198 // Return: tEplKernel = errorcode
202 //---------------------------------------------------------------------------
203 tEplKernel
EplObduDefineVar(tEplVarParam
*pVarParam_p
)
207 Ret
= EplObduCalDefineVar(pVarParam_p
);
212 //---------------------------------------------------------------------------
214 // Function: EplObduGetObjectDataPtr()
216 // Description: It returnes the current data pointer. But if object is an
217 // constant object it returnes the default pointer.
219 // Parameters: uiIndex_p = Index of the entry
220 // uiSubindex_p = Subindex of the entry
222 // Return: void * = pointer to object data
226 //---------------------------------------------------------------------------
227 void *EplObduGetObjectDataPtr(unsigned int uiIndex_p
, unsigned int uiSubIndex_p
)
231 pData
= EplObduCalGetObjectDataPtr(uiIndex_p
, uiSubIndex_p
);
236 //---------------------------------------------------------------------------
238 // Function: EplObduRegisterUserOd()
240 // Description: function registers the user OD
242 // Parameters: pUserOd_p =pointer to user ODd
244 // Return: tEplKernel = errorcode
248 //---------------------------------------------------------------------------
249 #if (defined (EPL_OBD_USER_OD) && (EPL_OBD_USER_OD != FALSE))
250 tEplKernel
EplObduRegisterUserOd(tEplObdEntryPtr pUserOd_p
)
254 Ret
= EplObduCalRegisterUserOd(pUserOd_p
);
260 //---------------------------------------------------------------------------
262 // Function: EplObduInitVarEntry()
264 // Description: function to initialize VarEntry dependened on object type
266 // Parameters: pVarEntry_p = pointer to var entry structure
267 // bType_p = object type
268 // ObdSize_p = size of object data
274 //---------------------------------------------------------------------------
275 void EplObduInitVarEntry(tEplObdVarEntry
*pVarEntry_p
, u8 bType_p
, tEplObdSize ObdSize_p
)
277 EplObduCalInitVarEntry(pVarEntry_p
, bType_p
, ObdSize_p
);
280 //---------------------------------------------------------------------------
282 // Function: EplObduGetDataSize()
284 // Description: function to initialize VarEntry dependened on object type
286 // gets the data size of an object
287 // for string objects it returnes the string length
289 // Parameters: uiIndex_p = Index
290 // uiSubIndex_p= Subindex
292 // Return: tEplObdSize
296 //---------------------------------------------------------------------------
297 tEplObdSize
EplObduGetDataSize(unsigned int uiIndex_p
, unsigned int uiSubIndex_p
)
301 Size
= EplObduCalGetDataSize(uiIndex_p
, uiSubIndex_p
);
306 //---------------------------------------------------------------------------
308 // Function: EplObduGetNodeId()
310 // Description: function returns nodeid from entry 0x1F93
315 // Return: unsigned int = Node Id
319 //---------------------------------------------------------------------------
320 unsigned int EplObduGetNodeId(void)
322 unsigned int uiNodeId
;
324 uiNodeId
= EplObduCalGetNodeId();
329 //---------------------------------------------------------------------------
331 // Function: EplObduSetNodeId()
333 // Description: function sets nodeid in entry 0x1F93
336 // Parameters: uiNodeId_p = Node Id to set
337 // NodeIdType_p= Type on which way the Node Id was set
339 // Return: tEplKernel = Errorcode
343 //---------------------------------------------------------------------------
344 tEplKernel
EplObduSetNodeId(unsigned int uiNodeId_p
, tEplObdNodeIdType NodeIdType_p
)
348 Ret
= EplObduCalSetNodeId(uiNodeId_p
, NodeIdType_p
);
353 //---------------------------------------------------------------------------
355 // Function: EplObduGetAccessType()
357 // Description: Function returns accesstype of the entry
359 // Parameters: uiIndex_p = Index of the OD entry
360 // uiSubIndex_p = Subindex of the OD Entry
361 // pAccessTyp_p = pointer to buffer to store accesstyp
363 // Return: tEplKernel = Errorcode
368 //---------------------------------------------------------------------------
369 tEplKernel
EplObduGetAccessType(unsigned int uiIndex_p
,
370 unsigned int uiSubIndex_p
,
371 tEplObdAccess
*pAccessTyp_p
)
373 tEplObdAccess AccessType
;
376 EplObduCalGetAccessType(uiIndex_p
, uiSubIndex_p
, pAccessTyp_p
);
381 //---------------------------------------------------------------------------
383 // Function: EplObdReaduEntryToLe()
385 // Description: The function reads an object entry from the byteoder
386 // of the system to the little endian byteorder for numeric values.
387 // For other types a normal read will be processed. This is usefull for
388 // the PDO and SDO module. The application
389 // can always read the data even if attrib kEplObdAccRead
390 // is not set. The attrib is only checked up for SDO transfer.
392 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
393 // uiIndex_p = Index of the OD entry to read
394 // uiSubIndex_p = Subindex to read
395 // pDstData_p = pointer to the buffer for data
396 // Offset_p = offset in data for read access
397 // pSize_p = IN: Size of the buffer
398 // OUT: number of readed Bytes
400 // Return: tEplKernel
404 //---------------------------------------------------------------------------
405 tEplKernel
EplObduReadEntryToLe(unsigned int uiIndex_p
,
406 unsigned int uiSubIndex_p
,
408 tEplObdSize
*pSize_p
)
413 EplObduCalReadEntryToLe(uiIndex_p
, uiSubIndex_p
, pDstData_p
,
419 //---------------------------------------------------------------------------
421 // Function: EplObduWriteEntryFromLe()
423 // Description: Function writes data to an OBD entry from a source with
424 // little endian byteorder to the od with system specuific
425 // byteorder. Not numeric values will only by copied. Strings
426 // are stored with added '\0' character.
428 // Parameters: EPL_MCO_DECL_INSTANCE_PTR_
429 // uiIndex_p = Index of the OD entry
430 // uiSubIndex_p = Subindex of the OD Entry
431 // pSrcData_p = Pointer to the data to write
432 // Size_p = Size of the data in Byte
434 // Return: tEplKernel = Errorcode
439 //---------------------------------------------------------------------------
440 tEplKernel
EplObduWriteEntryFromLe(unsigned int uiIndex_p
,
441 unsigned int uiSubIndex_p
,
448 EplObduCalWriteEntryFromLe(uiIndex_p
, uiSubIndex_p
, pSrcData_p
,
454 //---------------------------------------------------------------------------
456 // Function: EplObduSearchVarEntry()
458 // Description: gets variable from OD
460 // Parameters: uiIndex_p = index of the var entry to search
461 // uiSubindex_p = subindex of var entry to search
462 // ppVarEntry_p = pointer to the pointer to the varentry
464 // Return: tEplKernel
468 //---------------------------------------------------------------------------
469 tEplKernel
EplObduSearchVarEntry(EPL_MCO_DECL_INSTANCE_PTR_
unsigned int uiIndex_p
,
470 unsigned int uiSubindex_p
,
471 tEplObdVarEntry
**ppVarEntry_p
)
475 Ret
= EplObduCalSearchVarEntry(uiIndex_p
, uiSubindex_p
, ppVarEntry_p
);
480 //=========================================================================//
482 // P R I V A T E F U N C T I O N S //
484 //=========================================================================//
486 //---------------------------------------------------------------------------
502 //---------------------------------------------------------------------------
504 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_OBDU)) != 0)