Alias decimal.
authorFlorian Pose <fp@igh-essen.com>
Fri, 27 Jun 2008 09:48:45 +0000
changeset 1068 df1c8e4f0577
parent 1067 54744527d7c6
child 1069 ab0c21d9ab2b
Alias decimal.
TODO
tools/Master.cpp
--- a/TODO	Fri Jun 27 09:37:53 2008 +0000
+++ b/TODO	Fri Jun 27 09:48:45 2008 +0000
@@ -15,8 +15,8 @@
 * Adapt remaining examples.
 * READMEs for examples.
 * Update documentation.
-* Overthink display style of hex numbers.
 * Add -a and -p switches for 'ethercat config' command.
+* Scan Sdo indices with optional '0x'.
 * Race in jiffies frame timeout.
 * FoE
 * Allow master requesting when in ORPHANED phase
--- a/tools/Master.cpp	Fri Jun 27 09:37:53 2008 +0000
+++ b/tools/Master.cpp	Fri Jun 27 09:48:45 2008 +0000
@@ -142,7 +142,7 @@
     }
 
     strAlias << commandArgs[0];
-    strAlias >> hex >> number;
+    strAlias >> number;
     if (strAlias.fail() || number < 0x0000 || number > 0xffff) {
         err << "Invalid alias '" << commandArgs[0] << "'!";
         throw MasterException(err.str());
@@ -153,9 +153,8 @@
         unsigned int numSlaves, i;
 
         if (!force) {
-            err << "This will write the alias addresses of all slaves to 0x"
-                << hex << setfill('0') << setw(4) << alias << "! "
-                << "Please specify --force to proceed.";
+            err << "This will write the alias addresses of all slaves to "
+                << alias << "! Please specify --force to proceed.";
             throw MasterException(err.str());
         }
 
@@ -978,11 +977,11 @@
     for (i = 0; i < master.config_count; i++) {
         getConfig(&config, i);
 
-        cout << "Alias: 0x"
-            << hex << setfill('0') << setw(4) << config.alias << endl
-            << "Position: " << dec << config.position << endl
+        cout << "Alias: "
+            << dec << config.alias << endl
+            << "Position: " << config.position << endl
             << "Vendor Id: 0x"
-            << hex << setw(8) << config.vendor_id << endl
+            << hex << setfill('0') << setw(8) << config.vendor_id << endl
             << "Product code: 0x"
             << hex << setw(8) << config.product_code << endl
             << "Attached: " << (config.attached ? "yes" : "no") << endl
@@ -1306,7 +1305,7 @@
     for (i = 0; i < slave.sdo_count; i++) {
         getSdo(&sdo, slavePosition, i);
 
-        cout << "Sdo "
+        cout << "Sdo 0x"
             << hex << setfill('0') << setw(4) << sdo.sdo_index
             << ", \"" << sdo.name << "\"" << endl;
 
@@ -1316,7 +1315,7 @@
         for (j = 0; j <= sdo.max_subindex; j++) {
             getSdoEntry(&entry, slavePosition, -i, j);
 
-            cout << "  " << hex << setfill('0')
+            cout << "  0x" << hex << setfill('0')
                 << setw(4) << sdo.sdo_index << ":" 
                 << setw(2) << (unsigned int) entry.sdo_entry_subindex
                 << ", ";
@@ -1391,8 +1390,8 @@
             if (strlen(slave.name)) {
                 slaveInfo.name = slave.name;
             } else {
-                str << hex << setfill('0')
-                    << setw(8) << slave.vendor_id << ":"
+                str << "0x" << hex << setfill('0')
+                    << setw(8) << slave.vendor_id << ":0x"
                     << setw(8) << slave.product_code;
                 slaveInfo.name = str.str();
                 str.str("");
@@ -1437,7 +1436,7 @@
     getSlave(&slave, slavePosition);
         
     cout << "Slave " << dec << slavePosition << endl
-        << "Alias: 0x" << hex << setfill('0') << setw(4) << slave.alias << endl
+        << "Alias: " << slave.alias << endl
         << "State: " << slaveState(slave.state) << endl
         << "Flag: " << (slave.error_flag ? 'E' : '+') << endl
         << "Identity:" << endl