More slave fields in SysFS; DL link status for 4 ports
authorFlorian Pose <fp@igh-essen.com>
Tue, 11 Apr 2006 10:05:21 +0000
changeset 183 8ae1e011e96c
parent 182 8c0bc99229a9
child 184 2fc86cec12df
More slave fields in SysFS; DL link status for 4 ports
master/slave.c
master/slave.h
--- a/master/slave.c	Tue Apr 11 09:12:00 2006 +0000
+++ b/master/slave.c	Tue Apr 11 10:05:21 2006 +0000
@@ -29,13 +29,31 @@
 /*****************************************************************************/
 
 static struct attribute attr_ring_position = {
-    .name = "ring_position",
-    .owner = THIS_MODULE,
-    .mode = S_IRUGO
+    .name = "ring_position", .owner = THIS_MODULE, .mode = S_IRUGO
+};
+
+static struct attribute attr_station_address = {
+    .name = "station_address", .owner = THIS_MODULE, .mode = S_IRUGO
+};
+
+static struct attribute attr_vendor_name = {
+    .name = "vendor_name", .owner = THIS_MODULE, .mode = S_IRUGO
+};
+
+static struct attribute attr_product_name = {
+    .name = "product_name", .owner = THIS_MODULE, .mode = S_IRUGO
+};
+
+static struct attribute attr_product_desc = {
+    .name = "product_description", .owner = THIS_MODULE, .mode = S_IRUGO
 };
 
 static struct attribute *def_attrs[] = {
     &attr_ring_position,
+    &attr_station_address,
+    &attr_vendor_name,
+    &attr_product_name,
+    &attr_product_desc,
     NULL,
 };
 
@@ -114,10 +132,10 @@
     INIT_LIST_HEAD(&slave->eeprom_pdos);
     INIT_LIST_HEAD(&slave->sdo_dictionary);
 
-    for (i = 0; i < 2; i++) {
-        slave->dl_status_link[i] = 0;
-        slave->dl_status_loop[i] = 0;
-        slave->dl_status_comm[i] = 0;
+    for (i = 0; i < 4; i++) {
+        slave->dl_link[i] = 0;
+        slave->dl_loop[i] = 0;
+        slave->dl_signal[i] = 0;
     }
 
     return 0;
@@ -230,10 +248,10 @@
     }
 
     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;
+    for (i = 0; i < 4; i++) {
+        slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0;
+        slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0;
+        slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0;
     }
 
     // Read EEPROM data
@@ -1004,11 +1022,11 @@
     EC_INFO("  Station address: 0x%04X\n", slave->station_address);
 
     EC_INFO("  Data link status:\n");
-    for (i = 0; i < 2; i++) {
-        EC_INFO("    Port %i: link %s, loop %s, comm %s\n", i,
-                slave->dl_status_link[i] ? "up" : "down",
-                slave->dl_status_loop[i] ? "closed" : "open",
-                slave->dl_status_comm[i] ? "up" : "down");
+    for (i = 0; i < 4; i++) {
+        EC_INFO("    Port %i: link %s, loop %s, %s\n", i,
+                slave->dl_link[i] ? "up" : "down",
+                slave->dl_loop[i] ? "closed" : "open",
+                slave->dl_signal[i] ? "signal detected" : "no signal");
     }
 
     EC_INFO("  Base information:\n");
@@ -1205,6 +1223,21 @@
     if (attr == &attr_ring_position) {
         return sprintf(buffer, "%i\n", slave->ring_position);
     }
+    else if (attr == &attr_station_address) {
+        return sprintf(buffer, "%i\n", slave->station_address);
+    }
+    else if (attr == &attr_vendor_name) {
+        if (slave->type)
+            return sprintf(buffer, "%s\n", slave->type->vendor_name);
+    }
+    else if (attr == &attr_product_name) {
+        if (slave->type)
+            return sprintf(buffer, "%s\n", slave->type->product_name);
+    }
+    else if (attr == &attr_product_desc) {
+        if (slave->type)
+            return sprintf(buffer, "%s\n", slave->type->description);
+    }
 
     return 0;
 }
--- a/master/slave.h	Tue Apr 11 09:12:00 2006 +0000
+++ b/master/slave.h	Tue Apr 11 10:05:21 2006 +0000
@@ -207,9 +207,9 @@
     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 */
+    uint8_t dl_link[4]; /**< Verbindung erkannt */
+    uint8_t dl_loop[4]; /**< Loop geschlossen */
+    uint8_t dl_signal[4]; /**< Signal an RX-Seite erkannt */
 
     // Slave information interface
     uint16_t sii_alias; /**< Configured station alias */