Link Status ausgelesen.
authorFlorian Pose <fp@igh-essen.com>
Fri, 31 Mar 2006 09:27:34 +0000
changeset 142 e933f1adb550
parent 141 5f76a36cd9b4
child 143 f6c4f38b699f
Link Status ausgelesen.
master/slave.c
master/slave.h
rt/msr_module.c
--- a/master/slave.c	Wed Mar 29 15:45:25 2006 +0000
+++ b/master/slave.c	Fri Mar 31 09:27:34 2006 +0000
@@ -35,12 +35,19 @@
                    ec_master_t *master /**< EtherCAT-Master */
                    )
 {
+    unsigned int i;
+
     slave->master = master;
     slave->base_type = 0;
     slave->base_revision = 0;
     slave->base_build = 0;
     slave->base_fmmu_count = 0;
     slave->base_sync_count = 0;
+    for (i = 0; i < 2; i++) {
+        slave->dl_status_link[i] = 0;
+        slave->dl_status_loop[i] = 0;
+        slave->dl_status_comm[i] = 0;
+    }
     slave->ring_position = 0;
     slave->station_address = 0;
     slave->sii_alias = 0;
@@ -135,11 +142,13 @@
 int ec_slave_fetch(ec_slave_t *slave /**< EtherCAT-Slave */)
 {
     ec_command_t command;
+    unsigned int i;
+    uint16_t dl_status;
 
     // Read base data
     ec_command_init_nprd(&command, slave->station_address, 0x0000, 6);
     if (unlikely(ec_master_simple_io(slave->master, &command))) {
-        EC_ERR("Reading base datafrom slave %i failed!\n",
+        EC_ERR("Reading base data from slave %i failed!\n",
                slave->ring_position);
         return -1;
     }
@@ -153,6 +162,22 @@
     if (slave->base_fmmu_count > EC_MAX_FMMUS)
         slave->base_fmmu_count = EC_MAX_FMMUS;
 
+    // Read DL status
+    ec_command_init_nprd(&command, slave->station_address, 0x0110, 2);
+    if (unlikely(ec_master_simple_io(slave->master, &command))) {
+        EC_ERR("Reading DL status from slave %i failed!\n",
+               slave->ring_position);
+        return -1;
+    }
+
+    dl_status = EC_READ_U16(command.data);
+    for (i = 0; i < 2; i++) {
+        slave->dl_status_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0;
+        slave->dl_status_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0;
+        slave->dl_status_comm[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0;
+    }
+
+    // Read EEPROM data
     if (ec_slave_sii_read16(slave, 0x0004, &slave->sii_alias))
         return -1;
     if (ec_slave_sii_read32(slave, 0x0008, &slave->sii_vendor_id))
@@ -869,7 +894,7 @@
     ec_eeprom_pdo_entry_t *pdo_entry;
     ec_sdo_t *sdo;
     ec_sdo_entry_t *sdo_entry;
-    int first;
+    int first, i;
 
     EC_INFO("x-- EtherCAT slave information ---------------\n");
 
@@ -887,6 +912,14 @@
 
     if (verbosity > 0) // Etwas geschwätziger
     {
+        EC_INFO("| Data link status:\n");
+        for (i = 0; i < 2; i++) {
+            EC_INFO("|   Port %i: link %s, loop %s, %s\n", i,
+                    slave->dl_status_link[i] ? "up" : "down",
+                    slave->dl_status_loop[i] ? "closed" : "open",
+                    slave->dl_status_comm[i] ? "comm. establ." : "no comm.");
+        }
+
         EC_INFO("| Base information:\n");
         EC_INFO("|   Type %u, Revision %i, Build %i\n",
                 slave->base_type, slave->base_revision, slave->base_build);
--- a/master/slave.h	Wed Mar 29 15:45:25 2006 +0000
+++ b/master/slave.h	Fri Mar 31 09:27:34 2006 +0000
@@ -197,6 +197,11 @@
     uint16_t base_fmmu_count; /**< Anzahl unterstützter FMMUs */
     uint16_t base_sync_count; /**< Anzahl unterstützter Sync-Manager */
 
+    // Data link status
+    uint8_t dl_status_link[2]; /**< Verbindung erkannt */
+    uint8_t dl_status_loop[2]; /**< Loop geschlossen */
+    uint8_t dl_status_comm[2]; /**< Kommunikation */
+
     // Slave information interface
     uint16_t sii_alias; /**< Configured station alias */
     uint32_t sii_vendor_id; /**< Identifikationsnummer des Herstellers */
--- a/rt/msr_module.c	Wed Mar 29 15:45:25 2006 +0000
+++ b/rt/msr_module.c	Fri Mar 31 09:27:34 2006 +0000
@@ -38,7 +38,7 @@
 #include "../include/ecrt.h"
 
 #define ASYNC
-#define BLOCK1
+//#define BLOCK1
 
 // Defines/Makros
 #define HZREDUCTION (MSR_ABTASTFREQUENZ / HZ)
@@ -224,7 +224,7 @@
     }
     ecrt_master_print(master, 2);
 #else
-    ecrt_master_print(master, 0);
+    ecrt_master_print(master, 1);
 #endif