tool/CommandRegWrite.cpp
branchstable-1.5
changeset 2529 c7e1f2616a9d
parent 2443 2c3ccdde3919
--- a/tool/CommandRegWrite.cpp	Thu Feb 14 11:17:33 2013 +0100
+++ b/tool/CommandRegWrite.cpp	Mon May 13 20:21:19 2013 +0200
@@ -68,10 +68,12 @@
         << typeInfo()
         << endl
         << "Command-specific options:" << endl
-        << "  --alias    -a <alias>" << endl
-        << "  --position -p <pos>    Slave selection. See the help of" << endl
-        << "                         the 'slaves' command." << endl
-        << "  --type     -t <type>   Data type (see above)." << endl
+        << "  --alias     -a <alias>" << endl
+        << "  --position  -p <pos>    Slave selection. See the help of"
+        << endl
+        << "                          the 'slaves' command." << endl
+        << "  --type      -t <type>   Data type (see above)." << endl
+        << "  --emergency -e          Send as emergency request." << endl
         << endl
         << numericInfo();
 
@@ -85,7 +87,6 @@
     stringstream strOffset, err;
     ec_ioctl_slave_reg_t io;
     ifstream file;
-    SlaveList slaves;
 
     if (args.size() != 2) {
         err << "'" << getName() << "' takes exactly two arguments!";
@@ -158,12 +159,19 @@
         throw e;
     }
 
-    slaves = selectedSlaves(m);
-    if (slaves.size() != 1) {
-        delete [] io.data;
-        throwSingleSlaveRequired(slaves.size());
-    }
-    io.slave_position = slaves.front().position;
+    if (getEmergency()) {
+        io.slave_position = emergencySlave();
+        io.emergency = true;
+    }
+    else {
+        SlaveList slaves = selectedSlaves(m);
+        if (slaves.size() != 1) {
+            delete [] io.data;
+            throwSingleSlaveRequired(slaves.size());
+        }
+        io.slave_position = slaves.front().position;
+        io.emergency = false;
+    }
 
     // send data to master
     try {