Multithreaded-software/external/soem/soem/ethercatconfig.c
static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
{
   int i, nSM;
   if ((slave > 1) && (*(context->slavecount) > 0))
   {
      i = 1;
      while(((context->slavelist[i].eep_man != context->slavelist[slave].eep_man) ||
             (context->slavelist[i].eep_id  != context->slavelist[slave].eep_id ) ||
             (context->slavelist[i].eep_rev != context->slavelist[slave].eep_rev)) &&
            (i < slave))
      {
         i++;
      }
      if(i < slave)
      {
         for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
         {
            context->slavelist[slave].SM[nSM].SMlength = context->slavelist[i].SM[nSM].SMlength;
            context->slavelist[slave].SMtype[nSM] = context->slavelist[i].SMtype[nSM];
         }
         *Osize = context->slavelist[i].Obits;
         *Isize = context->slavelist[i].Ibits;
         context->slavelist[slave].Obits = *Osize;
         context->slavelist[slave].Ibits = *Isize;
         EC_PRINT("Copy mapping slave %d from %d.\n", slave, i);
         return 1;
      }
   }
   return 0;
}
/* If slave has SII mapping and same slave ID done before, use previous mapping.
 * This is safe because SII mapping is constant for same slave ID.
 */
If slave has SII mapping and same slave ID done before, use previous mapping.
This is safe because SII mapping is constant for same slave ID.
If slave has SII mapping and same slave ID done before use previous mapping . This is safe because SII mapping is constant for same slave ID .
static int ecx_lookup_mapping(ecx_contextt *context, uint16 slave, int *Osize, int *Isize)
{
   int i, nSM;
   if ((slave > 1) && (*(context->slavecount) > 0))
   {
      i = 1;
      while(((context->slavelist[i].eep_man != context->slavelist[slave].eep_man) ||
             (context->slavelist[i].eep_id  != context->slavelist[slave].eep_id ) ||
             (context->slavelist[i].eep_rev != context->slavelist[slave].eep_rev)) &&
            (i < slave))
      {
         i++;
      }
      if(i < slave)
      {
         for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
         {
            context->slavelist[slave].SM[nSM].SMlength = context->slavelist[i].SM[nSM].SMlength;
            context->slavelist[slave].SMtype[nSM] = context->slavelist[i].SMtype[nSM];
         }
         *Osize = context->slavelist[i].Obits;
         *Isize = context->slavelist[i].Ibits;
         context->slavelist[slave].Obits = *Osize;
         context->slavelist[slave].Ibits = *Isize;
         EC_PRINT("Copy mapping slave %d from %d.\n", slave, i);
         return 1;
      }
   }
   return 0;
}
static int ecx_lookup_mapping ( ecx_contextt * context , uint16 slave , int * Osize , int * Isize ) { int i , nSM ; if ( ( slave > 1 ) && ( * ( context -> slavecount ) > 0 ) ) { i = 1 ; while ( ( ( context -> slavelist [ i ] . eep_man != context -> slavelist [ slave ] . eep_man ) || ( context -> slavelist [ i ] . eep_id != context -> slavelist [ slave ] . eep_id ) || ( context -> slavelist [ i ] . eep_rev != context -> slavelist [ slave ] . eep_rev ) ) && ( i < slave ) ) { i ++ ; } if ( i < slave ) { for ( nSM = 0 ; nSM < EC_MAXSM ; nSM ++ ) { context -> slavelist [ slave ] . SM [ nSM ] . SMlength = context -> slavelist [ i ] . SM [ nSM ] . SMlength ; context -> slavelist [ slave ] . SMtype [ nSM ] = context -> slavelist [ i ] . SMtype [ nSM ] ; } * Osize = context -> slavelist [ i ] . Obits ; * Isize = context -> slavelist [ i ] . Ibits ; context -> slavelist [ slave ] . Obits = * Osize ; context -> slavelist [ slave ] . Ibits = * Isize ; EC_PRINT ( " \n " , slave , i ) ; return 1 ; } } return 0 ; }
If slave has SII mapping and same slave ID done before, use previous mapping.
If slave has SII mapping and same slave ID done before use previous mapping .