]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks...
authoretisserant <etisserant>
Mon, 16 Mar 2009 23:03:18 +0000 (23:03 +0000)
committeretisserant <etisserant>
Mon, 16 Mar 2009 23:03:18 +0000 (23:03 +0000)
include/objacces.h
include/objdictdef.h
include/sdo.h
src/objacces.c
src/pdo.c
src/sdo.c

index e819f29251ddce35d6505e5dae51e4fb3c2e5ecf..b5ee04a85a3b44c1034d2c512685189a2a06ab9d 100644 (file)
@@ -64,7 +64,7 @@ void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex);
  * @return
  */ 
 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, 
-                          UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code);
+                          UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code);
 
 
 /* _getODentry() Reads an entry from the object dictionary.\n
@@ -108,7 +108,7 @@ UNS32 _getODentry( CO_Data* d,
                  UNS16 wIndex,
                  UNS8 bSubindex,
                  void * pDestData,
-                 UNS8 * pExpectedSize,
+                 UNS32 * pExpectedSize,
                  UNS8 * pDataType,
                  UNS8 checkAccess,
                  UNS8 endianize);
@@ -188,7 +188,7 @@ UNS32 _setODentry( CO_Data* d,
                    UNS16 wIndex,
                    UNS8 bSubindex,
                    void * pSourceData,
-                   UNS8 * pExpectedSize,
+                   UNS32 * pExpectedSize,
                    UNS8 checkAccess,
                    UNS8 endianize);
 
index 8361ee6d7697574a37716229e54ceeb6fde6e003..60948b85a7526cc7cc6e6c665619c20e71e967f2 100644 (file)
@@ -85,7 +85,7 @@ typedef struct td_subindex
 {
     UNS8                    bAccessType;
     UNS8                    bDataType; /* Defines of what datatype the entry is */
-    UNS                   size;      /* The size (in Byte) of the variable */
+    UNS32                   size;      /* The size (in Byte) of the variable */
     void*                   pObject;   /* This is the pointer of the Variable */
 } subindex;
 
index 96245c7326d478ff0206e2cc633f9d747bb17416..b8dd7d302e98cd04d63ce160ddccb05fb9ba8a09 100644 (file)
@@ -135,7 +135,7 @@ UNS32 objdictToSDOline (CO_Data* d, UNS8 line);
  * @param *data Pointer on the data
  * @return 0xFF if error. Else, returns 0.
  */
-UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
+UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8 * data);
 
 /** 
  * @brief Add data to an existant line
@@ -145,7 +145,7 @@ UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
  * @param *data Pointer on the data
  * @return 0xFF if error. Else, returns 0.
  */
-UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
+UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8 * data);
 
 /** 
  * @brief Called when an internal SDO abort occurs.
@@ -224,7 +224,7 @@ UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami);
  * @param *nbBytes Pointer on nbBytes
  * @return 0.
  */
-UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes);
+UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 * nbBytes);
 
 /** 
  * @brief Store in the line structure the nb of bytes which must be transmited (or received)
@@ -234,7 +234,7 @@ UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes);
  * @param nbBytes
  * @return 0 if success, 0xFF if error.
  */
-UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes);
+UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 nbBytes);
 
 /**
  * @brief Transmit a SDO frame on the bus bus_id
@@ -290,7 +290,7 @@ UNS8 proceedSDO (CO_Data* d, Message *m);
  * @return 0xFF if error, else return 0
  */
 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data);
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data);
 
 /** 
  * @ingroup sdo
@@ -308,7 +308,7 @@ UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
  * @return 0xFF if error, else return 0
  */
 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback);
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback);
 
 /**
  * @ingroup sdo 
@@ -330,7 +330,7 @@ UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index,
  * @return 0xFF if error, else return 0
  */
 UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
 
 /**
  * @ingroup sdo 
@@ -399,7 +399,7 @@ UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIn
  * while (getReadResultNetworkDict (0, 0x05, &data, &size) != SDO_UPLOAD_IN_PROGRESS);
  * @endcode
 */
-UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, UNS32 * abortCode);
+UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS32 *size, UNS32 * abortCode);
 
 /**
  * @brief Use this function after a writeNetworkDict to get the result of the write
index 1ab03bd7ce908cab227b99019e2473741206dd7e..8e6a897c4c68b09e08c2cd1c2e0c432798f38c10 100644 (file)
@@ -54,7 +54,7 @@
 **/
 #ifdef DEBUG_WAR_CONSOLE_ON
 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex,
-                           UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code)
+                           UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code)
 {
   MSG_WAR(0x2B09,"Dictionary index : ", index);
   MSG_WAR(0X2B10,"           subindex : ", subIndex);
@@ -108,14 +108,14 @@ UNS32 _getODentry( CO_Data* d,
                    UNS16 wIndex,
                    UNS8 bSubindex,
                    void * pDestData,
-                   UNS8 * pExpectedSize,
+                   UNS32 * pExpectedSize,
                    UNS8 * pDataType,
                    UNS8 checkAccess,
                    UNS8 endianize)
 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite
     loop if it fails. */
   UNS32 errorCode;
-  UNS8 szData;
+  UNS32 szData;
   const indextable *ptrTable;
   ODCallback_t *Callback;
 
@@ -211,11 +211,11 @@ UNS32 _setODentry( CO_Data* d,
                    UNS16 wIndex,
                    UNS8 bSubindex,
                    void * pSourceData,
-                   UNS8 * pExpectedSize,
+                   UNS32 * pExpectedSize,
                    UNS8 checkAccess,
                    UNS8 endianize)
 {
-  UNS8 szData;
+  UNS32 szData;
   UNS8 dataType;
   UNS32 errorCode;
   const indextable *ptrTable;
index 457c4955992e9f100ced54f10fd759c83a7e741d..7618266a2cdcc87990fdd35cd7dcecd58f963641 100644 (file)
--- a/src/pdo.c
+++ b/src/pdo.c
@@ -71,12 +71,12 @@ UNS8 buildPDO (CO_Data * d, UNS8 numPdo, Message * pdo)
       UNS32 *pMappingParameter =
         (UNS32 *) TPDO_map->pSubindex[prp_j + 1].pObject;
       UNS16 index = (UNS16) ((*pMappingParameter) >> 16);
-      UNS8 Size = (UNS8) (*pMappingParameter & (UNS32) 0x000000FF);     /* Size in bits */
+      UNS32 Size = (UNS32) (*pMappingParameter & (UNS32) 0x000000FF);     /* Size in bits */
 
       /* get variable only if Size != 0 and Size is lower than remaining bits in the PDO */
       if (Size && ((offset + Size) <= 64))
         {
-          UNS8 ByteSize = 1 + ((Size - 1) >> 3);        /*1->8 => 1 ; 9->16 => 2, ... */
+          UNS32 ByteSize = 1 + ((Size - 1) >> 3);        /*1->8 => 1 ; 9->16 => 2, ... */
           UNS8 subIndex =
             (UNS8) (((*pMappingParameter) >> (UNS8) 8) & (UNS32) 0x000000FF);
 
@@ -241,7 +241,7 @@ proceedPDO (CO_Data * d, Message * m)
                 while (numMap < *pMappingCount)
                   {
                     UNS8 tmp[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
-                    UNS8 ByteSize;
+                    UNS32 ByteSize;
                     pMappingParameter =
                       (UNS32 *) (d->objdict + offsetObjdict +
                                  numPdo)->pSubindex[numMap + 1].pObject;
@@ -268,7 +268,7 @@ proceedPDO (CO_Data * d, Message * m)
                         CopyBits (Size, (UNS8 *) & m->data[offset >> 3],
                                   offset % 8, 0, ((UNS8 *) tmp), 0, 0);
                         /*1->8 => 1 ; 9->16 =>2, ... */
-                        ByteSize = 1 + ((Size - 1) >> 3);
+                        ByteSize = (UNS32)(1 + ((Size - 1) >> 3));
 
                         objDict =
                           setODentry (d, (UNS16) ((*pMappingParameter) >> 16),
index 8edf5bea5ca411ca32d841d3923c1b50ea0a81cb..b4e0e011c84616744a56267ac3dd05196fcd5c38 100644 (file)
--- a/src/sdo.c
+++ b/src/sdo.c
@@ -62,7 +62,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 ** @return
 **/
 INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
 
 /*!
 ** Called by readNetworkDict
@@ -184,10 +184,10 @@ void resetSDO (CO_Data* d)
 **/
 UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line)
 {
-  UNS8      size;
+  UNS32 size;
   UNS32 errorCode;
   MSG_WAR(0x3A08, "Enter in SDOlineToObjdict ", line);
-  size = (UNS8)d->transfers[line].count;
+  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)
@@ -207,7 +207,7 @@ UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line)
 **/
 UNS32 objdictToSDOline (CO_Data* d, UNS8 line)
 {
-  UNS8  size = 0;
+  UNS32  size = 0;
   UNS8  dataType;
   UNS32 errorCode;
 
@@ -238,9 +238,9 @@ UNS32 objdictToSDOline (CO_Data* d, UNS8 line)
 **
 ** @return
 **/
-UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data) {
+UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8* data) {
   UNS8 i;
-  UNS8 offset;
+  UNS32 offset;
 
   if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) {
     MSG_ERR(0x1A10,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
@@ -250,7 +250,7 @@ UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data) {
     MSG_ERR(0x1A11,"SDO Size of data too large. Exceed count", nbBytes);
     return 0xFF;
   }
-  offset = (UNS8)d->transfers[line].offset;
+  offset = d->transfers[line].offset;
   for (i = 0 ; i < nbBytes ; i++)
     * (data + i) = d->transfers[line].data[offset + i];
   d->transfers[line].offset = d->transfers[line].offset + nbBytes;
@@ -267,19 +267,21 @@ UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data) {
 **
 ** @return
 **/
-UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8* data)
+UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8* data)
 {
   UNS8 i;
-  UNS8 offset;
+  UNS32 offset;
 
   if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) {
     MSG_ERR(0x1A15,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
     return 0xFF;
   }
-  offset = (UNS8)d->transfers[line].offset;
+  offset = d->transfers[line].offset;
   for (i = 0 ; i < nbBytes ; i++)
     d->transfers[line].data[offset + i] = * (data + i);
   d->transfers[line].offset = d->transfers[line].offset + nbBytes;
+  d->transfers[line].count = d->transfers[line].offset; 
+  
   return 0;
 }
 
@@ -328,7 +330,7 @@ UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index,
 **/
 void resetSDOline ( CO_Data* d, UNS8 line )
 {
-  UNS8 i;
+  UNS32 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++)
@@ -451,12 +453,13 @@ UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami)
 **
 ** @return
 **/
-UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes)
+UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 * nbBytes)
 {
   if (d->transfers[line].count == 0) /* if received initiate SDO protocol with e=0 and s=0 */
     * nbBytes = 0;
   else
-    * nbBytes = (UNS8)d->transfers[line].count - (UNS8)d->transfers[line].offset;
+    * nbBytes = d->transfers[line].count - d->transfers[line].offset;
+  
   return 0;
 }
 
@@ -469,7 +472,7 @@ UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes)
 **
 ** @return
 **/
-UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes)
+UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 nbBytes)
 {
   if (nbBytes > SDO_MAX_LENGTH_TRANSFERT) {
     MSG_ERR(0x1A35,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes);
@@ -613,7 +616,7 @@ UNS8 proceedSDO (CO_Data* d, Message *m)
 {
   UNS8 err;
   UNS8 line;
-  UNS8 nbBytes; /* received or to be transmited. */
+  UNS32 nbBytes; /* received or to be transmited. */
   UNS8 nodeId = 0;  /* The node from which the SDO is received */
   UNS8 *pNodeId = NULL;
   UNS8 whoami = SDO_UNKNOWN;  /* SDO_SERVER or SDO_CLIENT.*/
@@ -864,8 +867,7 @@ UNS8 proceedSDO (CO_Data* d, Message *m)
       }
       else {/* So, if it is not an expedited transfert */
        if (getSDOs(m->data[0])) {
-         /* TODO : if e and s = 0, not reading m->data[4] but put nbBytes = 0 */
-         nbBytes = m->data[4]; /* Transfert limited to 255 bytes. */
+         nbBytes = 0; 
          err = setSDOlineRestBytes(d, nodeId, nbBytes);
          if (err) {
            failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
@@ -1248,13 +1250,14 @@ UNS8 proceedSDO (CO_Data* d, Message *m)
 ** @return
 **/
 INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
 {
   UNS8 err;
   UNS8 SDOfound = 0;
   UNS8 line;
   s_SDO sdo;    /* SDO to transmit */
-  UNS8 i, j;
+  UNS8 i;
+  UNS32 j;
   UNS16     lastIndex;
   UNS16     offset;
   UNS8      *pNodeIdServer;
@@ -1333,9 +1336,8 @@ INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
   }
   else { /** Normal transfert */
     sdo.body.data[0] = (1 << 5) | 1;
-    sdo.body.data[4] = count; /* nb of byte to transmit. Max = 255. (canfestival2 limitation). */
-    for (i = 5 ; i < 8 ; i++)
-      sdo.body.data[i] = 0;
+    for (i = 4 ; i < 8 ; i++)
+      sdo.body.data[i] = 0;   
   }
   sdo.body.data[1] = index & 0xFF;        /* LSB */
   sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */
@@ -1369,7 +1371,7 @@ INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
 ** @return
 **/
 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data)
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data)
 {
        return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL, 1);
 }
@@ -1389,13 +1391,13 @@ UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
 ** @return
 **/
 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback)
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback)
 {
        return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, 1);
 }
 
 UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index,
-                      UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
+                      UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
 {
        UNS8 ret;
        UNS16 lastIndex;
@@ -1629,10 +1631,10 @@ UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIn
 **
 ** @return
 **/
-UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size,
+UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS32 *size,
                               UNS32 * abortCode)
 {
-  UNS8 i;
+  UNS32 i;
   UNS8 err;
   UNS8 line;
   * abortCode = 0;
@@ -1649,8 +1651,8 @@ UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size,
 
   /* Transfert is finished. Put the value in the data. */
   /* use transfers[line].count as max size */
-  if( (UNS8)d->transfers[line].count < *size )
-       *size = (UNS8)d->transfers[line].count;
+  if( d->transfers[line].count < *size )
+       *size = d->transfers[line].count;
   for  ( i = 0 ; i < *size ; i++) {
 # ifdef CANOPEN_BIG_ENDIAN
     if (d->transfers[line].dataType != visible_string)