# HG changeset patch # User Martin Troxler # Date 1261128953 -3600 # Node ID 699bd70f7bfe2d9128e49292bdac4464df98a6ff # Parent 2f6683e9181f7c425f1d2d11a36b0fa0fed4ab29 undone changes of revision 1547: Abort SDO/FOE requests when slave is in INIT diff -r 2f6683e9181f -r 699bd70f7bfe master/fsm_slave.c --- a/master/fsm_slave.c Thu Dec 17 10:54:59 2009 +0100 +++ b/master/fsm_slave.c Fri Dec 18 10:35:53 2009 +0100 @@ -62,7 +62,9 @@ fsm->slave = slave; fsm->datagram = datagram; fsm->datagram->data_size = 0; - fsm->state = ec_fsm_slave_state_idle; + if (slave->master->debug_level) + EC_DBG("init fsm for slave %u...\n",slave->ring_position); + fsm->state = ec_fsm_slave_state_idle; // init sub-state-machines ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram); @@ -177,20 +179,26 @@ // search the first external request to be processed list_for_each_entry_safe(request, next, &slave->slave_sdo_requests, list) { + list_del_init(&request->list); // dequeue if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { - EC_WARN("Postponing SDO request, slave %u has ERROR.\n", + EC_WARN("Aborting SDO request, slave %u has ERROR.\n", slave->ring_position); + request->req.state = EC_INT_REQUEST_FAILURE; + wake_up(&slave->sdo_queue); + fsm->sdo_request = NULL; fsm->state = ec_fsm_slave_state_idle; return 0; } if (slave->current_state == EC_SLAVE_STATE_INIT) { - EC_WARN("Postponing SDO request, slave %u is in INIT.\n", - slave->ring_position); + EC_WARN("Aborting SDO request, slave %u is in INIT.\n", + slave->ring_position); + request->req.state = EC_INT_REQUEST_FAILURE; + wake_up(&slave->sdo_queue); + fsm->sdo_request = NULL; fsm->state = ec_fsm_slave_state_idle; return 0; - } - list_del_init(&request->list); // dequeue - request->req.state = EC_INT_REQUEST_BUSY; + } + request->req.state = EC_INT_REQUEST_BUSY; // Found pending SDO request. Execute it! if (master->debug_level) @@ -226,8 +234,11 @@ // search the first request to be processed list_for_each_entry_safe(request, next, &slave->foe_requests, list) { if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { - EC_WARN("Postponing FOE request, slave %u has ERROR.\n", + EC_WARN("Aborting FOE request, slave %u has ERROR.\n", slave->ring_position); + request->req.state = EC_INT_REQUEST_FAILURE; + wake_up(&slave->sdo_queue); + fsm->sdo_request = NULL; fsm->state = ec_fsm_slave_state_idle; return 0; } @@ -271,9 +282,9 @@ EC_DBG("Failed to process SDO request for slave %u.\n", fsm->slave->ring_position); request->state = EC_INT_REQUEST_FAILURE; - wake_up(&slave->sdo_queue); - fsm->sdo_request = NULL; - fsm->state = ec_fsm_slave_state_idle; + wake_up(&slave->foe_queue); + fsm->foe_request = NULL; + fsm->state = ec_fsm_slave_state_idle; return; }