Introduced effective_alias variable to separate reg12 alias from SII alias.
authorFlorian Pose <fp@igh-essen.com>
Fri, 23 Apr 2010 16:42:27 +0200
changeset 1909 ea3eb4c74c1b
parent 1908 666ad3a50f9f
child 1910 9a741a3d01bb
Introduced effective_alias variable to separate reg12 alias from SII alias.
master/cdev.c
master/ethernet.c
master/fsm_master.c
master/fsm_slave_scan.c
master/master.c
master/slave.c
master/slave.h
--- a/master/cdev.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/cdev.c	Fri Apr 23 16:42:27 2010 +0200
@@ -285,7 +285,7 @@
     data.product_code = slave->sii.product_code;
     data.revision_number = slave->sii.revision_number;
     data.serial_number = slave->sii.serial_number;
-    data.alias = slave->sii.alias;
+    data.alias = slave->effective_alias;
     data.boot_rx_mailbox_offset = slave->sii.boot_rx_mailbox_offset;
     data.boot_rx_mailbox_size = slave->sii.boot_rx_mailbox_size;
     data.boot_tx_mailbox_offset = slave->sii.boot_tx_mailbox_offset;
--- a/master/ethernet.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/ethernet.c	Fri Apr 23 16:42:27 2010 +0200
@@ -136,9 +136,9 @@
 
     /* device name eoe<MASTER>[as]<SLAVE>, because networking scripts don't
      * like hyphens etc. in interface names. */
-    if (slave->sii.alias) {
+    if (slave->effective_alias) {
         snprintf(name, EC_DATAGRAM_NAME_SIZE,
-                "eoe%ua%u", slave->master->index, slave->sii.alias);
+                "eoe%ua%u", slave->master->index, slave->effective_alias);
     } else {
         snprintf(name, EC_DATAGRAM_NAME_SIZE,
                 "eoe%us%u", slave->master->index, slave->ring_position);
--- a/master/fsm_master.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/fsm_master.c	Fri Apr 23 16:42:27 2010 +0200
@@ -877,6 +877,7 @@
         // alias was written
         slave->sii.alias = EC_READ_U16(request->words + 4);
         // TODO: read alias from register 0x0012
+        slave->effective_alias = slave->sii.alias;
     }
     // TODO: Evaluate other SII contents!
 
--- a/master/fsm_slave_scan.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/fsm_slave_scan.c	Fri Apr 23 16:42:27 2010 +0200
@@ -609,6 +609,7 @@
 
     slave->sii.alias =
         EC_READ_U16(slave->sii_words + 0x0004);
+    slave->effective_alias = slave->sii.alias;
     slave->sii.vendor_id =
         EC_READ_U32(slave->sii_words + 0x0008);
     slave->sii.product_code =
@@ -738,9 +739,9 @@
     ec_datagram_t *datagram = fsm->datagram;
     ec_slave_t *slave = fsm->slave;
 
-    // read alias from register 0x0012
+    // read alias from register
     if (slave->master->debug_level)
-         EC_DBG("Reading alias from register 0x0012 of slave %u.\n",
+         EC_DBG("Reading alias from register of slave %u.\n",
                  slave->ring_position);
     ec_datagram_fprd(datagram, slave->station_address, 0x0012, 2);
     ec_datagram_zero(datagram);
@@ -775,10 +776,10 @@
         EC_WARN("Failed to read reg alias of slave %u.\n",
         fsm->slave->ring_position);
     } else {
-        slave->sii.alias = EC_READ_U16(datagram->data);
+        slave->effective_alias = EC_READ_U16(datagram->data);
         if (slave->master->debug_level)
-            EC_DBG("Alias of slave %u is %u.\n",
-        slave->ring_position,slave->sii.alias);
+            EC_DBG("Read alias %u from register of slave %u.\n",
+                    slave->effective_alias, slave->ring_position);
     }
     if (slave->sii.mailbox_protocols & EC_MBOX_COE) {
         ec_fsm_slave_scan_enter_preop(fsm);
--- a/master/master.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/master.c	Fri Apr 23 16:42:27 2010 +0200
@@ -1526,7 +1526,7 @@
         if (alias) { \
             for (; slave < master->slaves + master->slave_count; \
                     slave++) { \
-                if (slave->sii.alias == alias) \
+                if (slave->effective_alias == alias) \
                 break; \
             } \
             if (slave == master->slaves + master->slave_count) \
@@ -2262,7 +2262,7 @@
     slave_info->product_code = slave->sii.product_code;
     slave_info->revision_number = slave->sii.revision_number;
     slave_info->serial_number = slave->sii.serial_number;
-    slave_info->alias = slave->sii.alias;
+    slave_info->alias = slave->effective_alias;
     slave_info->current_on_ebus = slave->sii.current_on_ebus;
     slave_info->al_state = slave->current_state;
     slave_info->error_flag = slave->error_flag;
--- a/master/slave.c	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/slave.c	Fri Apr 23 16:42:27 2010 +0200
@@ -72,6 +72,7 @@
     slave->master = master;
     slave->ring_position = ring_position;
     slave->station_address = station_address;
+    slave->effective_alias = 0x0000;
 
     slave->config = NULL;
     slave->requested_state = EC_SLAVE_STATE_PREOP;
--- a/master/slave.h	Tue Apr 20 11:21:43 2010 +0200
+++ b/master/slave.h	Fri Apr 23 16:42:27 2010 +0200
@@ -116,6 +116,7 @@
     // addresses
     uint16_t ring_position; /**< Ring position. */
     uint16_t station_address; /**< Configured station address. */
+    uint16_t effective_alias; /**< Effective alias address. */
 
     ec_slave_port_t ports[EC_MAX_PORTS]; /**< Ports. */