# HG changeset patch # User Florian Pose # Date 1148653729 0 # Node ID 44a3a5833c49c0d6ecab0dc35b2da9b959382fbb # Parent 5fe7df7f2433bbddb7ebd5061ea119272c32d5e1 Better state-dependent behaviour for EoE-capable slaves. diff -r 5fe7df7f2433 -r 44a3a5833c49 master/ethernet.c --- a/master/ethernet.c Fri May 26 14:26:57 2006 +0000 +++ b/master/ethernet.c Fri May 26 14:28:49 2006 +0000 @@ -250,7 +250,6 @@ eoe->tx_offset += current_size; eoe->tx_fragment_number++; - return 0; } @@ -302,12 +301,15 @@ /** State: RX_START. - Starts a new receiving sequence by queuing a command that checks the - slave's mailbox for a new command. + Starts a new receiving sequence by queueing a command that checks the + slave's mailbox for a new EoE command. */ void ec_eoe_state_rx_start(ec_eoe_t *eoe /**< EoE handler */) { + if (!eoe->slave->online || !eoe->slave->master->device->link_state) + return; + ec_slave_mbox_prepare_check(eoe->slave); ec_master_queue_command(eoe->slave->master, &eoe->slave->mbox_command); eoe->state = ec_eoe_state_rx_check; @@ -493,6 +495,9 @@ unsigned int wakeup; #endif + if (!eoe->slave->online || !eoe->slave->master->device->link_state) + return; + spin_lock_bh(&eoe->tx_queue_lock); if (!eoe->tx_queued_frames || list_empty(&eoe->tx_queue)) { @@ -601,6 +606,7 @@ EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name); else { eoe->slave->requested_state = EC_SLAVE_STATE_OP; + eoe->slave->state_error = 0; } return 0; } @@ -623,6 +629,7 @@ EC_WARN("device %s is not coupled to any EoE slave!\n", dev->name); else { eoe->slave->requested_state = EC_SLAVE_STATE_INIT; + eoe->slave->state_error = 0; } return 0; } diff -r 5fe7df7f2433 -r 44a3a5833c49 master/master.c --- a/master/master.c Fri May 26 14:26:57 2006 +0000 +++ b/master/master.c Fri May 26 14:28:49 2006 +0000 @@ -853,14 +853,20 @@ coupled++; EC_INFO("Coupling device %s to slave %i.\n", eoe->dev->name, slave->ring_position); - if (eoe->opened) + if (eoe->opened) { slave->requested_state = EC_SLAVE_STATE_OP; + } + else { + slave->requested_state = EC_SLAVE_STATE_INIT; + } + slave->state_error = 0; break; } if (!found) { EC_WARN("No EoE handler for slave %i!\n", slave->ring_position); slave->requested_state = EC_SLAVE_STATE_INIT; + slave->state_error = 0; } } @@ -898,6 +904,7 @@ list_for_each_entry(eoe, &master->eoe_handlers, list) { if (eoe->slave) { eoe->slave->requested_state = EC_SLAVE_STATE_INIT; + eoe->slave->state_error = 0; eoe->slave = NULL; } } @@ -906,7 +913,6 @@ } /*****************************************************************************/ - /** Does the Ethernet-over-EtherCAT processing. */