forked from jgeisler0303/CANFestivino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjacces.h
132 lines (116 loc) · 5.63 KB
/
objacces.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
This file is part of CanFestival, a library implementing CanOpen Stack.
Copyright (C): Edouard TISSERANT and Francis DUPIN
See COPYING file for copyrights details.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @file
* @brief Responsible for accessing the object dictionary.
*
* This file contains functions for accessing the object dictionary and
* variables that are contained by the object dictionary.
* Accessing the object dictionary contains setting local variables
* as PDOs and accessing (read/write) all entries of the object dictionary
* @warning Only the basic entries of an object dictionary are included
* at the moment.
*/
/** @defgroup od Object Dictionary Management
* @brief The Object Dictionary is the heart of each CANopen device containing all communication and application objects.
* @ingroup userapi
*/
#ifndef __objacces_h__
#define __objacces_h__
#include "applicfg.h"
typedef UNS32 (*valueRangeTest_t)(UNS8 typeValue, void *Value);
typedef void (*storeODSubIndex_t)(UNS16 wIndex, UNS8 bSubindex);
UNS8 objectSize(subindex *s);
/**
* @brief Print MSG_WAR (s) if error to the access to the object dictionary occurs.
*
* You must uncomment the lines in the file objaccess.c :\n
* //#define DEBUG_CAN\n
* //#define DEBUG_WAR_CONSOLE_ON\n
* //#define DEBUG_ERR_CONSOLE_ON\n\n
* Beware that sometimes, we force the sizeDataDict or sizeDataGiven to 0, when we wants to use
* this function but we do not have the access to the right value. One example is
* getSDOerror(). So do not take attention to these variables if they are null.
* @param index
* @param subIndex
* @param sizeDataDict Size of the data defined in the dictionary
* @param sizeDataGiven Size data given by the user.
* @param code error code to print. (SDO abort code. See file def.h)
* @return
*/
UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code);
/* _getODentry() Reads an entry from the object dictionary.\n
*
* use getODentry() macro to read from object and endianize
* use readLocalDict() macro to read from object and not endianize
*
* @code
* // Example usage:
* UNS8 *pbData;
* UNS8 length;
* UNS32 returnValue;
*
* returnValue = getODentry( (UNS16)0x100B, (UNS8)1,
* (void * *)&pbData, (UNS8 *)&length );
* if( returnValue != SUCCESSFUL )
* {
* // error handling
* }
* @endcode
* @param *d Pointer to a CAN object data structure
* @param wIndex The index in the object dictionary where you want to read
* an entry
* @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
* used to tell you how many valid entries you can find
* in this index. Look at the canopen standard for further
* information
* @param *pDestData Pointer to the pointer which points to the variable where
* the value of this object dictionary entry should be copied
* @param pExpectedSize This function writes the size of the copied value (in Byte)
* into this variable.
* @param *pDataType Pointer to the type of the data. See objdictdef.h
* @param CheckAccess if other than 0, do not read if the data is Write Only
* [Not used today. Put always 0].
* @param Endianize When not 0, data is endianized into network byte order
* when 0, data is not endianized and copied in machine native
* endianness
* @return
* - OD_SUCCESSFUL is returned upon success.
* - SDO abort code is returned if error occurs . (See file def.h)
*/
UNS32 getODentry(UNS16 wIndex, UNS8 bSubindex, void * pDestData, UNS32 * pExpectedSize, UNS8 * pDataType, UNS8 checkAccess);
/* By this function you can write an entry into the object dictionary
* @param *d Pointer to a CAN object data structure
* @param wIndex The index in the object dictionary where you want to write
* an entry
* @param bSubindex The subindex of the Index. e.g. mostly subindex 0 is
* used to tell you how many valid entries you can find
* in this index. Look at the canopen standard for further
* information
* @param *pSourceData Pointer to the variable that holds the value that should
* be copied into the object dictionary
* @param *pExpectedSize The size of the value (in Byte).
* @param checkAccess Flag that indicate if a check rights must be perfomed (0 : no , other than 0 : yes)
* @param endianize When not 0, data is endianized into network byte order
* when 0, data is not endianized and copied in machine native
* endianness
* @return
* - OD_SUCCESSFUL is returned upon success.
* - SDO abort code is returned if error occurs . (See file def.h)
*/
UNS32 setODentry(UNS16 wIndex, UNS8 bSubindex, void * pSourceData, UNS32 * pExpectedSize, UNS8 checkAccess);
UNS32 RegisterSetODentryCallBack(UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback);
#endif /* __objacces_h__ */