]> git.feebdaed.xyz Git - 0xmirror/SOEM.git/commitdiff
Update EoE and config overlap to dynamic mailboxes
authorAndreas Karlsson <andreas.karlsson@rt-labs.com>
Mon, 9 Dec 2024 13:38:16 +0000 (14:38 +0100)
committerHans-Erik Floryd <hans-erik.floryd@rt-labs.com>
Wed, 9 Jul 2025 10:15:39 +0000 (12:15 +0200)
- Remove old mbxreceive
- Rename mbxreceive2 to mbxreceive
- Add EoE to mbxreceive
- Refactor EoE to use dynamic mailbox handling
- Add mailbox status mapping to config overlap
- correct length calculations in send_process_data

Change-Id: Ia51402a8c73e59dfb6ed23d98916156f81b17103

soem/ethercatcoe.c
soem/ethercatconfig.c
soem/ethercateoe.c
soem/ethercatfoe.c
soem/ethercatmain.c
soem/ethercatmain.h
soem/ethercatsoe.c

index 8887a3dee32d6113fe3739bfcbd59c912c1e758e..f27ca2f0aa5e902a2b3c96cfeaa460491de013c2 100644 (file)
@@ -133,7 +133,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
 
    MbxIn = NULL;
    MbxOut = NULL;
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -171,8 +171,8 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
       MbxIn = NULL;
       do
       {
-         wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
-      } while ((wkc > 0) && !MbxIn);   
+         wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
+      } while ((wkc > 0) && !MbxIn);
       aSDOp = (ec_SDOt *)MbxIn;
       if ((wkc > 0) && MbxIn) /* succeeded to read slave response ? */
       {
@@ -245,7 +245,7 @@ int ecx_SDOread(ecx_contextt *context, uint16 slave, uint16 index, uint8 subinde
                            if(MbxIn) ecx_dropmbx(context, MbxIn);
                            MbxIn = NULL;
                            /* read slave response */
-                           wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+                           wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
                            aSDOp = (ec_SDOt *)MbxIn;
                            /* has slave responded ? */
                            if (wkc > 0)
@@ -357,7 +357,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
 
    MbxIn = NULL;
    MbxOut = NULL;
-   wkc = ecx_mbxreceive2(context, Slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, Slave, &MbxIn, 0);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -388,7 +388,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, Slave, &MbxIn, Timeout);
+         wkc = ecx_mbxreceive(context, Slave, &MbxIn, Timeout);
          if (wkc > 0)
          {
             aSDOp = (ec_SDOt *)MbxIn;
@@ -461,7 +461,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, Slave, &MbxIn, Timeout);
+         wkc = ecx_mbxreceive(context, Slave, &MbxIn, Timeout);
          if (wkc > 0)
          {
             aSDOp = (ec_SDOt *)MbxIn;
@@ -524,7 +524,7 @@ int ecx_SDOwrite(ecx_contextt *context, uint16 Slave, uint16 Index, uint8 SubInd
                      if(MbxIn) ecx_dropmbx(context, MbxIn);
                      MbxIn = NULL;
                      /* read slave response */
-                     wkc = ecx_mbxreceive2(context, Slave, &MbxIn, Timeout);
+                     wkc = ecx_mbxreceive(context, Slave, &MbxIn, Timeout);
                      if (wkc > 0)
                      {
                         aSDOp = (ec_SDOt *)MbxIn;
@@ -593,8 +593,8 @@ int ecx_RxPDO(ecx_contextt *context, uint16 Slave, uint16 RxPDOnumber, int psize
    
    MbxIn = NULL;
    MbxOut = NULL;
-   wkc = ecx_mbxreceive2(context, Slave, &MbxIn, 0);
-   if (MbxIn) ecx_dropmbx(context, MbxIn);  
+   wkc = ecx_mbxreceive(context, Slave, &MbxIn, 0);
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -643,8 +643,8 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
 
    MbxIn = NULL;
    MbxOut = NULL;
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
-   if (MbxIn) ecx_dropmbx(context, MbxIn);  
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -664,7 +664,7 @@ int ecx_TxPDO(ecx_contextt *context, uint16 slave, uint16 TxPDOnumber , int *psi
       if(MbxIn) ecx_dropmbx(context, MbxIn);
       MbxIn = NULL;
       /* read slave response */
-      wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+      wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
       if (wkc > 0) /* succeeded to read slave response ? */
       {
          aSDOp = (ec_SDOt *)MbxIn;
@@ -1054,8 +1054,8 @@ int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, Slave, &MbxIn, 0);
-   if (MbxIn) ecx_dropmbx(context, MbxIn);  
+   wkc = ecx_mbxreceive(context, Slave, &MbxIn, 0);
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -1088,7 +1088,7 @@ int ecx_readODlist(ecx_contextt *context, uint16 Slave, ec_ODlistt *pODlist)
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, Slave, &MbxIn, EC_TIMEOUTRXM);
+         wkc = ecx_mbxreceive(context, Slave, &MbxIn, EC_TIMEOUTRXM);
          /* got response ? */
          if (wkc > 0)
          {
@@ -1182,7 +1182,7 @@ int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlis
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, Slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, Slave, &MbxIn, 0);
    if (MbxIn) ecx_dropmbx(context, MbxIn);  
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
@@ -1206,10 +1206,10 @@ int ecx_readODdescription(ecx_contextt *context, uint16 Item, ec_ODlistt *pODlis
    /* mailbox placed in slave ? */
    if (wkc > 0)
    {
-      if (MbxIn) ecx_dropmbx(context, MbxIn);  
+      if (MbxIn) ecx_dropmbx(context, MbxIn);
       MbxIn = NULL;
       /* read slave response */
-      wkc = ecx_mbxreceive2(context, Slave, &MbxIn, EC_TIMEOUTRXM);
+      wkc = ecx_mbxreceive(context, Slave, &MbxIn, EC_TIMEOUTRXM);
       /* got response ? */
       if (wkc > 0)
       {
@@ -1274,8 +1274,8 @@ int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, Slave, &MbxIn, 0);
-   if (MbxIn) ecx_dropmbx(context, MbxIn);  
+   wkc = ecx_mbxreceive(context, Slave, &MbxIn, 0);
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
    MbxOut = ecx_getmbx(context);
    if(!MbxOut) return wkc;
    ec_clearmbx(MbxOut);
@@ -1300,10 +1300,10 @@ int ecx_readOEsingle(ecx_contextt *context, uint16 Item, uint8 SubI, ec_ODlistt
    /* mailbox placed in slave ? */
    if (wkc > 0)
    {
-      if (MbxIn) ecx_dropmbx(context, MbxIn);  
+      if (MbxIn) ecx_dropmbx(context, MbxIn);
       MbxIn = NULL;
       /* read slave response */
-      wkc = ecx_mbxreceive2(context, Slave, &MbxIn, EC_TIMEOUTRXM);
+      wkc = ecx_mbxreceive(context, Slave, &MbxIn, EC_TIMEOUTRXM);
       /* got response ? */
       if (wkc > 0)
       {
index 7e4473f4776cfbc5ab044fcfc1e358842b9be085..70a058bb8882877b89263bf72dd2036496d2283c 100644 (file)
@@ -1197,8 +1197,7 @@ static void ecx_config_create_mbxstatus_mappings(ecx_contextt *context, void *pI
 
       position = etohl(context->slavelist[slave].FMMU[FMMUc].LogStart);
       context->slavelist[slave].mbxstatus = (uint8 *)(pIOmap) + position;
-      position -= context->grouplist[group].Obytes + context->grouplist[group].Ibytes;
-      context->grouplist[group].mbxstatuslookup[position] = slave;
+      context->grouplist[group].mbxstatuslookup[context->grouplist[group].mbxstatuslength] = slave;
       context->grouplist[group].mbxstatuslength++;
       FMMUc++;
       /* account for MBXSTATUS wkc increment */
@@ -1344,23 +1343,6 @@ static int ecx_main_config_map_group(ecx_contextt *context, void *pIOmap, uint8
                if (segmentsize && diff)
                   context->grouplist[group].inputsWKC++;
             }
-
-            ecx_eeprom2pdi(context, slave); /* set Eeprom control to PDI */
-            /* User may override automatic state change */
-            if (context->manualstatechange == 0)
-            {
-               /* request safe_op for slave */
-               ecx_FPWRw(context->port,
-                  configadr,
-                  ECT_REG_ALCTL,
-                  htoes(EC_STATE_SAFE_OP),
-                  EC_TIMEOUTRET3); /* set safeop status */
-            }
-            if (context->slavelist[slave].blockLRW)
-            {
-               context->grouplist[group].blockLRW++;
-            }
-            context->grouplist[group].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
          }
       }
       if (BitPos)
@@ -1380,8 +1362,8 @@ static int ecx_main_config_map_group(ecx_contextt *context, void *pIOmap, uint8
       context->grouplist[group].nsegments = currentsegment + 1;
       context->grouplist[group].inputs = (uint8 *)(pIOmap) + context->grouplist[group].Obytes;
       context->grouplist[group].Ibytes = LogAddr -
-               context->grouplist[group].logstartaddr -
-               context->grouplist[group].Obytes;
+         context->grouplist[group].logstartaddr -
+         context->grouplist[group].Obytes;
 
       /* do mbxstatus mapping of slave and program FMMUs */
       for (slave = 1; slave <= *(context->slavecount); slave++)
@@ -1405,13 +1387,6 @@ static int ecx_main_config_map_group(ecx_contextt *context, void *pIOmap, uint8
             {
                   segmentsize += diff;
             }
-            ecx_eeprom2pdi(context, slave); /* set Eeprom control to PDI */
-            ecx_FPWRw(context->port, configadr, ECT_REG_ALCTL, htoes(EC_STATE_SAFE_OP) , EC_TIMEOUTRET3); /* set safeop status */
-            if (context->slavelist[slave].blockLRW)
-            {
-               context->grouplist[group].blockLRW++;
-            }
-            context->grouplist[group].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
          }
       }
 
@@ -1428,9 +1403,42 @@ static int ecx_main_config_map_group(ecx_contextt *context, void *pIOmap, uint8
          context->slavelist[0].mbxstatus = (uint8 *)(pIOmap) + context->slavelist[0].Obytes + context->slavelist[0].Ibytes;
       }
 
-      EC_PRINT("IOmapSize %d\n", LogAddr - context->grouplist[group].logstartaddr);
 
-      return (LogAddr - context->grouplist[group].logstartaddr);
+      /* Do post mapping actions */
+      for (slave = 1; slave <= *(context->slavecount); slave++)
+      {
+         configadr = context->slavelist[slave].configadr;
+         if (!group || (group == context->slavelist[slave].group))
+         {
+            /* set Eeprom control to PDI */
+            ecx_eeprom2pdi(context, slave);
+            /* User may override automatic state change */
+            if (context->manualstatechange == 0)
+            {
+                /* request safe_op for slave */
+                ecx_FPWRw(context->port,
+                    configadr,
+                    ECT_REG_ALCTL,
+                    htoes(EC_STATE_SAFE_OP),
+                    EC_TIMEOUTRET3);
+            }
+
+            /* Store slave properties*/
+            if (context->slavelist[slave].blockLRW)
+            {
+                context->grouplist[group].blockLRW++;
+            }
+            context->grouplist[group].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
+         }
+      }
+
+      EC_PRINT("IOmapSize %d\n", context->grouplist[group].Obytes +
+          context->grouplist[group].Ibytes +
+          context->grouplist[group].mbxstatuslength);
+
+      return (context->grouplist[group].Obytes +
+          context->grouplist[group].Ibytes) +
+          context->grouplist[group].mbxstatuslength;
    }
 
    return 0;
@@ -1560,27 +1568,10 @@ int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 grou
                context->grouplist[group].inputsWKC += (siLength > 0);
                context->grouplist[group].outputsWKC += (soLength > 0);
             }
-
-            ecx_eeprom2pdi(context, slave); /* set Eeprom control to PDI */
-            /* User may override automatic state change */
-            if (context->manualstatechange == 0)
-            {
-               /* request safe_op for slave */
-               ecx_FPWRw(context->port,
-                  configadr,
-                  ECT_REG_ALCTL,
-                  htoes(EC_STATE_SAFE_OP),
-                  EC_TIMEOUTRET3);
-            }
-            if (context->slavelist[slave].blockLRW)
-            {
-               context->grouplist[group].blockLRW++;
-            }
-            context->grouplist[group].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
-
          }
       }
 
+      /* Update segment info */
       context->grouplist[group].IOsegment[currentsegment] = segmentsize;
       context->grouplist[group].nsegments = currentsegment + 1;
       context->grouplist[group].Isegment = 0;
@@ -1593,7 +1584,7 @@ int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 grou
 
       context->grouplist[group].mbxstatus = (uint8 *)pIOmap + context->grouplist[group].Obytes + context->grouplist[group].Ibytes;
 
-     /* Move calculated inputs with OBytes offset*/
+      /* Move calculated inputs with OBytes offset */
       for (slave = 1; slave <= *(context->slavecount); slave++)
       {
          if (!group || (group == context->slavelist[slave].group))
@@ -1605,6 +1596,38 @@ int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 grou
          }
       }
 
+      /* Do mbxstatus mapping of slave and program FMMUs */
+      for (slave = 1; slave <= *(context->slavecount); slave++)
+      {
+         configadr = context->slavelist[slave].configadr;
+         if (!group || (group == context->slavelist[slave].group))
+         {
+            ecx_config_create_mbxstatus_mappings(context, pIOmap, group, slave, &tempLogAddr);
+            diff = tempLogAddr - mLogAddr;
+            mLogAddr = tempLogAddr;
+            if ((segmentsize + diff) > (EC_MAXLRWDATA - EC_FIRSTDCDATAGRAM))
+            {
+                context->grouplist[group].IOsegment[currentsegment] = segmentsize;
+                if (currentsegment < (EC_MAXIOSEGMENTS - 1))
+                {
+                    currentsegment++;
+                    segmentsize = diff;
+                }
+            }
+            else
+            {
+                segmentsize += diff;
+            }
+            /* Move calculated mbxstatus with OBytes + Ibytes offset */
+            context->slavelist[slave].mbxstatus += context->grouplist[group].Obytes;
+            context->slavelist[slave].mbxstatus += context->grouplist[group].Ibytes;
+         }
+      }
+
+      /* Update segment info */
+      context->grouplist[group].IOsegment[currentsegment] = segmentsize;
+      context->grouplist[group].nsegments = currentsegment + 1;
+
       if (!group)
       {
          /* store output bytes in master record */
@@ -1612,12 +1635,46 @@ int ecx_config_overlap_map_group(ecx_contextt *context, void *pIOmap, uint8 grou
          context->slavelist[0].Obytes = soLogAddr - context->grouplist[group].logstartaddr;
          context->slavelist[0].inputs = (uint8 *)pIOmap + context->slavelist[0].Obytes;
          context->slavelist[0].Ibytes = siLogAddr - context->grouplist[group].logstartaddr;
-         context->slavelist[0].mbxstatus = (uint8 *)pIOmap + context->slavelist[0].Obytes + context->slavelist[0].Ibytes;
+         context->slavelist[0].mbxstatus = (uint8 *)pIOmap +
+            context->slavelist[0].Obytes +
+            context->slavelist[0].Ibytes;
+      }
+
+      /* Do post mapping actions */
+      for (slave = 1; slave <= *(context->slavecount); slave++)
+      {
+         configadr = context->slavelist[slave].configadr;
+         if (!group || (group == context->slavelist[slave].group))
+         {
+            /* set Eeprom control to PDI */
+            ecx_eeprom2pdi(context, slave);
+            /* User may override automatic state change */
+            if (context->manualstatechange == 0)
+            {
+                /* request safe_op for slave */
+                ecx_FPWRw(context->port,
+                    configadr,
+                    ECT_REG_ALCTL,
+                    htoes(EC_STATE_SAFE_OP),
+                    EC_TIMEOUTRET3);
+            }
+
+            /* Store slave properties*/
+            if (context->slavelist[slave].blockLRW)
+            {
+                context->grouplist[group].blockLRW++;
+            }
+            context->grouplist[group].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
+         }
       }
 
-      EC_PRINT("IOmapSize %d\n", context->grouplist[group].Obytes + context->grouplist[group].Ibytes);
+      EC_PRINT("IOmapSize %d\n", context->grouplist[group].Obytes +
+          context->grouplist[group].Ibytes +
+          context->grouplist[group].mbxstatuslength);
 
-      return (context->grouplist[group].Obytes + context->grouplist[group].Ibytes);
+      return (context->grouplist[group].Obytes +
+          context->grouplist[group].Ibytes) +
+          context->grouplist[group].mbxstatuslength;
    }
 
    return 0;
index 3e25c428aa9695c5a9cffe27649dabc7dac9d8a0..d677e07b7a0a49775498b7aae8628ee804d81e2d 100644 (file)
@@ -68,19 +68,20 @@ int ecx_EOEdefinehook(ecx_contextt *context, void *hook)
 */
 int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t * ipparam, int timeout)
 {
-   ec_EOEt *EOEp, *aEOEp;  
-   ec_mbxbuft MbxIn, MbxOut;  
+   ec_EOEt *EOEp, *aEOEp;
+   ec_mbxbuft *MbxIn, *MbxOut;
    uint16 frameinfo1, result;
    uint8 cnt, data_offset;
    uint8 flags = 0;
    int wkc;
 
-   ec_clearmbx(&MbxIn);
+   MbxIn = NULL;
+   MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive(context,  slave, (ec_mbxbuft *)&MbxIn, 0);
-   ec_clearmbx(&MbxOut);
-   aEOEp = (ec_EOEt *)&MbxIn;
-   EOEp = (ec_EOEt *)&MbxOut;  
+   wkc = ecx_mbxreceive(context,  slave, &MbxIn, 0);
+   MbxOut = ecx_getmbx(context);
+   ec_clearmbx(MbxOut);
+   EOEp = (ec_EOEt *)MbxOut;
    EOEp->mbxheader.address = htoes(0x0000);
    EOEp->mbxheader.priority = 0x00;
    data_offset = EOE_PARAM_OFFSET;
@@ -138,17 +139,19 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
    EOEp->data[0] = flags;
 
    /* send EoE request to slave */
-   wkc = ecx_mbxsend(context, slave, (ec_mbxbuft *)&MbxOut, EC_TIMEOUTTXM);
+   wkc = ecx_mbxsend(context, slave, MbxOut, EC_TIMEOUTTXM);
+   MbxOut = NULL;
 
    if (wkc > 0) /* succeeded to place mailbox in slave ? */
    {
-      /* clean mailboxbuffer */
-      ec_clearmbx(&MbxIn);
+       if (MbxIn) ecx_dropmbx(context, MbxIn);
+       MbxIn = NULL;
       /* read slave response */
-      wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, timeout);
+      wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
       if (wkc > 0) /* succeeded to read slave response ? */
       {
-         /* slave response should be FoE */
+          aEOEp = (ec_EOEt*)MbxIn;
+         /* slave response should be EoE */
          if ((aEOEp->mbxheader.mbxtype & 0x0f) == ECT_MBXT_EOE)
          {
             frameinfo1 = etohs(aEOEp->frameinfo1);
@@ -166,6 +169,10 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
          }
       }
    }
+
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
+   if (MbxOut) ecx_dropmbx(context, MbxOut);
+
    return wkc;
 }
 
@@ -181,17 +188,19 @@ int ecx_EOEsetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
 int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t * ipparam, int timeout)
 {
    ec_EOEt *EOEp, *aEOEp;
-   ec_mbxbuft MbxIn, MbxOut;
+   ec_mbxbuft *MbxIn, *MbxOut;
    uint16 frameinfo1, eoedatasize;
    uint8 cnt, data_offset;
    uint8 flags = 0;
    int wkc;
 
+   MbxIn = NULL;
+   MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, 0);
-   ec_clearmbx(&MbxOut);
-   aEOEp = (ec_EOEt *)&MbxIn;
-   EOEp = (ec_EOEt *)&MbxOut;
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
+   MbxOut = ecx_getmbx(context);
+   ec_clearmbx(MbxOut);
+   EOEp = (ec_EOEt *)MbxOut;
    EOEp->mbxheader.address = htoes(0x0000);
    EOEp->mbxheader.priority = 0x00;
    data_offset = EOE_PARAM_OFFSET;
@@ -211,15 +220,17 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
    EOEp->data[0] = flags;
 
    /* send EoE request to slave */
-   wkc = ecx_mbxsend(context, slave, (ec_mbxbuft *)&MbxOut, EC_TIMEOUTTXM);
+   wkc = ecx_mbxsend(context, slave, MbxOut, EC_TIMEOUTTXM);
+   MbxOut = NULL;
    if (wkc > 0) /* succeeded to place mailbox in slave ? */
    {
-      /* clean mailboxbuffer */
-      ec_clearmbx(&MbxIn);
+       if (MbxIn) ecx_dropmbx(context, MbxIn);
+       MbxIn = NULL;
       /* read slave response */
-      wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, timeout);
+      wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
       if (wkc > 0) /* succeeded to read slave response ? */
       {
+          aEOEp = (ec_EOEt*)MbxIn;
          /* slave response should be FoE */
          if ((aEOEp->mbxheader.mbxtype & 0x0f) == ECT_MBXT_EOE)
          {
@@ -298,6 +309,10 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
          }
       }
    }
+
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
+   if (MbxOut) ecx_dropmbx(context, MbxOut);
+
    return wkc;
 }
 
@@ -318,7 +333,7 @@ int ecx_EOEgetIp(ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *
 int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void *p, int timeout)
 {
    ec_EOEt *EOEp;
-   ec_mbxbuft MbxOut;
+   ec_mbxbuft *MbxOut;
    uint16 frameinfo1, frameinfo2;
    uint8 cnt, txfragmentno;  
    boolean  NotLast;
@@ -326,10 +341,7 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
    const uint8 * buf = p;
    static uint8_t txframeno = 0;
 
-   ec_clearmbx(&MbxOut);
-   EOEp = (ec_EOEt *)&MbxOut;
-   EOEp->mbxheader.address = htoes(0x0000);
-   EOEp->mbxheader.priority = 0x00;
+   MbxOut = NULL;
    /* data section=mailbox size - 6 mbx - 4 EoEh */
    maxdata = context->slavelist[slave].mbx_l - 0x0A; 
    txframesize = psize;
@@ -339,6 +351,12 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
 
    do
    {
+      MbxOut = ecx_getmbx(context);
+      ec_clearmbx(MbxOut);
+      EOEp = (ec_EOEt*)MbxOut;
+      EOEp->mbxheader.address = htoes(0x0000);
+      EOEp->mbxheader.priority = 0x00;
+
       txframesize = psize - txframeoffset;
       if (txframesize > maxdata)
       {
@@ -381,14 +399,17 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
       memcpy(EOEp->data, &buf[txframeoffset], txframesize);
 
       /* send EoE request to slave */
-      wkc = ecx_mbxsend(context, slave, (ec_mbxbuft *)&MbxOut, timeout);
+      wkc = ecx_mbxsend(context, slave, MbxOut, timeout);
+      MbxOut = NULL;
       if ((NotLast == TRUE)  && (wkc > 0))
       {
          txframeoffset += txframesize;
          txfragmentno++;
       }
    } while ((NotLast == TRUE) && (wkc > 0));
-   
+
+   if (MbxOut) ecx_dropmbx(context, MbxOut);
+
    return wkc;
 }
 
@@ -410,15 +431,14 @@ int ecx_EOEsend(ecx_contextt *context, uint16 slave, uint8 port, int psize, void
 int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, void *p, int timeout)
 {
    ec_EOEt *aEOEp;
-   ec_mbxbuft MbxIn;
+   ec_mbxbuft *MbxIn;
    uint16 frameinfo1, frameinfo2;
    uint8 rxfragmentno, rxframeno;
    boolean NotLast;
    int wkc, buffersize, rxframesize, rxframeoffset, eoedatasize;
    uint8 * buf = p;
-   
-   ec_clearmbx(&MbxIn);
-   aEOEp = (ec_EOEt *)&MbxIn;
+
+   MbxIn = NULL;
    NotLast = TRUE;
    buffersize = *psize;
    rxfragmentno = 0;
@@ -426,14 +446,14 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
    rxframeoffset = 0;
    
    /* Hang for a while if nothing is in */
-   wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, timeout);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
 
    while ((wkc > 0) && (NotLast == TRUE))
    {
+      aEOEp = (ec_EOEt*)MbxIn;
       /* slave response should be FoE */
       if ((aEOEp->mbxheader.mbxtype & 0x0f) == ECT_MBXT_EOE)
       {
-        
          eoedatasize = etohs(aEOEp->mbxheader.length) - 0x00004;
          frameinfo1 = etohs(aEOEp->frameinfo1);
          frameinfo2 = etohs(aEOEp->frameinfo2);
@@ -500,8 +520,10 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
          }
          else
          {
+             if (MbxIn) ecx_dropmbx(context, MbxIn);
+             MbxIn = NULL;
             /* Hang for a while if nothing is in */
-            wkc = ecx_mbxreceive(context, slave, (ec_mbxbuft *)&MbxIn, timeout);
+            wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
          }
       }
       else
@@ -510,6 +532,7 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
          wkc = -EC_ERR_TYPE_PACKET_ERROR;
       }
    }
+   if (MbxIn) ecx_dropmbx(context, MbxIn);
    return wkc;
 }
 
@@ -528,12 +551,12 @@ int ecx_EOErecv(ecx_contextt *context, uint16 slave, uint8 port, int * psize, vo
 * @return 0= if fragment OK, >0 if last fragment, <0 on error
 */
 int ecx_EOEreadfragment(
-   ec_mbxbuft * MbxIn,
-   uint8 * rxfragmentno,
-   uint16 * rxframesize, 
-   uint16 * rxframeoffset, 
-   uint16 * rxframeno,
-   int * psize, 
+   ec_mbxbuft *MbxIn,
+   uint8 *rxfragmentno,
+   uint16 *rxframesize,
+   uint16 *rxframeoffset,
+   uint16 *rxframeno,
+   int *psize,
    void *p)
 {  
    uint16 frameinfo1, frameinfo2,  eoedatasize;
index d7d4efc514a3fb3ab94aa5d44ffd9afb4447e278..8351a831f50d26ae8398984b666667deb8e528ce 100644 (file)
@@ -90,7 +90,7 @@ int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 pass
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
    MbxOut = ecx_getmbx(context);
    ec_clearmbx(MbxOut);
    FOEp = (ec_FOEt *)MbxOut;
@@ -126,7 +126,7 @@ int ecx_FOEread(ecx_contextt *context, uint16 slave, char *filename, uint32 pass
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+         wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
          if (wkc > 0) /* succeeded to read slave response ? */
          {
             aFOEp = (ec_FOEt *)MbxIn;
@@ -230,7 +230,7 @@ int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 pas
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
    MbxOut = ecx_getmbx(context);
    ec_clearmbx(MbxOut);
    FOEp = (ec_FOEt *)MbxOut;
@@ -267,7 +267,7 @@ int ecx_FOEwrite(ecx_contextt *context, uint16 slave, char *filename, uint32 pas
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+         wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
          if (wkc > 0) /* succeeded to read slave response ? */
          {
             aFOEp = (ec_FOEt *)MbxIn;
index 174eb4fbfa35a0c7bad722f9625e821b8bcdcc8e..da21649705f8eb6816ad3d5ad9eb3a5197cf059b 100644 (file)
@@ -1226,7 +1226,10 @@ int ecx_mbxinhandler(ecx_contextt *context, uint8 group, int limit)
          /* handle robust mailbox protocol state machine */
          if(slaveitem->mbxrmpstate)
          {
-            if(slaveitem->islost) slaveitem->mbxrmpstate = 0;   
+            if(slaveitem->islost)
+            {
+                slaveitem->mbxrmpstate = 0;
+            }
             else
             {
                switch(slaveitem->mbxrmpstate)
@@ -1247,6 +1250,7 @@ int ecx_mbxinhandler(ecx_contextt *context, uint8 group, int limit)
                      break; 
                   case 3 :
                      /* wait for repeat ack */
+                     SMstatex = htoes(slaveitem->mbxinstateex);
                      wkc2 = ecx_FPRD(context->port, configadr, ECT_REG_SM1CONTR, sizeof(SMcontr), &SMcontr, EC_TIMEOUTRET);
                      if((wkc2 > 0) && ((SMcontr & 0x02) == (HI_BYTE(SMstatex) & 0x02)))
                      {
@@ -1313,7 +1317,24 @@ int ecx_mbxinhandler(ecx_contextt *context, uint8 group, int limit)
                   }
                   else if ((mbxh->mbxtype & 0x0f) == ECT_MBXT_EOE) /* EoE response? */
                   {
-                     if(slaveitem->eoembxin && (slaveitem->eoembxinfull == FALSE))
+                     ec_EOEt *eoembx = (ec_EOEt*)mbx;
+                     uint16 frameinfo1 = etohs(eoembx->frameinfo1);
+                     /* All non fragment data frame types are expected to be handled by
+                      * slave send/receive API if the EoE hook is set
+                      */
+                     if (EOE_HDR_FRAME_TYPE_GET(frameinfo1) == EOE_FRAG_DATA)
+                     {
+                        if (context->EOEhook)
+                        {
+                           if (context->EOEhook(context, slave, eoembx) > 0)
+                           {
+                              /* Fragment handled by EoE hook */
+                              wkc = 0;
+                            }
+                        }
+                     }
+                     /* Not handled by hook */
+                     if((wkc > 0) && slaveitem->eoembxin && (slaveitem->eoembxinfull == FALSE))
                      {
                         slaveitem->eoembxin = (uint8 *)mbx;
                         mbx = NULL;
@@ -1372,7 +1393,7 @@ int ecx_mbxinhandler(ecx_contextt *context, uint8 group, int limit)
                /* release mailbox to pool if still owner */
                if (mbx)
                {
-                  ecx_dropmbx(context, mbx);  
+                  ecx_dropmbx(context, mbx);
                }
             }
          }
@@ -1510,158 +1531,7 @@ int ecx_mbxsend(ecx_contextt *context, uint16 slave,ec_mbxbuft *mbx, int timeout
       }
       if(wkc < 0 ) wkc = 0;
    }
-   if (mbx) ecx_dropmbx(context, mbx);  
-   return wkc;
-}
-
-/** Read OUT mailbox from slave.
- * Supports Mailbox Link Layer with repeat requests.
- * @param[in]  context    = context struct
- * @param[in]  slave      = Slave number
- * @param[out] mbx        = Mailbox data
- * @param[in]  timeout    = Timeout in us
- * @return Work counter (>0 is success)
- */
-int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout)
-{
-   uint16 mbxro,mbxl,configadr;
-   int wkc=0;
-   int wkc2;
-   uint8 SMstat;
-   uint16 SMstatex;
-   uint8 SMcontr;
-   ec_mbxheadert *mbxh;
-   ec_emcyt *EMp;
-   ec_mbxerrort *MBXEp;
-   osal_timert timer;
-   ec_slavet *slavelist = &(context->slavelist[slave]);
-
-   configadr = slavelist->configadr;
-   mbxl = slavelist->mbx_rl;
-   if (slavelist->mbxhandlerstate == ECT_MBXH_CYCLIC)
-   {
-      osal_timer_start(&timer, timeout);
-      wkc = 0;
-      do
-      {
-         if (slavelist->coembxinfull == TRUE)
-         {
-            memcpy(mbx, slavelist->coembxin, mbxl);
-            ecx_dropmbx(context, (ec_mbxbuft *)slavelist->coembxin);
-            slavelist->coembxin = EC_MBXINENABLE;
-            slavelist->coembxinfull = FALSE;
-            wkc = 1;
-         }
-         else if (slavelist->soembxinfull == TRUE)
-         {
-            memcpy(mbx, slavelist->soembxin, mbxl);
-            slavelist->soembxinfull = FALSE;
-            wkc = 1;
-         }
-         else if (slavelist->foembxinfull == TRUE)
-         {
-            memcpy(mbx, slavelist->foembxin, mbxl);
-            slavelist->foembxinfull = FALSE;
-            wkc = 1;
-         }
-         if (!wkc && (timeout > EC_LOCALDELAY))
-         {
-            osal_usleep(EC_LOCALDELAY);
-         }
-      }
-      while ((wkc <= 0) && (osal_timer_is_expired(&timer) == FALSE));
-   }
-   else if ((mbxl > 0) && (mbxl <= EC_MAXMBX))
-   {
-      osal_timer_start(&timer, timeout);
-      wkc = 0;
-      do /* wait for read mailbox available */
-      {
-         SMstat = 0;
-         wkc = ecx_readmbxstatus(context, slave, &SMstat);
-         if (((SMstat & 0x08) == 0) && (timeout > EC_LOCALDELAY))
-         {
-            osal_usleep(EC_LOCALDELAY);
-         }
-      }
-      while (((wkc <= 0) || ((SMstat & 0x08) == 0)) && (osal_timer_is_expired(&timer) == FALSE));
-
-      if ((wkc > 0) && ((SMstat & 0x08) > 0)) /* read mailbox available ? */
-      {
-         mbxro = slavelist->mbx_ro;
-         mbxh = (ec_mbxheadert *)mbx;
-         do
-         {
-            wkc = ecx_FPRD(context->port, configadr, mbxro, mbxl, mbx, EC_TIMEOUTRET); /* get mailbox */
-            if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == 0x00)) /* Mailbox error response? */
-            {
-               MBXEp = (ec_mbxerrort *)mbx;
-               ecx_mbxerror(context, slave, etohs(MBXEp->Detail));
-               wkc = 0; /* prevent emergency to cascade up, it is already handled. */
-            }
-            else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == ECT_MBXT_COE)) /* CoE response? */
-            {
-               EMp = (ec_emcyt *)mbx;
-               if ((etohs(EMp->CANOpen) >> 12) == 0x01) /* Emergency request? */
-               {
-                  ecx_mbxemergencyerror(context, slave, etohs(EMp->ErrorCode), EMp->ErrorReg,
-                          EMp->bData, etohs(EMp->w1), etohs(EMp->w2));
-                  wkc = 0; /* prevent emergency to cascade up, it is already handled. */
-               }
-            }
-            else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == ECT_MBXT_EOE)) /* EoE response? */
-            {
-               ec_EOEt * eoembx = (ec_EOEt *)mbx;
-               uint16 frameinfo1 = etohs(eoembx->frameinfo1);
-               /* All non fragment data frame types are expected to be handled by
-               * slave send/receive API if the EoE hook is set
-               */
-               if (EOE_HDR_FRAME_TYPE_GET(frameinfo1) == EOE_FRAG_DATA)
-               {
-                  if (context->EOEhook)
-                  {
-                     if (context->EOEhook(context, slave, eoembx) > 0)
-                     {
-                        /* Fragment handled by EoE hook */
-                        wkc = 0;
-                     }
-                  }
-               }
-            }
-            else
-            {
-               if (wkc <= 0) /* read mailbox lost */
-               {
-                  do /* read extended mailbox status */
-                  {
-                     wkc2 = ecx_readmbxstatusex(context, slave, &SMstatex);
-                  } while ((wkc2 <= 0) && (osal_timer_is_expired(&timer) == FALSE));
-                  SMstatex ^= 0x0200; /* toggle repeat request */
-                  SMstatex = htoes(SMstatex);
-                  wkc2 = ecx_FPWR(context->port, configadr, ECT_REG_SM1STAT, sizeof(SMstatex), &SMstatex, EC_TIMEOUTRET);
-                  SMstatex = etohs(SMstatex);
-                  do /* wait for toggle ack */
-                  {
-                     wkc2 = ecx_FPRD(context->port, configadr, ECT_REG_SM1CONTR, sizeof(SMcontr), &SMcontr, EC_TIMEOUTRET);
-                   } while (((wkc2 <= 0) || ((SMcontr & 0x02) != (HI_BYTE(SMstatex) & 0x02))) && (osal_timer_is_expired(&timer) == FALSE));
-                  do /* wait for read mailbox available */
-                  {
-                     wkc2 = ecx_readmbxstatusex(context, slave, &SMstatex);
-                     if (((SMstatex & 0x08) == 0) && (timeout > EC_LOCALDELAY))
-                     {
-                        osal_usleep(EC_LOCALDELAY);
-                     }
-                  } while (((wkc2 <= 0) || ((SMstatex & 0x08) == 0)) && (osal_timer_is_expired(&timer) == FALSE));
-               }
-            }
-         } while ((wkc <= 0) && (osal_timer_is_expired(&timer) == FALSE)); /* if WKC<=0 repeat */
-      }
-      else /* no read mailbox available */
-      {
-          wkc = 0;
-      }
-   }
-
+   if (mbx) ecx_dropmbx(context, mbx);
    return wkc;
 }
 
@@ -1675,7 +1545,7 @@ int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int tim
  * @param[in]  timeout    = Timeout in us
  * @return Work counter (>0 is success)
  */
-int ecx_mbxreceive2(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int timeout)
+int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int timeout)
 {
    uint16 mbxro,mbxl,configadr;
    int wkc=0;
@@ -1719,6 +1589,13 @@ int ecx_mbxreceive2(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int t
             slavelist->foembxinfull = FALSE;
             wkc = 1;
          }
+         else if (slavelist->eoembxinfull == TRUE)
+         {
+             *mbx = (ec_mbxbuft*)slavelist->eoembxin;
+             slavelist->eoembxin = EC_MBXINENABLE;
+             slavelist->eoembxinfull = FALSE;
+             wkc = 1;
+         }
          if (!wkc && (timeout > EC_LOCALDELAY))
          {
             osal_usleep(EC_LOCALDELAY);
@@ -1757,7 +1634,7 @@ int ecx_mbxreceive2(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int t
                mbxin = NULL;
                wkc = 0; /* prevent emergency to cascade up, it is already handled. */
             }
-            else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == 0x03)) /* CoE response? */
+            else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == ECT_MBXT_COE)) /* CoE response? */
             {
                EMp = (ec_emcyt *)mbx;
                if ((etohs(EMp->CANOpen) >> 12) == 0x01) /* Emergency request? */
@@ -1774,6 +1651,33 @@ int ecx_mbxreceive2(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int t
                   mbxin = NULL;
                }
             }
+            else if ((wkc > 0) && ((mbxh->mbxtype & 0x0f) == ECT_MBXT_EOE)) /* EoE response? */
+            {
+                ec_EOEt* eoembx = (ec_EOEt*)mbx;
+                uint16 frameinfo1 = etohs(eoembx->frameinfo1);
+                /* All non fragment data frame types are expected to be handled by
+                * slave send/receive API if the EoE hook is set
+                */
+                if (EOE_HDR_FRAME_TYPE_GET(frameinfo1) == EOE_FRAG_DATA)
+                {
+                    if (context->EOEhook)
+                    {
+                        if (context->EOEhook(context, slave, eoembx) > 0)
+                        {
+                            /* Fragment handled by EoE hook */
+                            ecx_dropmbx(context, mbxin);
+                            mbxin = NULL;
+                            wkc = 0;
+                        }
+                    }
+                }
+                /* Not handled by EoE hook*/
+                if(wkc > 0)
+                {
+                    *mbx = mbxin;
+                    mbxin = NULL;
+                }
+            }
             else
             {
                if (wkc <= 0) /* read mailbox lost */
@@ -2432,12 +2336,15 @@ static int ecx_main_send_processdata(ecx_contextt *context, uint8 group, boolean
       /* For overlap IOmap make the frame EQ big to biggest part */
       length = (context->grouplist[group].Obytes > context->grouplist[group].Ibytes) ?
          context->grouplist[group].Obytes : context->grouplist[group].Ibytes;
+      length += context->grouplist[group].mbxstatuslength;
       /* Save the offset used to compensate where to save inputs when frame returns */
       iomapinputoffset = context->grouplist[group].Obytes;
    }
    else
    {
-      length = context->grouplist[group].Obytes + context->grouplist[group].Ibytes;
+       length = context->grouplist[group].Obytes +
+           context->grouplist[group].Ibytes +
+           context->grouplist[group].mbxstatuslength;
       iomapinputoffset = 0;
    }
    
index 4bfcac8961c31eb9f92efcd039948ecf623ee1ad..205a33dbff1d2a43e5e5d6d470a035855e9fcfe1 100644 (file)
@@ -602,8 +602,7 @@ uint16 ecx_statecheck(ecx_contextt *context, uint16 slave, uint16 reqstate, int
 int ecx_mbxhandler(ecx_contextt *context, uint8 group, int limit);
 int ecx_mbxempty(ecx_contextt *context, uint16 slave, int timeout);
 int ecx_mbxsend(ecx_contextt *context, uint16 slave,ec_mbxbuft *mbx, int timeout);
-int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft *mbx, int timeout);
-int ecx_mbxreceive2(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int timeout);
+int ecx_mbxreceive(ecx_contextt *context, uint16 slave, ec_mbxbuft **mbx, int timeout);
 void ecx_esidump(ecx_contextt *context, uint16 slave, uint8 *esibuf);
 uint32 ecx_readeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, int timeout);
 int ecx_writeeeprom(ecx_contextt *context, uint16 slave, uint16 eeproma, uint16 data, int timeout);
index 862f4f13c78d9f2b5c879918930b52a75d6ba88d..da0b0cf7725f227a3d43cda1cb54494c4e82c21d 100644 (file)
@@ -91,7 +91,7 @@ int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elemen
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
    MbxOut = ecx_getmbx(context);
    ec_clearmbx(MbxOut);
    SoEp = (ec_SoEt *)MbxOut;
@@ -122,7 +122,7 @@ int ecx_SoEread(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 elemen
          if(MbxIn) ecx_dropmbx(context, MbxIn);
          MbxIn = NULL;
          /* read slave response */
-         wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+         wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
          if (wkc > 0) /* succeeded to read slave response ? */
          {
             aSoEp = (ec_SoEt *)MbxIn;
@@ -218,7 +218,7 @@ int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 eleme
    MbxIn = NULL;
    MbxOut = NULL;
    /* Empty slave out mailbox if something is in. Timout set to 0 */
-   wkc = ecx_mbxreceive2(context, slave, &MbxIn, 0);
+   wkc = ecx_mbxreceive(context, slave, &MbxIn, 0);
    hp = p;
    maxdata = context->slavelist[slave].mbx_l - sizeof(ec_SoEt);
    NotLast = TRUE;
@@ -264,7 +264,7 @@ int ecx_SoEwrite(ecx_contextt *context, uint16 slave, uint8 driveNo, uint8 eleme
             if(MbxIn) ecx_dropmbx(context, MbxIn);
             MbxIn = NULL;
             /* read slave response */
-            wkc = ecx_mbxreceive2(context, slave, &MbxIn, timeout);
+            wkc = ecx_mbxreceive(context, slave, &MbxIn, timeout);
             if (wkc > 0) /* succeeded to read slave response ? */
             {
                aSoEp = (ec_SoEt *)MbxIn;