diff --git a/master/ethernet.c b/master/ethernet.c index ae87f4173a73092b8672be85684f653d0e25c9ad..61ffd2d54d18f7da55c06f87459c3d9d62c8807d 100644 --- a/master/ethernet.c +++ b/master/ethernet.c @@ -262,6 +262,18 @@ void ec_eoe_run(ec_eoe_t *eoe /**< EoE object */) /*****************************************************************************/ +/** + Returns the state of the device. + \return 1 if the device is "up", 0 if it is "down" +*/ + +unsigned int ec_eoe_active(const ec_eoe_t *eoe /**< EoE object */) +{ + return eoe->opened; +} + +/*****************************************************************************/ + /** Prints EoE object information. */ diff --git a/master/ethernet.h b/master/ethernet.h index 9521954f991b90a8b77e730f482f8b08e5d6c740..cbc341a007515ff1e905fcd6ce3707f77f35937b 100644 --- a/master/ethernet.h +++ b/master/ethernet.h @@ -66,7 +66,7 @@ struct ec_eoe void (*state)(ec_eoe_t *); /**< state function for the state machine */ struct net_device *dev; /**< net_device for virtual ethernet device */ struct net_device_stats stats; /**< device statistics */ - uint8_t opened; /**< net_device is opened */ + unsigned int opened; /**< net_device is opened */ struct sk_buff *rx_skb; /**< current rx socket buffer */ off_t rx_skb_offset; /**< current write pointer in the socket buffer */ size_t rx_skb_size; /**< size of the allocated socket buffer memory */ @@ -86,6 +86,7 @@ struct ec_eoe int ec_eoe_init(ec_eoe_t *, ec_slave_t *); void ec_eoe_clear(ec_eoe_t *); void ec_eoe_run(ec_eoe_t *); +unsigned int ec_eoe_active(const ec_eoe_t *); void ec_eoe_print(const ec_eoe_t *); /*****************************************************************************/ diff --git a/master/master.c b/master/master.c index c8dd9c8c9684cb11faae2fad6eae60bb6702c040..d7dd72aa09ccf7d5c79120871353bc2ffdffa9ae 100644 --- a/master/master.c +++ b/master/master.c @@ -874,9 +874,14 @@ void ec_master_run_eoe(void *data /**< master pointer */) { ec_master_t *master = (ec_master_t *) data; ec_eoe_t *eoe; + unsigned int active = 0; + + list_for_each_entry(eoe, &master->eoe_slaves, list) { + if (ec_eoe_active(eoe)) active++; + } // request_cb must return 0, if the lock has been aquired! - if (!master->request_cb(master->cb_data)) + if (active && !master->request_cb(master->cb_data)) { ecrt_master_async_receive(master); list_for_each_entry(eoe, &master->eoe_slaves, list) {