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 |
22 |
23 #define DEBUG_WAR_CONSOLE_ON |
23 //#define DEBUG_WAR_CONSOLE_ON |
24 #define DEBUG_ERR_CONSOLE_ON |
24 //#define DEBUG_ERR_CONSOLE_ON |
|
25 |
|
26 #undef CANOPEN_BIG_ENDIAN |
25 |
27 |
26 #include "objacces.h" |
28 #include "objacces.h" |
27 |
29 |
28 |
30 |
29 #ifdef DEBUG_WAR_CONSOLE_ON |
31 #ifdef DEBUG_WAR_CONSOLE_ON |
97 if( *pExpectedSize == 0 || |
99 if( *pExpectedSize == 0 || |
98 *pExpectedSize == szData || |
100 *pExpectedSize == szData || |
99 (*pDataType == visible_string && *pExpectedSize > szData)) // We allow to fetch a shorter string than expected |
101 (*pDataType == visible_string && *pExpectedSize > szData)) // We allow to fetch a shorter string than expected |
100 { |
102 { |
101 #ifdef CANOPEN_BIG_ENDIAN |
103 #ifdef CANOPEN_BIG_ENDIAN |
102 if(*pDataType > boolean && *pDataType < visible_string){ |
104 if(*pDataType > boolean && *pDataType < visible_string) { |
103 // data must be transmited with low byte first |
105 // data must be transmited with low byte first |
104 MSG_WAR(0x2B30, "Dans ENDIANISATION", 0x00); |
|
105 UNS8 i, j = 0; |
106 UNS8 i, j = 0; |
106 for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) { |
107 for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) { |
107 ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; |
108 ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; |
108 } |
109 } |
109 } |
|
110 else { |
|
111 MSG_WAR(0x2B32, "cas string", 0x00); |
|
112 } |
110 } |
113 #else |
111 #else |
114 memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize); |
112 memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize); |
115 #endif |
113 #endif |
116 *pExpectedSize = szData; |
114 *pExpectedSize = szData; |
157 if( *pExpectedSize == 0 || |
155 if( *pExpectedSize == 0 || |
158 *pExpectedSize == szData || |
156 *pExpectedSize == szData || |
159 (dataType == visible_string && *pExpectedSize < szData)) // We allow to store a shorter string than entry size |
157 (dataType == visible_string && *pExpectedSize < szData)) // We allow to store a shorter string than entry size |
160 { |
158 { |
161 #ifdef CANOPEN_BIG_ENDIAN |
159 #ifdef CANOPEN_BIG_ENDIAN |
162 if(dataType > boolean && dataType < visible_string){ |
160 if(dataType > boolean && dataType < visible_string) |
163 // we invert the data source directly. This let us do range testing without |
161 { |
164 // additional temp variable |
162 // we invert the data source directly. This let us do range testing without |
165 MSG_WAR(0x2B31, "Dans ENDIANISATION", 0x00); |
163 // additional temp variable |
166 UNS8 i, j = 0; |
164 UNS8 tmp, i; |
167 for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) { |
165 for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++) |
168 ((char*)ptrTable->pSubindex[bSubindex].pObject)[i - 1] = ((char*)pSourceData)[j++]; |
166 { |
169 } |
167 UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i]; |
170 // for ( i = ptrTable->pSubindex[bSubindex].size >> 1 ; i > 0 ; i--) { |
168 ((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i]; |
171 // char tmp = ((char*)pSourceData)[i - 1]; |
169 ((UNS8 *)pSourceData)[i] = tmp; |
172 // ((char*)pSourceData)[i - 1] = ((char*)pSourceData)[j]; |
170 } |
173 // ((char*)pSourceData)[j++] = tmp; |
171 } |
174 // } |
|
175 } |
|
176 else { |
|
177 MSG_WAR(0x2B35, "cas string", 0x00); |
|
178 } |
|
179 #endif |
172 #endif |
180 errorCode = (*d->valueRangeTest)(dataType, pSourceData); |
173 errorCode = (*d->valueRangeTest)(dataType, pSourceData); |
181 if (errorCode) { |
174 if (errorCode) { |
182 accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode); |
175 accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode); |
183 return errorCode; |
176 return errorCode; |