tool/CommandSiiWrite.cpp
changeset 1157 04d1c950cf9d
parent 1155 bd4e5b544473
child 1161 d1324ac71232
--- a/tool/CommandSiiWrite.cpp	Mon Jul 28 09:12:21 2008 +0000
+++ b/tool/CommandSiiWrite.cpp	Mon Jul 28 11:29:28 2008 +0000
@@ -30,6 +30,8 @@
         << endl 
         << getBriefDescription() << endl
         << endl
+        << "This command requires a single slave to be selected." << endl
+    	<< endl
         << "The file contents are checked for validity and integrity." << endl
         << "These checks can be overridden with the --force option." << endl
         << endl
@@ -38,9 +40,10 @@
         << "           positive number of words." << endl
         << endl
         << "Command-specific options:" << endl
-        << "  --slave -s <index>  Positive numerical ring position" << endl
-        << "                      (mandatory)." << endl
-        << "  --force -f          Override validity checks." << endl
+        << "  --alias    -a <alias>" << endl
+        << "  --position -p <pos>    Slave selection. See the help of" << endl
+        << "                         the 'slaves' command." << endl
+        << "  --force    -f          Override validity checks." << endl
         << endl
         << numericInfo();
 
@@ -60,13 +63,6 @@
     uint16_t categoryType, categorySize;
     uint8_t crc;
 
-    slaves = selectedSlaves(m);
-
-    if (slaves.size() != 1) {
-        throwSingleSlaveRequired(slaves.size());
-    }
-    data.slave_position = slaves.front().position;
-
     if (args.size() != 1) {
         err << "'" << getName() << "' takes exactly one argument!";
         throwInvalidUsageException(err);
@@ -131,8 +127,14 @@
         }
     }
 
+    m.open(MasterDevice::ReadWrite);
+    slaves = selectedSlaves(m);
+    if (slaves.size() != 1) {
+        throwSingleSlaveRequired(slaves.size());
+    }
+    data.slave_position = slaves.front().position;
+
     // send data to master
-    m.open(MasterDevice::ReadWrite);
     data.offset = 0;
 	m.writeSii(&data);
 }