Multithreaded-software/external/soem/soem/ethercatsoe.c
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
{
   int retVal = 0;
   int   wkc;
   int psize;
   int driveNr;
   uint16 entries, itemcount;
   ec_SoEmappingt     SoEmapping;
   ec_SoEattributet   SoEattribute;

   *Isize = 0;
   *Osize = 0;
   for(driveNr = 0; driveNr < EC_SOE_MAX_DRIVES; driveNr++)
   {
      psize = sizeof(SoEmapping);
      /* read output mapping via SoE */
      wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_VALUE_B, EC_IDN_MDTCONFIG, &psize, &SoEmapping, EC_TIMEOUTRXM);
      if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
      {
         /* command word (uint16) is always mapped but not in list */
         *Osize = 16;
         for (itemcount = 0 ; itemcount < entries ; itemcount++)
         {
            psize = sizeof(SoEattribute);
            /* read attribute of each IDN in mapping list */
            wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_ATTRIBUTE_B, SoEmapping.idn[itemcount], &psize, &SoEattribute, EC_TIMEOUTRXM);
            if ((wkc > 0) && (!SoEattribute.list))
            {
               /* length : 0 = 8bit, 1 = 16bit .... */
               *Osize += (int)8 << SoEattribute.length;
            }
         }
      }
      psize = sizeof(SoEmapping);
      /* read input mapping via SoE */
      wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_VALUE_B, EC_IDN_ATCONFIG, &psize, &SoEmapping, EC_TIMEOUTRXM);
      if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
      {
         /* status word (uint16) is always mapped but not in list */
         *Isize = 16;
         for (itemcount = 0 ; itemcount < entries ; itemcount++)
         {
            psize = sizeof(SoEattribute);
            /* read attribute of each IDN in mapping list */
            wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_ATTRIBUTE_B, SoEmapping.idn[itemcount], &psize, &SoEattribute, EC_TIMEOUTRXM);
            if ((wkc > 0) && (!SoEattribute.list))
            {
               /* length : 0 = 8bit, 1 = 16bit .... */
               *Isize += (int)8 << SoEattribute.length;
            }
         }
      }
   }

   /* found some I/O bits ? */
   if ((*Isize > 0) || (*Osize > 0))
   {
      retVal = 1;
   }
   return retVal;
}
/** SoE read AT and MTD mapping.
 *
 * SoE has standard indexes defined for mapping. This function
 * tries to read them and collect a full input and output mapping size
 * of designated slave.
 *
 * @param[in]  context = context struct
 * @param[in]  slave   = Slave number
 * @param[out] Osize   = Size in bits of output mapping (MTD) found
 * @param[out] Isize   = Size in bits of input mapping (AT) found
 * @return >0 if mapping succesful.
 */
SoE read AT and MTD mapping.
SoE has standard indexes defined for mapping. This function
tries to read them and collect a full input and output mapping size
of designated slave.


SoE read AT and MTD mapping . SoE has standard indexes defined for mapping . This function tries to read them and collect a full input and output mapping size of designated slave .
int ecx_readIDNmap(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
{
   int retVal = 0;
   int   wkc;
   int psize;
   int driveNr;
   uint16 entries, itemcount;
   ec_SoEmappingt     SoEmapping;
   ec_SoEattributet   SoEattribute;
   *Isize = 0;
   *Osize = 0;
   for(driveNr = 0; driveNr < EC_SOE_MAX_DRIVES; driveNr++)
   {
      psize = sizeof(SoEmapping);
      wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_VALUE_B, EC_IDN_MDTCONFIG, &psize, &SoEmapping, EC_TIMEOUTRXM);
      if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
      {
         *Osize = 16;
         for (itemcount = 0 ; itemcount < entries ; itemcount++)
         {
            psize = sizeof(SoEattribute);
            wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_ATTRIBUTE_B, SoEmapping.idn[itemcount], &psize, &SoEattribute, EC_TIMEOUTRXM);
            if ((wkc > 0) && (!SoEattribute.list))
            {
               *Osize += (int)8 << SoEattribute.length;
            }
         }
      }
      psize = sizeof(SoEmapping);
      wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_VALUE_B, EC_IDN_ATCONFIG, &psize, &SoEmapping, EC_TIMEOUTRXM);
      if ((wkc > 0) && (psize >= 4) && ((entries = etohs(SoEmapping.currentlength) / 2) > 0) && (entries <= EC_SOE_MAXMAPPING))
      {
         *Isize = 16;
         for (itemcount = 0 ; itemcount < entries ; itemcount++)
         {
            psize = sizeof(SoEattribute);
            wkc = ecx_SoEread(context, slave, driveNr, EC_SOE_ATTRIBUTE_B, SoEmapping.idn[itemcount], &psize, &SoEattribute, EC_TIMEOUTRXM);
            if ((wkc > 0) && (!SoEattribute.list))
            {
               *Isize += (int)8 << SoEattribute.length;
            }
         }
      }
   }
   if ((*Isize > 0) || (*Osize > 0))
   {
      retVal = 1;
   }
   return retVal;
}
int ecx_readIDNmap ( ecx_contextt * context , uint16 slave , int * Osize , int * Isize ) { int retVal = 0 ; int wkc ; int psize ; int driveNr ; uint16 entries , itemcount ; ec_SoEmappingt SoEmapping ; ec_SoEattributet SoEattribute ; * Isize = 0 ; * Osize = 0 ; for ( driveNr = 0 ; driveNr < EC_SOE_MAX_DRIVES ; driveNr ++ ) { psize = sizeof ( SoEmapping ) ; wkc = ecx_SoEread ( context , slave , driveNr , EC_SOE_VALUE_B , EC_IDN_MDTCONFIG , & psize , & SoEmapping , EC_TIMEOUTRXM ) ; if ( ( wkc > 0 ) && ( psize >= 4 ) && ( ( entries = etohs ( SoEmapping . currentlength ) / 2 ) > 0 ) && ( entries <= EC_SOE_MAXMAPPING ) ) { * Osize = 16 ; for ( itemcount = 0 ; itemcount < entries ; itemcount ++ ) { psize = sizeof ( SoEattribute ) ; wkc = ecx_SoEread ( context , slave , driveNr , EC_SOE_ATTRIBUTE_B , SoEmapping . idn [ itemcount ] , & psize , & SoEattribute , EC_TIMEOUTRXM ) ; if ( ( wkc > 0 ) && ( ! SoEattribute . list ) ) { * Osize += ( int ) 8 << SoEattribute . length ; } } } psize = sizeof ( SoEmapping ) ; wkc = ecx_SoEread ( context , slave , driveNr , EC_SOE_VALUE_B , EC_IDN_ATCONFIG , & psize , & SoEmapping , EC_TIMEOUTRXM ) ; if ( ( wkc > 0 ) && ( psize >= 4 ) && ( ( entries = etohs ( SoEmapping . currentlength ) / 2 ) > 0 ) && ( entries <= EC_SOE_MAXMAPPING ) ) { * Isize = 16 ; for ( itemcount = 0 ; itemcount < entries ; itemcount ++ ) { psize = sizeof ( SoEattribute ) ; wkc = ecx_SoEread ( context , slave , driveNr , EC_SOE_ATTRIBUTE_B , SoEmapping . idn [ itemcount ] , & psize , & SoEattribute , EC_TIMEOUTRXM ) ; if ( ( wkc > 0 ) && ( ! SoEattribute . list ) ) { * Isize += ( int ) 8 << SoEattribute . length ; } } } } if ( ( * Isize > 0 ) || ( * Osize > 0 ) ) { retVal = 1 ; } return retVal ; }
SoE read AT and MTD mapping.
SoE read AT and MTD mapping .
/* read output mapping via SoE */ /* command word (uint16) is always mapped but not in list */ /* read attribute of each IDN in mapping list */ /* length : 0 = 8bit, 1 = 16bit .... */ /* read input mapping via SoE */ /* status word (uint16) is always mapped but not in list */ /* read attribute of each IDN in mapping list */ /* length : 0 = 8bit, 1 = 16bit .... */ /* found some I/O bits ? */