merge -r974:979 trunk -> branches/stable-1.3 (lsec fix). stable-1.3 version-1.3.2
authorFlorian Pose <fp@igh-essen.com>
Fri, 05 Oct 2007 08:16:43 +0000
branchstable-1.3
changeset 1751 b6cfd85db58e
parent 1750 c916f48c95dd
child 1752 b01562a45602
merge -r974:979 trunk -> branches/stable-1.3 (lsec fix).
master/slave.c
script/lsec
--- a/master/slave.c	Thu Oct 04 08:43:47 2007 +0000
+++ b/master/slave.c	Fri Oct 05 08:16:43 2007 +0000
@@ -713,7 +713,8 @@
 
     off += sprintf(buffer + off, "Data link status:\n");
     for (i = 0; i < 4; i++) {
-        off += sprintf(buffer + off, "  Port %i (", i);
+        off += sprintf(buffer + off, "  Port %u: Phy %u (",
+                i, slave->sii_physical_layer[i]);
         switch (slave->sii_physical_layer[i]) {
             case 0x00:
                 off += sprintf(buffer + off, "EBUS");
@@ -725,10 +726,9 @@
                 off += sprintf(buffer + off, "100BASE-FX");
                 break;
             default:
-                off += sprintf(buffer + off, "unknown (%i)",
-                               slave->sii_physical_layer[i]);
-        }
-        off += sprintf(buffer + off, ") Link %s, Loop %s, %s\n",
+                off += sprintf(buffer + off, "unknown");
+        }
+        off += sprintf(buffer + off, "), Link %s, Loop %s, %s\n",
                        slave->dl_link[i] ? "up" : "down",
                        slave->dl_loop[i] ? "closed" : "open",
                        slave->dl_signal[i] ? "Signal detected" : "No signal");
@@ -739,13 +739,14 @@
         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",
+    off += sprintf(buffer + off, "Identity:\n");
+    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",
+    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",
+    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",
+    off += sprintf(buffer + off, "  Serial number: 0x%08X (%u)\n\n",
                    slave->sii_serial_number, slave->sii_serial_number);
 
     if (slave->sii_mailbox_protocols) {
--- a/script/lsec	Thu Oct 04 08:43:47 2007 +0000
+++ b/script/lsec	Fri Oct 05 08:16:43 2007 +0000
@@ -63,7 +63,6 @@
     my $slave_info_file;
     my @slaves;
     my $slave;
-    my $abs;
     my $line;
     my $ring_col_width;
     my $alias_col_width;
@@ -71,6 +70,7 @@
     my $width;
     my $last_alias;
     my $alias_index;
+    my $category;
 
     $master_dir = "/sys/ethercat/master" . $master_index;
 
@@ -87,21 +87,35 @@
         open INFO, $slave_info_file or die
             "ERROR: Failed to open $slave_info_file.";
 
+        $category = "";
         while ($line = <INFO>) {
-            if ($line =~ /^Name: (.*)$/) {
-                $slave->{'name'} = $1;
+            # remember category
+            if ($line =~ /^([^\s][^:]*):$/) {
+                $category = $1;
+            } elsif ($line =~ /^\s*$/) {
+                $category = "";
             }
-            elsif ($line =~ /^Ring position: (\d+)$/) {
-                $slave->{'ring_position'} = $1;
-            }
-            elsif ($line =~ /Configured station alias: .* \((\d+)\)$/) {
-                $slave->{'alias'} = $1;
-            }
-            elsif ($line =~ /^State: (.+) /) {
-                $slave->{'state'} = $1;
-            }
-            elsif ($line =~ /^Current consumption: (-?\d+) mA$/) {
-                $slave->{'current'} = $1;
+
+            if ($category eq "") {
+                if ($line =~ /^Ring position: (\d+)$/) {
+                    $slave->{'ring_position'} = $1;
+                } elsif ($line =~ /^State: (.+) /) {
+                    $slave->{'state'} = $1;
+                } elsif ($line =~ /^Configured station alias: .* \((\d+)\)$/) {
+                    $slave->{'alias'} = $1;
+                } elsif ($line =~ /^Current consumption: (-?\d+) mA$/) {
+                    $slave->{'current'} = $1;
+                }
+            } elsif ($category eq "Identity") {
+                if ($line =~ /Vendor ID: .* \((\d+)\)$/) {
+                    $slave->{'vendor'} = $1;
+                } elsif ($line =~ /Product code: .* \((\d+)\)$/) {
+                    $slave->{'product'} = $1;
+                }
+            } elsif ($category eq "General") {
+                if ($line =~ /Name: (.*)$/) {
+                    $slave->{'name'} = $1;
+                }
             }
         }
 
@@ -131,6 +145,14 @@
         $alias_index++;
     }
 
+    # replace empty name with vendor id and product code
+    for $slave (@slaves) {
+        unless (defined $slave->{'name'}) {
+            $slave->{'name'} = sprintf("0x%08X:0x%08X", $slave->{'vendor'},
+                    $slave->{'product'});
+        }
+    }
+
     if (defined $opt{'c'}) { # display power consumtion
         $fmt = sprintf " %%%is  %%%is  %%6i  %%6i  %%s\n",
             $ring_col_width, $alias_col_width;
@@ -182,7 +204,7 @@
     print "        -m <IDX>    Query master <IDX>.\n";
     print "        -c          Display current [mA] ";
     print "(3: consumption, 4: remaining).\n";
-    print "        -n          Display no coupler lines.\n";
+    print "        -n          Do not display lines before aliased slaves.\n";
     print "        -h          Show this help.\n";
     exit 0;
 }