master/sync.c
changeset 912 6630f4dbcfd2
parent 879 9b395c5646ab
child 943 1d9e2663e087
equal deleted inserted replaced
911:17c3b3aafbb9 912:6630f4dbcfd2
   142         const ec_sync_t *sync /**< EtherCAT sync manager. */
   142         const ec_sync_t *sync /**< EtherCAT sync manager. */
   143         )
   143         )
   144 {
   144 {
   145     int index = sync->index;
   145     int index = sync->index;
   146 
   146 
   147     if (sync->slave && sync->slave->sii.mailbox_protocols) {
   147     if (sync->slave->sii.sync_count != 1) {
   148         index -= 2;
   148         if (sync->slave && sync->slave->sii.mailbox_protocols) {
   149     }
   149             index -= 2;
       
   150         }
   150 
   151 
   151     if (index < 0 || index > 1) {
   152         if (index < 0 || index > 1) {
   152         EC_WARN("ec_sync_get_direction(): invalid sync manager index.\n");
   153             EC_WARN("ec_sync_get_direction(): invalid sync manager index.\n");
   153         return EC_DIR_OUTPUT;
   154             return EC_DIR_OUTPUT;
       
   155         }
       
   156     } else { // sync_count == 1
       
   157         if (!list_empty(&sync->pdos.list)) {
       
   158             const ec_pdo_t *pdo =
       
   159                 list_entry(sync->pdos.list.next, ec_pdo_t, list);
       
   160             return pdo->dir;
       
   161         }
       
   162         
   154     }
   163     }
   155 
   164 
   156     return (ec_direction_t) index;
   165     return (ec_direction_t) index;
   157 }
   166 }
   158 
   167