tool/cmd_debug.cpp
changeset 1126 b09fd81894cb
child 1130 bb1c11adb2db
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool/cmd_debug.cpp	Tue Jul 22 14:17:20 2008 +0000
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ *
+ * $Id$
+ *
+ ****************************************************************************/
+
+#include <sstream>
+#include <iomanip>
+using namespace std;
+
+#include "globals.h"
+
+/*****************************************************************************/
+
+const char *help_debug =
+    "[OPTIONS]\n"
+    "\n"
+    "\n"
+    "Command-specific options:\n";
+
+/****************************************************************************/
+
+void command_debug(void)
+{
+    stringstream str;
+    int debugLevel;
+    
+    if (commandArgs.size() != 1) {
+        stringstream err;
+        err << "'debug' takes exactly one argument!";
+        throw MasterDeviceException(err.str());
+    }
+
+    str << commandArgs[0];
+    str >> resetiosflags(ios::basefield) // guess base from prefix
+        >> debugLevel;
+
+    if (str.fail()) {
+        stringstream err;
+        err << "Invalid debug level '" << commandArgs[0] << "'!";
+        throw MasterDeviceException(err.str());
+    }
+
+    masterDev.open(MasterDevice::ReadWrite);
+    masterDev.setDebug(debugLevel);
+}
+
+/*****************************************************************************/