Configure PDO sync managers even if no configuration has been applied.
authorFlorian Pose <fp@igh-essen.com>
Thu, 09 Jul 2009 12:54:49 +0000
changeset 1491 40529f2f60bd
parent 1490 7da4e7486bbe
child 1492 c44308ec691b
Configure PDO sync managers even if no configuration has been applied.
documentation/graphs/fsm_slave_conf.dot
master/fsm_slave_config.c
--- a/documentation/graphs/fsm_slave_conf.dot	Mon Jul 06 09:06:31 2009 +0000
+++ b/documentation/graphs/fsm_slave_conf.dot	Thu Jul 09 12:54:49 2009 +0000
@@ -55,10 +55,10 @@
 
     boot_preop [style="bold"]
     boot_preop -> end [label="PREOP\nor BOOT\nrequested"]
-    boot_preop -> enter_safeop [label="No slave\nconfig attached"]
     boot_preop -> enter_sdo_conf [weight=10]
 
     enter_sdo_conf [shape=point, label=""]
+    enter_sdo_conf -> enter_pdo_sync [label="No config\nattached"]
     enter_sdo_conf -> enter_pdo_conf [label="No SDOs\nconfigured"]
     enter_sdo_conf -> sdo_conf [weight=10]
 
@@ -81,7 +81,7 @@
     pdo_sync -> enter_fmmu [weight=10]
 
     enter_fmmu [shape=point,label=""]
-    enter_fmmu -> reconfigure
+    enter_fmmu -> enter_safeop [label="No config\nattached"]
     enter_fmmu -> enter_dc_cycle [label="No FMMUs\nconfigured"]
     enter_fmmu -> fmmu [weight=10]
 
--- a/master/fsm_slave_config.c	Mon Jul 06 09:06:31 2009 +0000
+++ b/master/fsm_slave_config.c	Thu Jul 09 12:54:49 2009 +0000
@@ -735,27 +735,25 @@
         return;
     }
 
+    ec_fsm_slave_config_enter_sdo_conf(fsm);
+}
+
+/*****************************************************************************/
+
+/** Check for SDO configurations to be applied.
+ */
+void ec_fsm_slave_config_enter_sdo_conf(
+        ec_fsm_slave_config_t *fsm /**< slave state machine */
+        )
+{
+    ec_slave_t *slave = fsm->slave;
+
     if (!slave->config) {
-        EC_WARN("Slave %u is not configured.\n", slave->ring_position);
-        ec_fsm_slave_config_enter_safeop(fsm);
-        return;
-    }
-
-    ec_fsm_slave_config_enter_sdo_conf(fsm);
-}
-
-/*****************************************************************************/
-
-/** Check for SDO configurations to be applied.
- */
-void ec_fsm_slave_config_enter_sdo_conf(
-        ec_fsm_slave_config_t *fsm /**< slave state machine */
-        )
-{
-    ec_slave_t *slave = fsm->slave;
+        ec_fsm_slave_config_enter_pdo_sync(fsm);
+        return;
+    }
 
     // No CoE configuration to be applied?
-	// FIXME check for config
     if (list_empty(&slave->config->sdo_configs)) { // skip SDO configuration
         ec_fsm_slave_config_enter_pdo_conf(fsm);
         return;
@@ -862,8 +860,8 @@
     unsigned int i, offset, num_pdo_syncs;
     uint8_t sync_index;
     const ec_sync_t *sync;
-    const ec_sync_config_t *sync_config;
     uint16_t size;
+    ec_direction_t dir;
 
     if (slave->sii.mailbox_protocols) {
         offset = 2; // slave has mailboxes
@@ -888,10 +886,19 @@
     for (i = 0; i < num_pdo_syncs; i++) {
         sync_index = i + offset;
         sync = &slave->sii.syncs[sync_index];
-        sync_config = &slave->config->sync_configs[sync_index];
-        size = ec_pdo_list_total_size(&sync_config->pdos);
-        ec_sync_page(sync, sync_index, size, sync_config->dir,
-                datagram->data + EC_SYNC_PAGE_SIZE * i);
+
+        if (slave->config) {
+            const ec_sync_config_t *sync_config;
+            sync_config = &slave->config->sync_configs[sync_index];
+            size = ec_pdo_list_total_size(&sync_config->pdos);
+            dir = sync_config->dir;
+        } else {
+            size = sync->default_length;
+            dir = EC_DIR_INVALID;
+        }
+
+        ec_sync_page(sync, sync_index, size, dir, datagram->data +
+                EC_SYNC_PAGE_SIZE * i);
     }
 
     fsm->retries = EC_FSM_RETRIES;
@@ -946,8 +953,8 @@
     const ec_fmmu_config_t *fmmu;
     const ec_sync_t *sync;
 
-    if (!slave->config) { // config removed in the meantime
-        ec_fsm_slave_config_reconfigure(fsm);
+    if (!slave->config) {
+        ec_fsm_slave_config_enter_safeop(fsm);
         return;
     }