Added revision number to slave type checking.
authorFlorian Pose <fp@igh-essen.com>
Mon, 16 Jun 2008 09:30:58 +0000
changeset 1009 6012e1414bec
parent 1008 bfa040859b56
child 1010 6672b86e7b10
Added revision number to slave type checking.
include/ecrt.h
master/domain.c
master/master.c
master/slave_config.c
master/slave_config.h
--- a/include/ecrt.h	Thu Jun 12 13:42:52 2008 +0000
+++ b/include/ecrt.h	Mon Jun 16 09:30:58 2008 +0000
@@ -246,6 +246,7 @@
     uint16_t position; /**< Slave position. */
     uint32_t vendor_id; /**< Slave vendor ID. */
     uint32_t product_code; /**< Slave product code. */
+    uint32_t revision_number; /**< Slave revision number. */
     uint16_t index; /**< Pdo entry index. */
     uint8_t subindex; /**< Pdo entry subindex. */
     unsigned int *offset; /**< Pointer to a variable to store the Pdo entry's
@@ -350,7 +351,8 @@
         uint16_t alias, /**< Slave alias. */
         uint16_t position, /**< Slave position. */
         uint32_t vendor_id, /**< Expected vendor ID. */
-        uint32_t product_code /**< Expected product code. */
+        uint32_t product_code, /**< Expected product code. */
+        uint32_t revision_number /**< Expected revision number. */
         );
 
 /** Finishes the configuration phase and prepares for realtime mode.
--- a/master/domain.c	Thu Jun 12 13:42:52 2008 +0000
+++ b/master/domain.c	Mon Jun 16 09:30:58 2008 +0000
@@ -320,7 +320,8 @@
     
     for (reg = regs; reg->index; reg++) {
         if (!(sc = ecrt_master_slave_config(domain->master, reg->alias,
-                        reg->position, reg->vendor_id, reg->product_code)))
+                        reg->position, reg->vendor_id, reg->product_code,
+                        reg->revision_number)))
             return -1;
 
         if ((ret = ecrt_slave_config_reg_pdo_entry(sc, reg->index,
--- a/master/master.c	Thu Jun 12 13:42:52 2008 +0000
+++ b/master/master.c	Mon Jun 16 09:30:58 2008 +0000
@@ -1287,7 +1287,7 @@
 
 ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master,
         uint16_t alias, uint16_t position, uint32_t vendor_id,
-        uint32_t product_code)
+        uint32_t product_code, uint32_t revision_number)
 {
     ec_slave_config_t *sc;
     unsigned int found = 0;
@@ -1304,18 +1304,21 @@
             EC_INFO("Using existing slave configuration for %u:%u\n",
                     alias, position);
         }
-        if (sc->vendor_id != vendor_id || sc->product_code != product_code) {
+        if (sc->vendor_id != vendor_id
+                || sc->product_code != product_code
+                || sc->revision_number != revision_number) {
             EC_ERR("Slave type mismatch. Slave was configured as"
-                    " 0x%08X/0x%08X before. Now configuring with"
-                    " 0x%08X/0x%08X.\n", sc->vendor_id, sc->product_code,
-                    vendor_id, product_code);
+                    " 0x%08X/0x%08X/0x%08X before. Now configuring with"
+                    " 0x%08X/0x%08X/0x%08X.\n",
+                    sc->vendor_id, sc->product_code, sc->revision_number,
+                    vendor_id, product_code, revision_number);
             return NULL;
         }
     } else {
         if (master->debug_level) {
             EC_INFO("Creating slave configuration for %u:%u,"
-                    " 0x%08X/0x%08X.\n", alias, position, vendor_id,
-                    product_code);
+                    " 0x%08X/0x%08X/0x%08X.\n", alias, position,
+                    vendor_id, product_code, revision_number);
         }
 
         if (!(sc = (ec_slave_config_t *) kmalloc(sizeof(ec_slave_config_t),
@@ -1325,7 +1328,7 @@
         }
 
         ec_slave_config_init(sc, master,
-                alias, position, vendor_id, product_code);
+                alias, position, vendor_id, product_code, revision_number);
 
         // try to find the addressed slave
         ec_slave_config_attach(sc);
--- a/master/slave_config.c	Thu Jun 12 13:42:52 2008 +0000
+++ b/master/slave_config.c	Mon Jun 16 09:30:58 2008 +0000
@@ -58,7 +58,8 @@
         uint16_t alias, /**< Slave alias. */
         uint16_t position, /**< Slave position. */
         uint32_t vendor_id, /**< Expected vendor ID. */
-        uint32_t product_code /**< Expected product code. */
+        uint32_t product_code, /**< Expected product code. */
+        uint32_t revision_number /**< Expected revision number. */
         )
 {
     ec_direction_t dir;
@@ -68,6 +69,7 @@
     sc->position = position;
     sc->vendor_id = vendor_id;
     sc->product_code = product_code;
+    sc->revision_number = revision_number;
     sc->slave = NULL;
 
     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++)
@@ -186,12 +188,14 @@
 		return -2;
 	}
 	if (slave->sii.vendor_id != sc->vendor_id
-			|| slave->sii.product_code != sc->product_code) {
-		EC_ERR("Slave %u has an invalid type (0x%08X/0x%08X) for"
-				" configuration %u:%u (0x%08X/0x%08X).\n",
-				slave->ring_position, slave->sii.vendor_id,
-				slave->sii.product_code, sc->alias, sc->position,
-				sc->vendor_id, sc->product_code);
+			|| slave->sii.product_code != sc->product_code
+			|| slave->sii.revision_number != sc->revision_number) {
+		EC_ERR("Slave %u has an invalid type (0x%08X/0x%08X/0x%08X) for"
+				" configuration %u:%u (0x%08X/0x%08X/0x%08X).\n",
+				slave->ring_position,
+                slave->sii.vendor_id, slave->sii.product_code,
+                slave->sii.revision_number, sc->alias, sc->position,
+				sc->vendor_id, sc->product_code, sc->revision_number);
 		return -3;
 	}
 
--- a/master/slave_config.h	Thu Jun 12 13:42:52 2008 +0000
+++ b/master/slave_config.h	Mon Jun 16 09:30:58 2008 +0000
@@ -63,6 +63,7 @@
                          ring position. */
     uint32_t vendor_id; /**< Slave vendor ID. */
     uint32_t product_code; /**< Slave product code. */
+    uint32_t revision_number; /**< Slave revision number. */
 
     ec_slave_t *slave; /**< Slave pointer. This is \a NULL, if the slave is
                          offline. */
@@ -79,7 +80,7 @@
 /*****************************************************************************/
 
 void ec_slave_config_init(ec_slave_config_t *, ec_master_t *, uint16_t,
-        uint16_t, uint32_t, uint32_t);
+        uint16_t, uint32_t, uint32_t, uint32_t);
 void ec_slave_config_clear(ec_slave_config_t *);
 
 int ec_slave_config_attach(ec_slave_config_t *);