Multithreaded-software/external/soem/soem/ethercatconfig.c
static int ecx_lookup_prev_sii(ecx_contextt *context, uint16 slave)
{
   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)
      {
         context->slavelist[slave].CoEdetails = context->slavelist[i].CoEdetails;
         context->slavelist[slave].FoEdetails = context->slavelist[i].FoEdetails;
         context->slavelist[slave].EoEdetails = context->slavelist[i].EoEdetails;
         context->slavelist[slave].SoEdetails = context->slavelist[i].SoEdetails;
         if(context->slavelist[i].blockLRW > 0)
         {
            context->slavelist[slave].blockLRW = 1;
            context->slavelist[0].blockLRW++;
         }
         context->slavelist[slave].Ebuscurrent = context->slavelist[i].Ebuscurrent;
         context->slavelist[0].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
         memcpy(context->slavelist[slave].name, context->slavelist[i].name, EC_MAXNAME + 1);
         for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
         {
            context->slavelist[slave].SM[nSM].StartAddr = context->slavelist[i].SM[nSM].StartAddr;
            context->slavelist[slave].SM[nSM].SMlength  = context->slavelist[i].SM[nSM].SMlength;
            context->slavelist[slave].SM[nSM].SMflags   = context->slavelist[i].SM[nSM].SMflags;
         }
         context->slavelist[slave].FMMU0func = context->slavelist[i].FMMU0func;
         context->slavelist[slave].FMMU1func = context->slavelist[i].FMMU1func;
         context->slavelist[slave].FMMU2func = context->slavelist[i].FMMU2func;
         context->slavelist[slave].FMMU3func = context->slavelist[i].FMMU3func;
         EC_PRINT("Copy SII slave %d from %d.\n", slave, i);
         return 1;
      }
   }
   return 0;
}
/* If slave has SII and same slave ID done before, use previous data.
 * This is safe because SII is constant for same slave ID.
 */
If slave has SII and same slave ID done before, use previous data.
This is safe because SII is constant for same slave ID.
If slave has SII and same slave ID done before use previous data . This is safe because SII is constant for same slave ID .
static int ecx_lookup_prev_sii(ecx_contextt *context, uint16 slave)
{
   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)
      {
         context->slavelist[slave].CoEdetails = context->slavelist[i].CoEdetails;
         context->slavelist[slave].FoEdetails = context->slavelist[i].FoEdetails;
         context->slavelist[slave].EoEdetails = context->slavelist[i].EoEdetails;
         context->slavelist[slave].SoEdetails = context->slavelist[i].SoEdetails;
         if(context->slavelist[i].blockLRW > 0)
         {
            context->slavelist[slave].blockLRW = 1;
            context->slavelist[0].blockLRW++;
         }
         context->slavelist[slave].Ebuscurrent = context->slavelist[i].Ebuscurrent;
         context->slavelist[0].Ebuscurrent += context->slavelist[slave].Ebuscurrent;
         memcpy(context->slavelist[slave].name, context->slavelist[i].name, EC_MAXNAME + 1);
         for( nSM=0 ; nSM < EC_MAXSM ; nSM++ )
         {
            context->slavelist[slave].SM[nSM].StartAddr = context->slavelist[i].SM[nSM].StartAddr;
            context->slavelist[slave].SM[nSM].SMlength  = context->slavelist[i].SM[nSM].SMlength;
            context->slavelist[slave].SM[nSM].SMflags   = context->slavelist[i].SM[nSM].SMflags;
         }
         context->slavelist[slave].FMMU0func = context->slavelist[i].FMMU0func;
         context->slavelist[slave].FMMU1func = context->slavelist[i].FMMU1func;
         context->slavelist[slave].FMMU2func = context->slavelist[i].FMMU2func;
         context->slavelist[slave].FMMU3func = context->slavelist[i].FMMU3func;
         EC_PRINT("Copy SII slave %d from %d.\n", slave, i);
         return 1;
      }
   }
   return 0;
}
static int ecx_lookup_prev_sii ( ecx_contextt * context , uint16 slave ) { 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 ) { context -> slavelist [ slave ] . CoEdetails = context -> slavelist [ i ] . CoEdetails ; context -> slavelist [ slave ] . FoEdetails = context -> slavelist [ i ] . FoEdetails ; context -> slavelist [ slave ] . EoEdetails = context -> slavelist [ i ] . EoEdetails ; context -> slavelist [ slave ] . SoEdetails = context -> slavelist [ i ] . SoEdetails ; if ( context -> slavelist [ i ] . blockLRW > 0 ) { context -> slavelist [ slave ] . blockLRW = 1 ; context -> slavelist [ 0 ] . blockLRW ++ ; } context -> slavelist [ slave ] . Ebuscurrent = context -> slavelist [ i ] . Ebuscurrent ; context -> slavelist [ 0 ] . Ebuscurrent += context -> slavelist [ slave ] . Ebuscurrent ; memcpy ( context -> slavelist [ slave ] . name , context -> slavelist [ i ] . name , EC_MAXNAME + 1 ) ; for ( nSM = 0 ; nSM < EC_MAXSM ; nSM ++ ) { context -> slavelist [ slave ] . SM [ nSM ] . StartAddr = context -> slavelist [ i ] . SM [ nSM ] . StartAddr ; context -> slavelist [ slave ] . SM [ nSM ] . SMlength = context -> slavelist [ i ] . SM [ nSM ] . SMlength ; context -> slavelist [ slave ] . SM [ nSM ] . SMflags = context -> slavelist [ i ] . SM [ nSM ] . SMflags ; } context -> slavelist [ slave ] . FMMU0func = context -> slavelist [ i ] . FMMU0func ; context -> slavelist [ slave ] . FMMU1func = context -> slavelist [ i ] . FMMU1func ; context -> slavelist [ slave ] . FMMU2func = context -> slavelist [ i ] . FMMU2func ; context -> slavelist [ slave ] . FMMU3func = context -> slavelist [ i ] . FMMU3func ; EC_PRINT ( " \n " , slave , i ) ; return 1 ; } } return 0 ; }
If slave has SII and same slave ID done before, use previous data.
If slave has SII and same slave ID done before use previous data .