Internal SDO requests now synchronized with external requests.
authorKnud Baastrup <kba@deif.com>
Tue, 14 Apr 2015 13:12:24 -0400
changeset 2629 a2701af27fde
parent 2628 d123727b805b
child 2630 a380cce7d6f0
Internal SDO requests now synchronized with external requests.
Internal SDO requests are managed by master FSM and can conflict with
external requests managed by slave FSM. The internal SDO requests
includes SDO requests created by an application and external request are
typical created by EtherCAT Tool for SDO upload/download or a directory
fetch initiated with ethercat sdos command. The conflict will cause a
FPWR from an external request to be overwritten by a FPWR from an
internal SDO request (or oppersite) in the same "train" of datagrams.
master/fsm_master.c
master/fsm_slave.c
--- a/master/fsm_master.c	Tue Apr 14 13:10:55 2015 -0400
+++ b/master/fsm_master.c	Tue Apr 14 13:12:24 2015 -0400
@@ -493,6 +493,11 @@
             continue;
         }
 
+        if (!ec_fsm_slave_is_ready(&slave->fsm)) {
+            EC_SLAVE_DBG(slave, 1, "Busy - processing external request!\n");
+            continue;
+        }
+
         list_for_each_entry(req, &slave->config->sdo_requests, list) {
             if (req->state == EC_INT_REQUEST_QUEUED) {
 
--- a/master/fsm_slave.c	Tue Apr 14 13:10:55 2015 -0400
+++ b/master/fsm_slave.c	Tue Apr 14 13:12:24 2015 -0400
@@ -201,6 +201,18 @@
         ec_datagram_t *datagram /**< Datagram to use. */
         )
 {
+    ec_slave_t *slave = fsm->slave;
+    ec_sdo_request_t *req;
+
+    if (slave->config) {
+        list_for_each_entry(req, &slave->config->sdo_requests, list) {
+            if (req->state == EC_INT_REQUEST_QUEUED || req->state == EC_INT_REQUEST_BUSY) {
+                EC_SLAVE_DBG(slave, 1, "Busy - processing internal SDO request!\n");
+                return;
+            }
+        }
+    }
+
     // Check for pending external SDO requests
     if (ec_fsm_slave_action_process_sdo(fsm, datagram)) {
         return;