--- a/TODO Wed Jun 02 22:46:48 2010 +0200
+++ b/TODO Wed Jun 02 22:54:08 2010 +0200
@@ -42,7 +42,6 @@
* Output SoE IDN configurations in 'ethercat config'.
* Fix casting away constness during expected WC calculation.
* Read AL status code on spontaneous state change.
-* Fix clearing domains etc. when not activated and releasing.
* Only output watchdog config if not default.
Future issues:
--- a/master/master.c Wed Jun 02 22:46:48 2010 +0200
+++ b/master/master.c Wed Jun 02 22:54:08 2010 +0200
@@ -439,6 +439,20 @@
/*****************************************************************************/
+/** Clear the configuration applied by the application.
+ */
+void ec_master_clear_config(
+ ec_master_t *master /**< EtherCAT master. */
+ )
+{
+ down(&master->master_sem);
+ ec_master_clear_domains(master);
+ ec_master_clear_slave_configs(master);
+ up(&master->master_sem);
+}
+
+/*****************************************************************************/
+
/** Internal sending callback.
*/
void ec_master_internal_send_cb(
@@ -653,15 +667,17 @@
ec_master_t *master /**< EtherCAT master */
)
{
- if (master->active)
- ecrt_master_deactivate(master);
+ if (master->active) {
+ ecrt_master_deactivate(master); // also clears config
+ } else {
+ ec_master_clear_config(master);
+ }
EC_MASTER_DBG(master, 1, "OPERATION -> IDLE.\n");
master->phase = EC_IDLE;
}
-
/*****************************************************************************/
/** Injects external datagrams that fit into the datagram queue.
@@ -1989,8 +2005,7 @@
int eoe_was_running;
#endif
- EC_MASTER_DBG(master, 1, "ecrt_master_deactivate(master = 0x%p)\n",
- master);
+ EC_MASTER_DBG(master, 1, "%s(master = 0x%p)\n", __func__, master);
if (!master->active) {
EC_MASTER_WARN(master, "%s: Master not active.\n", __func__);
@@ -2007,10 +2022,7 @@
master->receive_cb = ec_master_internal_receive_cb;
master->cb_data = master;
- down(&master->master_sem);
- ec_master_clear_domains(master);
- ec_master_clear_slave_configs(master);
- up(&master->master_sem);
+ ec_master_clear_config(master);
for (slave = master->slaves;
slave < master->slaves + master->slave_count;
--- a/master/master.h Wed Jun 02 22:46:48 2010 +0200
+++ b/master/master.h Wed Jun 02 22:54:08 2010 +0200
@@ -170,11 +170,12 @@
unsigned int injection_seq_rt; /**< Datagram injection sequence number
for the realtime side. */
-
ec_slave_t *slaves; /**< Array of slaves on the bus. */
unsigned int slave_count; /**< Number of slaves on the bus. */
+ /* Configuration applied by the application. */
struct list_head configs; /**< List of slave configurations. */
+ struct list_head domains; /**< List of domains. */
u64 app_time; /**< Time of the last ecrt_master_sync() call. */
u64 app_start_time; /**< Application start time. */
@@ -213,7 +214,6 @@
struct list_head external_datagram_queue; /**< External Datagram queue. */
unsigned int send_interval; /**< Interval between calls to ecrt_master_send */
size_t max_queue_size; /**< Maximum size of datagram queue */
- struct list_head domains; /**< List of domains. */
unsigned int debug_level; /**< Master debug level. */
ec_stats_t stats; /**< Cyclic statistics. */
@@ -242,7 +242,6 @@
struct list_head reg_requests; /**< Register requests. */
wait_queue_head_t reg_queue; /**< Wait queue for register requests. */
-
};
/*****************************************************************************/