equal
deleted
inserted
replaced
17 |
17 |
18 You should have received a copy of the GNU Lesser General Public |
18 You should have received a copy of the GNU Lesser General Public |
19 License along with this library; if not, write to the Free Software |
19 License along with this library; if not, write to the Free Software |
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 */ |
21 */ |
|
22 |
|
23 //#define DEBUG_WAR_CONSOLE_ON |
|
24 //#define DEBUG_ERR_CONSOLE_ON |
22 |
25 |
23 #include "objacces.h" |
26 #include "objacces.h" |
24 |
27 |
25 #ifdef DEBUG_WAR_CONSOLE_ON |
28 #ifdef DEBUG_WAR_CONSOLE_ON |
26 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, |
29 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, |
80 accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX); |
83 accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX); |
81 return OD_NO_SUCH_SUBINDEX; |
84 return OD_NO_SUCH_SUBINDEX; |
82 } |
85 } |
83 |
86 |
84 if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) { |
87 if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) { |
|
88 MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
85 accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED); |
89 accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED); |
86 return OD_READ_NOT_ALLOWED; |
90 return OD_READ_NOT_ALLOWED; |
87 } |
91 } |
88 |
92 |
89 *pDataType = ptrTable->pSubindex[bSubindex].bDataType; |
93 *pDataType = ptrTable->pSubindex[bSubindex].bDataType; |
95 { |
99 { |
96 #ifdef CANOPEN_BIG_ENDIAN |
100 #ifdef CANOPEN_BIG_ENDIAN |
97 { |
101 { |
98 // data must be transmited with low byte first |
102 // data must be transmited with low byte first |
99 UNS8 i, j = 0; |
103 UNS8 i, j = 0; |
100 for ( i = ptrTable->pSubindex[bSubindex].size - 1 ; i >= 0 ; i--) { |
104 for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) { |
101 ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i]; |
105 ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; |
102 } |
106 } |
103 } |
107 } |
104 #else |
108 #else |
105 memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize); |
109 memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize); |
106 #endif |
110 #endif |
133 if( ptrTable->bSubCount <= bSubindex ) { |
137 if( ptrTable->bSubCount <= bSubindex ) { |
134 // Subindex not found |
138 // Subindex not found |
135 accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX); |
139 accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX); |
136 return OD_NO_SUCH_SUBINDEX; |
140 return OD_NO_SUCH_SUBINDEX; |
137 } |
141 } |
138 if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & RO)) { |
142 if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) { |
|
143 MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
139 accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED); |
144 accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED); |
140 return OD_WRITE_NOT_ALLOWED; |
145 return OD_WRITE_NOT_ALLOWED; |
141 } |
146 } |
142 |
147 |
143 |
148 |
155 } |
160 } |
156 #ifdef CANOPEN_BIG_ENDIAN |
161 #ifdef CANOPEN_BIG_ENDIAN |
157 { |
162 { |
158 // data must be transmited with low byte first |
163 // data must be transmited with low byte first |
159 UNS8 i, j = 0; |
164 UNS8 i, j = 0; |
160 for ( i = ptrTable->pSubindex[bSubindex].size - 1 ; i >= 0 ; i--) { |
165 for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) { |
161 ((char*)ptrTable->pSubindex[bSubindex].pObject)[i] = ((char*)pSourceData)[j++]; |
166 ((char*)ptrTable->pSubindex[bSubindex].pObject)[i - 1] = ((char*)pSourceData)[j++]; |
162 } |
167 } |
163 } |
168 } |
164 #else |
169 #else |
165 memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize); |
170 memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize); |
166 #endif |
171 #endif |
196 if(errorCode == OD_SUCCESSFUL && CallbackList) |
201 if(errorCode == OD_SUCCESSFUL && CallbackList) |
197 CallbackList[bSubindex] = Callback; |
202 CallbackList[bSubindex] = Callback; |
198 return errorCode; |
203 return errorCode; |
199 } |
204 } |
200 |
205 |
|
206 |