From ff75554c58084bda9504063066c2234629c874cc Mon Sep 17 00:00:00 2001 From: Knud Baastrup Date: Tue, 14 Apr 2015 13:12:24 -0400 Subject: [PATCH] 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 | 5 +++++ master/fsm_slave.c | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/master/fsm_master.c b/master/fsm_master.c index 2988ecd2..e6bf1362 100644 --- a/master/fsm_master.c +++ b/master/fsm_master.c @@ -493,6 +493,11 @@ int ec_fsm_master_action_process_sdo( 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) { diff --git a/master/fsm_slave.c b/master/fsm_slave.c index 67315cf2..fc21574f 100644 --- a/master/fsm_slave.c +++ b/master/fsm_slave.c @@ -201,6 +201,18 @@ void ec_fsm_slave_state_ready( 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;