]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems...
authoretisserant <etisserant>
Wed, 10 May 2006 19:05:57 +0000 (19:05 +0000)
committeretisserant <etisserant>
Wed, 10 May 2006 19:05:57 +0000 (19:05 +0000)
src/objacces.c
src/sdo.c

index 018b763eb822cd3e50239446f52fe1b5d11dae95..7cd08c1e85043a2564e6ec890954a15eb28cf60e 100644 (file)
@@ -20,6 +20,9 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
+//#define DEBUG_WAR_CONSOLE_ON
+//#define DEBUG_ERR_CONSOLE_ON
+
 #include "objacces.h"
 
 #ifdef DEBUG_WAR_CONSOLE_ON
@@ -82,6 +85,7 @@ UNS32 getODentry( CO_Data* d,
   }
   
   if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) {
+       MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED);
     return OD_READ_NOT_ALLOWED;
   }
@@ -97,8 +101,8 @@ UNS32 getODentry( CO_Data* d,
              {
                // data must be transmited with low byte first
                UNS8 i, j = 0;
-               for ( i = ptrTable->pSubindex[bSubindex].size - 1 ; i >= 0 ; i--) {
-                       ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i];
+               for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
+                       ((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
                }
              }
        #else   
@@ -135,7 +139,8 @@ UNS32 setODentry( CO_Data* d,
     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
     return OD_NO_SUCH_SUBINDEX;
   }
-  if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & RO)) {
+  if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) {
+       MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED);
     return OD_WRITE_NOT_ALLOWED;
   }
@@ -157,8 +162,8 @@ UNS32 setODentry( CO_Data* d,
              {
                // data must be transmited with low byte first
                UNS8 i, j = 0;
-               for ( i = ptrTable->pSubindex[bSubindex].size - 1 ; i >= 0 ; i--) {
-                       ((char*)ptrTable->pSubindex[bSubindex].pObject)[i] = ((char*)pSourceData)[j++];
+               for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
+                       ((char*)ptrTable->pSubindex[bSubindex].pObject)[i - 1] = ((char*)pSourceData)[j++];
                }
              }
       #else    
@@ -198,3 +203,4 @@ UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCal
        return errorCode;
 }
 
+
index 51c79621be055fc5033d752962f6f610074d70e3..e08e810b148b518b7416b6fd723f78034589e4da 100644 (file)
--- a/src/sdo.c
+++ b/src/sdo.c
@@ -20,8 +20,8 @@ License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
-//#define DEBUG_WAR_CONSOLE_ON
-//#define DEBUG_ERR_CONSOLE_ON
+#define DEBUG_WAR_CONSOLE_ON
+#define DEBUG_ERR_CONSOLE_ON
 
 #include "objacces.h"
 #include "sdo.h"
@@ -116,12 +116,13 @@ UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line)
   UNS8 i;
   UNS8      size;
   UNS32 errorCode;
+  MSG_WAR(0x3A08, "Enter in SDOlineToObjdict ", line);
   size = d->transfers[line].count;
   errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, 
                         (void *) d->transfers[line].data, &size, 1);
   if (errorCode != OD_SUCCESSFUL)
     return errorCode;
-
+  MSG_WAR(0x3A08, "exit of SDOlineToObjdict ", line);
   return 0;
 
 }
@@ -196,15 +197,16 @@ UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index,
   UNS8 err;
   UNS8 line;
   err = getSDOlineOnUse( d, nodeId, whoami, &line );
-  if (!err)
+  if (!err) // If a line on use have been found.
     MSG_WAR(0x3A20, "FailedSDO : line found : ", line);
   if ((! err) && (whoami == SDO_SERVER)) {
     resetSDOline( d, line );
     MSG_WAR(0x3A21, "FailedSDO : line released : ", line);
   }
-  if ((! err) && (whoami == SDO_CLIENT))
-    StopSDO_TIMER(line)
+  if ((! err) && (whoami == SDO_CLIENT)) {
+    StopSDO_TIMER(line);
     d->transfers[line].state = SDO_ABORTED_INTERNAL;
+  }
   MSG_WAR(0x3A22, "Sending SDO abort ", 0);
   err = sendSDOabort(d, whoami, index, subIndex, abortCode);
   if (err) {
@@ -218,7 +220,7 @@ UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index,
 void resetSDOline ( CO_Data* d, UNS8 line )
 {
   UNS8 i; 
-
+  MSG_WAR(0x3A25, "reset SDO line nb : ", line); 
   initSDOline(d, line, 0, 0, 0, SDO_RESET);
   for (i = 0 ; i < SDO_MAX_LENGTH_TRANSFERT ; i++)
     d->transfers[line].data[i] = 0;
@@ -227,6 +229,7 @@ void resetSDOline ( CO_Data* d, UNS8 line )
 /***************************************************************************/
 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state)
 {
+  MSG_WAR(0x3A25, "init SDO line nb : ", line); 
   if (state == SDO_DOWNLOAD_IN_PROGRESS || state == SDO_UPLOAD_IN_PROGRESS){
        StartSDO_TIMER(line)
   }else{
@@ -391,7 +394,7 @@ UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 ab
 {
   s_SDO sdo;
   UNS8 ret;
-  MSG_WAR(0x2A50,"Sending SDO abort", abortCode);
+  MSG_WAR(0x2A50,"Sending SDO abort ", abortCode);
   sdo.nodeId = *d->bDeviceNodeId;
   sdo.body.data[0] = 0x80;
   // Index
@@ -1275,3 +1278,4 @@ UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode)
   * abortCode = d->transfers[line].abortCode;
   return d->transfers[line].state;
 }
+