tool/CommandAlias.cpp
changeset 1826 ec6223c3b7ec
parent 1363 11c0b2caa253
child 1869 14f634f5b613
--- a/tool/CommandAlias.cpp	Tue Feb 23 17:40:46 2010 +0100
+++ b/tool/CommandAlias.cpp	Wed Feb 24 16:27:11 2010 +0100
@@ -34,6 +34,7 @@
 
 #include "CommandAlias.h"
 #include "sii_crc.h"
+#include "MasterDevice.h"
 
 /*****************************************************************************/
 
@@ -75,7 +76,7 @@
 
 /** Writes the Secondary slave address (alias) to the slave's SII.
  */
-void CommandAlias::execute(MasterDevice &m, const StringVector &args)
+void CommandAlias::execute(const StringVector &args)
 {
     uint16_t alias;
     stringstream err, strAlias;
@@ -98,6 +99,11 @@
     }
     alias = number;
 
+    if (getMasterIndices().size() != 1) {
+        err << getName() << " requires to select a single master!";
+        throwInvalidUsageException(err);
+    }
+    MasterDevice m(getMasterIndices().front());
     m.open(MasterDevice::ReadWrite);
     slaves = selectedSlaves(m);