Output (fixed-size) hex value before decimal value.
authorFlorian Pose <fp@igh-essen.com>
Thu, 09 Apr 2009 10:18:27 +0000
changeset 1393 979a7b26036d
parent 1392 8fcc1d0987c1
child 1394 e77728ddf0f9
Output (fixed-size) hex value before decimal value.
tool/CommandRegRead.cpp
tool/CommandUpload.cpp
--- a/tool/CommandRegRead.cpp	Thu Apr 09 09:17:41 2009 +0000
+++ b/tool/CommandRegRead.cpp	Thu Apr 09 10:18:27 2009 +0000
@@ -167,29 +167,29 @@
         if (dataType)
             cout << endl;
     } else if (dataType->name == "int8") {
-        int sval = *(int8_t *) data.data;
-        cout << sval << " 0x" << hex << setw(2) << sval << endl;
+        int val = (int) *data.data;
+        cout << "0x" << hex << setw(2) << val << " " << dec << val << endl;
     } else if (dataType->name == "int16") {
-        int sval = le16_to_cpup(data.data);
-        cout << sval << " 0x" << hex << setw(4) << sval << endl;
+        int16_t val = le16_to_cpup(data.data);
+        cout << "0x" << hex << setw(4) << val << " " << dec << val << endl;
     } else if (dataType->name == "int32") {
-        int sval = le32_to_cpup(data.data);
-        cout << sval << " 0x" << hex << setw(8) << sval << endl;
+        int32_t val = le32_to_cpup(data.data);
+        cout << "0x" << hex << setw(8) << val << " " << dec << val << endl;
     } else if (dataType->name == "int64") {
-        long long int sval = le64_to_cpup(data.data);
-        cout << sval << " 0x" << hex << setw(16) << sval << endl;
+        int64_t val = le64_to_cpup(data.data);
+        cout << "0x" << hex << setw(16) << val << " " << dec << val << endl;
     } else if (dataType->name == "uint8") {
-        unsigned int uval = (unsigned int) *(uint8_t *) data.data;
-        cout << uval << " 0x" << hex << setw(2) << uval << endl;
+        unsigned int val = (unsigned int) *data.data;
+        cout << "0x" << hex << setw(2) << val << " " << dec << val << endl;
     } else if (dataType->name == "uint16") {
-        unsigned int uval = le16_to_cpup(data.data);
-        cout << uval << " 0x" << hex << setw(4) << uval << endl;
+        uint16_t val = le16_to_cpup(data.data);
+        cout << "0x" << hex << setw(4) << val << " " << dec << val << endl;
     } else if (dataType->name == "uint32") {
-        unsigned int uval = le32_to_cpup(data.data);
-        cout << uval << " 0x" << hex << setw(8) << uval << endl;
+        uint32_t val = le32_to_cpup(data.data);
+        cout << "0x" << hex << setw(8) << val << " " << dec << val << endl;
     } else if (dataType->name == "uint64") {
-        long long unsigned int uval = le64_to_cpup(data.data);
-        cout << uval << " 0x" << hex << setw(16) << uval << endl;
+        uint64_t val = le64_to_cpup(data.data);
+        cout << "0x" << hex << setw(16) << val << " " << dec << val << endl;
     } else { // raw
         uint8_t *d = data.data;
         unsigned int size = data.length;
--- a/tool/CommandUpload.cpp	Thu Apr 09 09:17:41 2009 +0000
+++ b/tool/CommandUpload.cpp	Thu Apr 09 10:18:27 2009 +0000
@@ -85,10 +85,9 @@
 {
     SlaveList slaves;
     stringstream err, strIndex, strSubIndex;
-    int sval;
     ec_ioctl_slave_sdo_upload_t data;
+    const DataType *dataType = NULL;
     unsigned int uval;
-    const DataType *dataType = NULL;
 
     if (args.size() != 2) {
         err << "'" << getName() << "' takes two arguments!";
@@ -178,28 +177,46 @@
     cout << setfill('0');
     switch (dataType->coeCode) {
         case 0x0002: // int8
-            sval = *(int8_t *) data.target;
-            cout << sval << " 0x" << hex << setw(2) << sval << endl;
+            {
+                int val = (int) *data.target;
+                cout << "0x" << hex << setw(2) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0003: // int16
-            sval = le16_to_cpup(data.target);
-            cout << sval << " 0x" << hex << setw(4) << sval << endl;
+            {
+                int16_t val = le16_to_cpup(data.target);
+                cout << "0x" << hex << setw(4) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0004: // int32
-            sval = le32_to_cpup(data.target);
-            cout << sval << " 0x" << hex << setw(8) << sval << endl;
+            {
+                int32_t val = le32_to_cpup(data.target);
+                cout << "0x" << hex << setw(8) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0005: // uint8
-            uval = (unsigned int) *(uint8_t *) data.target;
-            cout << uval << " 0x" << hex << setw(2) << uval << endl;
+            {
+                unsigned int val = (unsigned int) *data.target;
+                cout << "0x" << hex << setw(2) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0006: // uint16
-            uval = le16_to_cpup(data.target);
-            cout << uval << " 0x" << hex << setw(4) << uval << endl;
+            {
+                uint16_t val = le16_to_cpup(data.target);
+                cout << "0x" << hex << setw(4) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0007: // uint32
-            uval = le32_to_cpup(data.target);
-            cout << uval << " 0x" << hex << setw(8) << uval << endl;
+            {
+                uint32_t val = le32_to_cpup(data.target);
+                cout << "0x" << hex << setw(8) << val
+                    << " " << dec << val << endl;
+            }
             break;
         case 0x0009: // string
             cout << string((const char *) data.target, data.data_size)