merge -r972:974 trunk -> branches/stable-1.3 (mapping source, new slave info file) stable-1.3
authorFlorian Pose <fp@igh-essen.com>
Thu, 04 Oct 2007 08:40:41 +0000
branchstable-1.3
changeset 1749 696dd9f22777
parent 1748 a8740ac42365
child 1750 c916f48c95dd
merge -r972:974 trunk -> branches/stable-1.3 (mapping source, new slave info file)
master/fsm_coe_map.c
master/slave.c
master/sync.c
master/sync.h
--- a/master/fsm_coe_map.c	Wed Oct 03 09:10:38 2007 +0000
+++ b/master/fsm_coe_map.c	Thu Oct 04 08:40:41 2007 +0000
@@ -276,6 +276,7 @@
         list_for_each_entry(pdo, &fsm->pdos, list) {
             ec_sync_add_pdo(sync, pdo);
         }
+        sync->mapping_source = EC_SYNC_MAPPING_COE;
         ec_fsm_coe_map_clear_pdos(fsm);
 
         // next sync manager
--- a/master/slave.c	Wed Oct 03 09:10:38 2007 +0000
+++ b/master/slave.c	Thu Oct 04 08:40:41 2007 +0000
@@ -576,6 +576,7 @@
 
         // if sync manager index is positive, the PDO is mapped by default
         if (pdo->sync_index >= 0) {
+            ec_sync_t *sync;
             ec_pdo_t *mapped_pdo;
 
             if (pdo->sync_index >= slave->sii_sync_count) {
@@ -583,6 +584,7 @@
                         pdo->sync_index, pdo->index, slave->ring_position);
                 return -1;
             }
+            sync = &slave->sii_syncs[pdo->sync_index];
 
             if (!(mapped_pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
                 EC_ERR("Failed to allocate PDO memory.\n");
@@ -595,8 +597,8 @@
                 return -1;
             }
 
-            list_add_tail(&mapped_pdo->list,
-                    &slave->sii_syncs[pdo->sync_index].pdos);
+            list_add_tail(&mapped_pdo->list, &sync->pdos);
+            sync->mapping_source = EC_SYNC_MAPPING_SII;
         }
     }
 
@@ -698,27 +700,16 @@
     ec_sdo_data_t *sdodata;
     char str[20];
 
-    off += sprintf(buffer + off, "\nName: ");
-
-    if (slave->sii_name)
-        off += sprintf(buffer + off, "%s", slave->sii_name);
-
-    off += sprintf(buffer + off, "\nVendor ID: 0x%08X\n",
-                   slave->sii_vendor_id);
-    off += sprintf(buffer + off, "Product code: 0x%08X\n\n",
-                   slave->sii_product_code);
-
+    off += sprintf(buffer + off, "Ring position: %i\n",
+                   slave->ring_position);
     off += sprintf(buffer + off, "State: ");
     off += ec_state_string(slave->current_state, buffer + off);
     off += sprintf(buffer + off, " (");
     off += ec_state_string(slave->requested_state, buffer + off);
-    off += sprintf(buffer + off, ")\nFlags: %s, %s\n",
+    off += sprintf(buffer + off, ")\n");
+    off += sprintf(buffer + off, "Flags: %s, %s\n\n",
             slave->online_state == EC_SLAVE_ONLINE ? "online" : "OFFLINE",
             slave->error_flag ? "ERROR" : "ok");
-    off += sprintf(buffer + off, "Ring position: %i\n",
-                   slave->ring_position);
-    off += sprintf(buffer + off, "Current consumption: %i mA\n\n",
-                   slave->sii_current_on_ebus);
 
     off += sprintf(buffer + off, "Data link status:\n");
     for (i = 0; i < 4; i++) {
@@ -742,15 +733,26 @@
                        slave->dl_loop[i] ? "closed" : "open",
                        slave->dl_signal[i] ? "Signal detected" : "No signal");
     }
+    off += sprintf(buffer + off, "\n");
+
+    if (slave->sii_alias)
+        off += sprintf(buffer + off, "Configured station alias:"
+                       " 0x%04X (%i)\n\n", slave->sii_alias, slave->sii_alias);
+
+    off += sprintf(buffer + off, "Vendor ID: 0x%08X (%u)\n",
+                   slave->sii_vendor_id, slave->sii_vendor_id);
+    off += sprintf(buffer + off, "Product code: 0x%08X (%u)\n",
+                   slave->sii_product_code, slave->sii_product_code);
+    off += sprintf(buffer + off, "Revision number: 0x%08X (%u)\n",
+                   slave->sii_revision_number, slave->sii_revision_number);
+    off += sprintf(buffer + off, "Serial number: 0x%08X (%u)\n\n",
+                   slave->sii_serial_number, slave->sii_serial_number);
 
     if (slave->sii_mailbox_protocols) {
-        off += sprintf(buffer + off, "\nMailboxes:\n");
-        off += sprintf(buffer + off, "  RX mailbox: 0x%04X/%i,"
-                       " TX mailbox: 0x%04X/%i\n",
-                       slave->sii_rx_mailbox_offset,
-                       slave->sii_rx_mailbox_size,
-                       slave->sii_tx_mailbox_offset,
-                       slave->sii_tx_mailbox_size);
+        off += sprintf(buffer + off, "Mailboxes:\n");
+        off += sprintf(buffer + off, "  RX: 0x%04X/%u, TX: 0x%04X/%u\n",
+                slave->sii_rx_mailbox_offset, slave->sii_rx_mailbox_size,
+                slave->sii_tx_mailbox_offset, slave->sii_tx_mailbox_size);
         off += sprintf(buffer + off, "  Supported protocols: ");
 
         first = 1;
@@ -782,90 +784,105 @@
             if (!first) off += sprintf(buffer + off, ", ");
             off += sprintf(buffer + off, "VoE");
         }
+        off += sprintf(buffer + off, "\n\n");
+    }
+
+    off += sprintf(buffer + off, "Current consumption: %i mA\n\n",
+            slave->sii_current_on_ebus);
+
+    if (slave->sii_group || slave->sii_image || slave->sii_order
+            || slave->sii_name) {
+        off += sprintf(buffer + off, "General:\n");
+
+        if (slave->sii_group)
+            off += sprintf(buffer + off, "  Group: %s\n", slave->sii_group);
+        if (slave->sii_image)
+            off += sprintf(buffer + off, "  Image: %s\n", slave->sii_image);
+        if (slave->sii_order)
+            off += sprintf(buffer + off, "  Order number: %s\n",
+                    slave->sii_order);
+        if (slave->sii_name)
+            off += sprintf(buffer + off, "  Name: %s\n", slave->sii_name);
         off += sprintf(buffer + off, "\n");
     }
 
-    if (slave->sii_alias || slave->sii_group
-        || slave->sii_image || slave->sii_order)
-        off += sprintf(buffer + off, "\nSII data:\n");
-
-    if (slave->sii_alias)
-        off += sprintf(buffer + off, "  Configured station alias:"
-                       " 0x%04X (%i)\n", slave->sii_alias, slave->sii_alias);
-    if (slave->sii_group)
-        off += sprintf(buffer + off, "  Group: %s\n", slave->sii_group);
-    if (slave->sii_image)
-        off += sprintf(buffer + off, "  Image: %s\n", slave->sii_image);
-    if (slave->sii_order)
-        off += sprintf(buffer + off, "  Order number: %s\n", slave->sii_order);
-
-    if (slave->sii_sync_count)
-        off += sprintf(buffer + off, "\nSync managers / PDO mapping:\n");
-
-    for (i = 0; i < slave->sii_sync_count; i++) {
-        sync = &slave->sii_syncs[i];
-        off += sprintf(buffer + off,
-                "  SM%u: addr 0x%04X, size %i, control 0x%02X, %s\n",
-                sync->index, sync->physical_start_address,
-                ec_sync_size(sync), sync->control_register,
-                sync->enable ? "enable" : "disable");
-
-        if (list_empty(&sync->pdos))
-            off += sprintf(buffer + off, "    No PDOs mapped.\n");
-
-        list_for_each_entry(pdo, &sync->pdos, list) {
-            off += sprintf(buffer + off, "    %s 0x%04X \"%s\"\n",
+    if (slave->sii_sync_count) {
+        off += sprintf(buffer + off, "Sync managers / PDO mapping:\n");
+
+        for (i = 0; i < slave->sii_sync_count; i++) {
+            sync = &slave->sii_syncs[i];
+            off += sprintf(buffer + off,
+                    "  SM%u: addr 0x%04X, size %i, control 0x%02X, %s\n",
+                    sync->index, sync->physical_start_address,
+                    ec_sync_size(sync), sync->control_register,
+                    sync->enable ? "enable" : "disable");
+
+            if (list_empty(&sync->pdos)) {
+                off += sprintf(buffer + off, "    No PDOs mapped.\n");
+            } else if (sync->mapping_source != EC_SYNC_MAPPING_NONE) {
+                off += sprintf(buffer + off,
+                        "    PDO mapping information from %s.\n",
+                        sync->mapping_source == EC_SYNC_MAPPING_SII
+                        ? "SII" : "CoE");
+            }
+
+            list_for_each_entry(pdo, &sync->pdos, list) {
+                off += sprintf(buffer + off, "    %s 0x%04X \"%s\"\n",
+                        pdo->type == EC_RX_PDO ? "RxPdo" : "TxPdo",
+                        pdo->index, pdo->name ? pdo->name : "???");
+
+                list_for_each_entry(pdo_entry, &pdo->entries, list) {
+                    off += sprintf(buffer + off,
+                            "      0x%04X:%X \"%s\", %i bit\n",
+                            pdo_entry->index, pdo_entry->subindex,
+                            pdo_entry->name ? pdo_entry->name : "???",
+                            pdo_entry->bit_length);
+                }
+            }
+        }
+        off += sprintf(buffer + off, "\n");
+    }
+
+    // type-cast to avoid warnings on some compilers
+    if (!list_empty((struct list_head *) &slave->sii_pdos)) {
+        off += sprintf(buffer + off, "Available PDOs from SII:\n");
+
+        list_for_each_entry(pdo, &slave->sii_pdos, list) {
+            off += sprintf(buffer + off, "  %s 0x%04X \"%s\"",
                     pdo->type == EC_RX_PDO ? "RxPdo" : "TxPdo",
                     pdo->index, pdo->name ? pdo->name : "???");
+            if (pdo->sync_index >= 0)
+                off += sprintf(buffer + off, ", default mapping: SM%u.\n",
+                        pdo->sync_index);
+            else
+                off += sprintf(buffer + off, ", no default mapping.\n");
 
             list_for_each_entry(pdo_entry, &pdo->entries, list) {
-                off += sprintf(buffer + off,
-                        "      0x%04X:%X \"%s\", %i bit\n",
+                off += sprintf(buffer + off, "    0x%04X:%X \"%s\", %i bit\n",
                         pdo_entry->index, pdo_entry->subindex,
                         pdo_entry->name ? pdo_entry->name : "???",
                         pdo_entry->bit_length);
             }
         }
+        off += sprintf(buffer + off, "\n");
     }
 
     // type-cast to avoid warnings on some compilers
-    if (!list_empty((struct list_head *) &slave->sii_pdos))
-        off += sprintf(buffer + off, "\nAvailable PDOs:\n");
-
-    list_for_each_entry(pdo, &slave->sii_pdos, list) {
-        off += sprintf(buffer + off, "  %s 0x%04X \"%s\"",
-                       pdo->type == EC_RX_PDO ? "RxPdo" : "TxPdo",
-                       pdo->index, pdo->name ? pdo->name : "???");
-        if (pdo->sync_index >= 0)
-            off += sprintf(buffer + off, ", default mapping: SM%u.\n",
-                    pdo->sync_index);
-        else
-            off += sprintf(buffer + off, ", no default mapping.\n");
-
-        list_for_each_entry(pdo_entry, &pdo->entries, list) {
-            off += sprintf(buffer + off, "    0x%04X:%X \"%s\", %i bit\n",
-                           pdo_entry->index, pdo_entry->subindex,
-                           pdo_entry->name ? pdo_entry->name : "???",
-                           pdo_entry->bit_length);
-        }
-    }
-
-    // type-cast to avoid warnings on some compilers
-    if (!list_empty((struct list_head *) &slave->sdo_confs))
-        off += sprintf(buffer + off, "\nSDO configurations:\n");
-
-    list_for_each_entry(sdodata, &slave->sdo_confs, list) {
-        switch (sdodata->size) {
-            case 1: sprintf(str, "%i", EC_READ_U8(sdodata->data)); break;
-            case 2: sprintf(str, "%i", EC_READ_U16(sdodata->data)); break;
-            case 4: sprintf(str, "%i", EC_READ_U32(sdodata->data)); break;
-            default: sprintf(str, "(invalid size)"); break;
-        }
-        off += sprintf(buffer + off, "  0x%04X:%-3i -> %s\n",
-                       sdodata->index, sdodata->subindex, str);
-    }
-
-    off += sprintf(buffer + off, "\n");
+    if (!list_empty((struct list_head *) &slave->sdo_confs)) {
+        off += sprintf(buffer + off, "SDO configurations:\n");
+
+        list_for_each_entry(sdodata, &slave->sdo_confs, list) {
+            switch (sdodata->size) {
+                case 1: sprintf(str, "%i", EC_READ_U8(sdodata->data)); break;
+                case 2: sprintf(str, "%i", EC_READ_U16(sdodata->data)); break;
+                case 4: sprintf(str, "%i", EC_READ_U32(sdodata->data)); break;
+                default: sprintf(str, "(invalid size)"); break;
+            }
+            off += sprintf(buffer + off, "  0x%04X:%-3i -> %s\n",
+                    sdodata->index, sdodata->subindex, str);
+        }
+        off += sprintf(buffer + off, "\n");
+    }
 
     return off;
 }
--- a/master/sync.c	Wed Oct 03 09:10:38 2007 +0000
+++ b/master/sync.c	Thu Oct 04 08:40:41 2007 +0000
@@ -62,6 +62,7 @@
     sync->est_length = 0;
     INIT_LIST_HEAD(&sync->pdos);
     sync->alt_mapping = 0;
+    sync->mapping_source = EC_SYNC_MAPPING_NONE;
 }
 
 /*****************************************************************************/
--- a/master/sync.h	Wed Oct 03 09:10:38 2007 +0000
+++ b/master/sync.h	Thu Oct 04 08:40:41 2007 +0000
@@ -54,6 +54,19 @@
 /*****************************************************************************/
 
 /**
+ * EtherCAT sync manager PDO mapping information source.
+ */
+
+typedef enum {
+    EC_SYNC_MAPPING_NONE, /**< No PDO mapping information */
+    EC_SYNC_MAPPING_SII, /**< PDO mapping information from SII */
+    EC_SYNC_MAPPING_COE /**< PDO mapping information from CoE dictionary */
+}
+ec_sync_mapping_source_t;
+
+/*****************************************************************************/
+
+/**
  * Sync manager.
  */
 
@@ -69,6 +82,7 @@
     uint16_t est_length; /**< used to calculate the length via PDO ranges */
     struct list_head pdos; /**< list of mapped PDOs */
     unsigned int alt_mapping; /**< alternative mapping configured */
+    ec_sync_mapping_source_t mapping_source; /**< pdo mapping source */
 }
 ec_sync_t;