From 201385fa20df554a991d5100313a915538581981 Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Mon, 12 Feb 2007 10:39:52 +0000 Subject: [PATCH] Ignore queued datagrams while waiting in ec_master_sync_io(). --- master/master.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/master/master.c b/master/master.c index e68918fe..144241ba 100644 --- a/master/master.c +++ b/master/master.c @@ -1452,22 +1452,25 @@ int ecrt_master_activate(ec_master_t *master /**< EtherCAT master */) void ec_master_sync_io(ec_master_t *master /**< EtherCAT master */) { ec_datagram_t *datagram; - unsigned int datagrams_waiting; + unsigned int datagrams_sent; - // send datagrams + // send all datagrams ecrt_master_send(master); while (1) { // active waiting ecrt_master_receive(master); // receive and dequeue datagrams // count number of datagrams still waiting for response - datagrams_waiting = 0; + datagrams_sent = 0; list_for_each_entry(datagram, &master->datagram_queue, queue) { - datagrams_waiting++; + // there may be another process that queued commands + // in the meantime. + if (datagram->state == EC_DATAGRAM_QUEUED) continue; + datagrams_sent++; } - // if there are no more datagrams waiting, abort loop. - if (!datagrams_waiting) break; + // abort loop if there are no more datagrams marked as sent. + if (!datagrams_sent) break; } } -- GitLab