diff --git a/TODO b/TODO index 5a01e11eeacfac4aa57e0e0730e87b263c2505e7..0999bffb04bf5ae6cab44b946aa5afba47cf78e6 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,6 @@ Version 1.5.0: - Output error after usage. - Implement ranges for slaves and domains. * Fix casting away constness during expected WC calculation. -* Include SoE drive_no in ethercat tool. Future issues: diff --git a/tool/Command.h b/tool/Command.h index 14306c5379e87eddd9cbaf6ccec04b07630b3c5d..02d70f45e365b1d7c6464635f9778b921492e78d 100644 --- a/tool/Command.h +++ b/tool/Command.h @@ -112,7 +112,7 @@ class Command bool matchesSubstr(const string &) const; bool matchesAbbrev(const string &) const; - virtual string helpString() const = 0; + virtual string helpString(const string &) const = 0; typedef vector<string> StringVector; virtual void execute(const StringVector &) = 0; diff --git a/tool/CommandAlias.cpp b/tool/CommandAlias.cpp index 6c53379ef66d5c69f57c119f5f7a7752de4ae0c8..22eef7f5eac59db36a7073957a6c267ee51dfa29 100644 --- a/tool/CommandAlias.cpp +++ b/tool/CommandAlias.cpp @@ -45,11 +45,11 @@ CommandAlias::CommandAlias(): /*****************************************************************************/ -string CommandAlias::helpString() const +string CommandAlias::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <ALIAS>" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS] <ALIAS>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandAlias.h b/tool/CommandAlias.h index 755d344e402c90b9e53004774c9cbf92292b7bbb..49404e926ccee7c4c8b6fb7b4db77778fc197f2d 100644 --- a/tool/CommandAlias.h +++ b/tool/CommandAlias.h @@ -40,7 +40,7 @@ class CommandAlias: public: CommandAlias(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandCStruct.cpp b/tool/CommandCStruct.cpp index bde1a765398363c8f1fa46726ce1f59c2aa6e4bd..2a3f75b19c4f2fe2aa27d74a9111d48bb8661747 100644 --- a/tool/CommandCStruct.cpp +++ b/tool/CommandCStruct.cpp @@ -46,11 +46,11 @@ CommandCStruct::CommandCStruct(): /*****************************************************************************/ -string CommandCStruct::helpString() const +string CommandCStruct::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandCStruct.h b/tool/CommandCStruct.h index 82ab31299f46a14b7fb14b45f069a9c3e13f74df..f277c8f5533238de7c8f35c569e7c09781e1d551 100644 --- a/tool/CommandCStruct.h +++ b/tool/CommandCStruct.h @@ -40,7 +40,7 @@ class CommandCStruct: public: CommandCStruct(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandConfig.cpp b/tool/CommandConfig.cpp index 45e6199958b980758cadd8e21e10358a2fe0cecd..749a3df72b1c69e34e8092d5af1cf878fd17585d 100644 --- a/tool/CommandConfig.cpp +++ b/tool/CommandConfig.cpp @@ -47,11 +47,11 @@ CommandConfig::CommandConfig(): /*****************************************************************************/ -string CommandConfig::helpString() const +string CommandConfig::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandConfig.h b/tool/CommandConfig.h index 75c7612bac4aa619bb89c67f16f5b1027ad9eed1..e012b82df04e23365080043bfa868dea78c9fa91 100644 --- a/tool/CommandConfig.h +++ b/tool/CommandConfig.h @@ -45,7 +45,7 @@ class CommandConfig: public: CommandConfig(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandData.cpp b/tool/CommandData.cpp index d31307c39f1a7c0899625ecf49033f0298093db2..5403963641ea7f8d7d364e0645e23aa3d5343013 100644 --- a/tool/CommandData.cpp +++ b/tool/CommandData.cpp @@ -44,11 +44,11 @@ CommandData::CommandData(): /*****************************************************************************/ -string CommandData::helpString() const +string CommandData::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandData.h b/tool/CommandData.h index b48631b27bf58949e64f1afca8eca1f32385eb11..9f52e94122e883ca333d90866fbdbdf9e8645647 100644 --- a/tool/CommandData.h +++ b/tool/CommandData.h @@ -40,7 +40,7 @@ class CommandData: public: CommandData(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandDebug.cpp b/tool/CommandDebug.cpp index df0548e80751100ed4f896089616c35f0fb36ee7..53d2a2333b996d1b497ba6796a85d5bb72fa086a 100644 --- a/tool/CommandDebug.cpp +++ b/tool/CommandDebug.cpp @@ -45,11 +45,11 @@ CommandDebug::CommandDebug(): /*****************************************************************************/ -string CommandDebug::helpString() const +string CommandDebug::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " <LEVEL>" << endl + str << binaryBaseName << " " << getName() << " <LEVEL>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandDebug.h b/tool/CommandDebug.h index a9e2843889135b871296ec7bfd8886abff561345..df82707f761a33ffa5fafeb0e695f9b8a0f1d6f3 100644 --- a/tool/CommandDebug.h +++ b/tool/CommandDebug.h @@ -40,7 +40,7 @@ class CommandDebug: public: CommandDebug(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandDomains.cpp b/tool/CommandDomains.cpp index 04a26f2d70744eca4f8dea2f326d0fccafe7a836..1ebece6c3721068033ae099269d1a787148db3ac 100644 --- a/tool/CommandDomains.cpp +++ b/tool/CommandDomains.cpp @@ -43,11 +43,11 @@ CommandDomains::CommandDomains(): /*****************************************************************************/ -string CommandDomains::helpString() const +string CommandDomains::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandDomains.h b/tool/CommandDomains.h index 2b4714458d85087c96eeb20f07ff87fa1d41f882..6a5e0ffc4487549435d98b90a1e248e0d70f9081 100644 --- a/tool/CommandDomains.h +++ b/tool/CommandDomains.h @@ -40,7 +40,7 @@ class CommandDomains: public: CommandDomains(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandDownload.cpp b/tool/CommandDownload.cpp index 7253d0b525283326730768cf9ae93f5bd96fc013..a393f85cb8e7a52b561dbffb53f47b83035340b3 100644 --- a/tool/CommandDownload.cpp +++ b/tool/CommandDownload.cpp @@ -43,11 +43,12 @@ CommandDownload::CommandDownload(): /*****************************************************************************/ -string CommandDownload::helpString() const +string CommandDownload::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <INDEX> <SUBINDEX> <VALUE>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandDownload.h b/tool/CommandDownload.h index 4821787708586f5914ec056c8626e7464a68d645..68c1a54a7118ba501a6b1d5fda4482c4d655cc29 100644 --- a/tool/CommandDownload.h +++ b/tool/CommandDownload.h @@ -40,7 +40,7 @@ class CommandDownload: public: CommandDownload(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandEoe.cpp b/tool/CommandEoe.cpp index 67ad0346a905d8efe14298fd1942cf8576ddc817..501ac28cd518f78866bdbe80cbb460b957d39f74 100644 --- a/tool/CommandEoe.cpp +++ b/tool/CommandEoe.cpp @@ -45,11 +45,11 @@ CommandEoe::CommandEoe(): /*****************************************************************************/ -string CommandEoe::helpString() const +string CommandEoe::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << endl + str << binaryBaseName << " " << getName() << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandEoe.h b/tool/CommandEoe.h index 479ddacda6c2991407152285468db8b17dd880c8..d080574d26e7e03176c7115980190912ca9d45dd 100644 --- a/tool/CommandEoe.h +++ b/tool/CommandEoe.h @@ -40,7 +40,7 @@ class CommandEoe: public: CommandEoe(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandFoeRead.cpp b/tool/CommandFoeRead.cpp index 3ab6d91374816dd7c67aa8fb2aff201d8ec41633..7221f40b8cd70d02404b55269953974a96bf2944 100644 --- a/tool/CommandFoeRead.cpp +++ b/tool/CommandFoeRead.cpp @@ -46,11 +46,12 @@ CommandFoeRead::CommandFoeRead(): /*****************************************************************************/ -string CommandFoeRead::helpString() const +string CommandFoeRead::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <SOURCEFILE>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <SOURCEFILE>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandFoeRead.h b/tool/CommandFoeRead.h index 1410a8ad67a75dce8f0f42cd24734ba05f69f363..0db2ad491f9789e6fb612d2fa39a705353673f61 100644 --- a/tool/CommandFoeRead.h +++ b/tool/CommandFoeRead.h @@ -40,7 +40,7 @@ class CommandFoeRead: public: CommandFoeRead(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandFoeWrite.cpp b/tool/CommandFoeWrite.cpp index 58094e1d011e7ef68f7b051ccfaf32596fc8339b..abd6a3fb1e68e3a4da206a029167e9a3cf3f2b86 100644 --- a/tool/CommandFoeWrite.cpp +++ b/tool/CommandFoeWrite.cpp @@ -48,11 +48,12 @@ CommandFoeWrite::CommandFoeWrite(): /*****************************************************************************/ -string CommandFoeWrite::helpString() const +string CommandFoeWrite::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <FILENAME>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <FILENAME>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandFoeWrite.h b/tool/CommandFoeWrite.h index 138eb0a7128cbdf32a59e35aa294a8d75ec30536..3f129e78043d86b3cecca04de05919f04c0e9eda 100644 --- a/tool/CommandFoeWrite.h +++ b/tool/CommandFoeWrite.h @@ -40,7 +40,7 @@ class CommandFoeWrite: public: CommandFoeWrite(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandGraph.cpp b/tool/CommandGraph.cpp index 951c5d27935290d9150ea6bdf0dea59ae60d7dad..a03c7b98b540b10004f97e0e0e963ee4063905d4 100644 --- a/tool/CommandGraph.cpp +++ b/tool/CommandGraph.cpp @@ -43,11 +43,11 @@ CommandGraph::CommandGraph(): /*****************************************************************************/ -string CommandGraph::helpString() const +string CommandGraph::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandGraph.h b/tool/CommandGraph.h index a6e8e5ff9bb43336f2c64b0a0806ada843e481c6..bc931d2a8ecf85f7b6229f2637db3e4f8adbfc13 100644 --- a/tool/CommandGraph.h +++ b/tool/CommandGraph.h @@ -40,7 +40,7 @@ class CommandGraph: public: CommandGraph(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandMaster.cpp b/tool/CommandMaster.cpp index 221cb9bf4106de389becea637f62f2b0a1434bc6..7471abe5ca371f3695890ece20891437ab670124 100644 --- a/tool/CommandMaster.cpp +++ b/tool/CommandMaster.cpp @@ -45,11 +45,11 @@ CommandMaster::CommandMaster(): /****************************************************************************/ -string CommandMaster::helpString() const +string CommandMaster::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandMaster.h b/tool/CommandMaster.h index de7976d4909e21273a890ad163b2da5cad6156df..53577d4a2c48dc3cf82ce5155782b22d95fa1515 100644 --- a/tool/CommandMaster.h +++ b/tool/CommandMaster.h @@ -40,7 +40,7 @@ class CommandMaster: public: CommandMaster(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); private: diff --git a/tool/CommandPdos.cpp b/tool/CommandPdos.cpp index ccf7d97e4899e5b434c38e0a7d4ccf54b66f2f07..6cf01b1740f01b32b205c85df3c6ee141e27f914 100644 --- a/tool/CommandPdos.cpp +++ b/tool/CommandPdos.cpp @@ -43,11 +43,11 @@ CommandPdos::CommandPdos(): /*****************************************************************************/ -string CommandPdos::helpString() const +string CommandPdos::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandPdos.h b/tool/CommandPdos.h index 91539509d3fe00d003cdc2170aa46aed0cf56d42..a1c0a54ba530bbbbe1244ae57dff26d3f0337789 100644 --- a/tool/CommandPdos.h +++ b/tool/CommandPdos.h @@ -40,7 +40,7 @@ class CommandPdos: public: CommandPdos(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandRegRead.cpp b/tool/CommandRegRead.cpp index 8af9635f1e4e778a5784d5fd9d9af23b60bd4196..3055ad20c2e21d74428eb08f39890d718bee290e 100644 --- a/tool/CommandRegRead.cpp +++ b/tool/CommandRegRead.cpp @@ -43,11 +43,12 @@ CommandRegRead::CommandRegRead(): /*****************************************************************************/ -string CommandRegRead::helpString() const +string CommandRegRead::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <OFFSET> [LENGTH]" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <OFFSET> [LENGTH]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandRegRead.h b/tool/CommandRegRead.h index 2e8a4a19e80eb69331b0eb2cc8701ce78017b9ff..8cb39327fdd4025a485f95be886653aa8b8f61b1 100644 --- a/tool/CommandRegRead.h +++ b/tool/CommandRegRead.h @@ -42,7 +42,7 @@ class CommandRegRead: public: CommandRegRead(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandRegWrite.cpp b/tool/CommandRegWrite.cpp index 964dc1bbc98191c1cb2b407c715a2e9bfe824e73..7e1e1bb912ccb60ec6176fdc7d1c15771c824037 100644 --- a/tool/CommandRegWrite.cpp +++ b/tool/CommandRegWrite.cpp @@ -45,11 +45,12 @@ CommandRegWrite::CommandRegWrite(): /*****************************************************************************/ -string CommandRegWrite::helpString() const +string CommandRegWrite::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <OFFSET> <DATA>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <OFFSET> <DATA>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandRegWrite.h b/tool/CommandRegWrite.h index 71a0487e086620916f6803c81815c091f7b52eec..c8e047be6008296bfe1f88424663ab76509dbc5c 100644 --- a/tool/CommandRegWrite.h +++ b/tool/CommandRegWrite.h @@ -42,7 +42,7 @@ class CommandRegWrite: public: CommandRegWrite(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); private: diff --git a/tool/CommandRescan.cpp b/tool/CommandRescan.cpp index c3d1cd3baad2bef661efa65e4da42af0fd8955fb..8fe3880263eb074ec62f42ba8f6979988da1be20 100644 --- a/tool/CommandRescan.cpp +++ b/tool/CommandRescan.cpp @@ -45,11 +45,11 @@ CommandRescan::CommandRescan(): /*****************************************************************************/ -string CommandRescan::helpString() const +string CommandRescan::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << endl + str << binaryBaseName << " " << getName() << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandRescan.h b/tool/CommandRescan.h index 80c386cf3e64b0d946594a77944248b50b857d41..ee2ea7faad8d134f246b7c1bc0d999790c7f7aba 100644 --- a/tool/CommandRescan.h +++ b/tool/CommandRescan.h @@ -40,7 +40,7 @@ class CommandRescan: public: CommandRescan(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandSdos.cpp b/tool/CommandSdos.cpp index d194e218d124a42ee07f7a0a34733484a4d327be..348b7cc63df602beb56dac2caa0a6343f0119955 100644 --- a/tool/CommandSdos.cpp +++ b/tool/CommandSdos.cpp @@ -43,11 +43,11 @@ CommandSdos::CommandSdos(): /*****************************************************************************/ -string CommandSdos::helpString() const +string CommandSdos::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandSdos.h b/tool/CommandSdos.h index 7aa301f23da55565b1457f52418213203d3c7061..cc83594558716a6c167ebb86d8dd9f72ae8ac51f 100644 --- a/tool/CommandSdos.h +++ b/tool/CommandSdos.h @@ -40,7 +40,7 @@ class CommandSdos: public: CommandSdos(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSiiRead.cpp b/tool/CommandSiiRead.cpp index 24e23ae8873ce9c67a422236541b59f3c3419dc7..979dd525a17e2e61ad6a3bf311a8d81929b0d201 100644 --- a/tool/CommandSiiRead.cpp +++ b/tool/CommandSiiRead.cpp @@ -43,11 +43,11 @@ CommandSiiRead::CommandSiiRead(): /*****************************************************************************/ -string CommandSiiRead::helpString() const +string CommandSiiRead::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandSiiRead.h b/tool/CommandSiiRead.h index 8f797a634df463ddf662dbd2391d4444e90d15a0..2b4152b282e257f8a39703f7e3a16d71949c6211 100644 --- a/tool/CommandSiiRead.h +++ b/tool/CommandSiiRead.h @@ -40,7 +40,7 @@ class CommandSiiRead: public: CommandSiiRead(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSiiWrite.cpp b/tool/CommandSiiWrite.cpp index de6d0507e0dc80c4a63294f11881d53f8c746107..22e4663d7dd434068ede2894cb53bcb6ade2c5b7 100644 --- a/tool/CommandSiiWrite.cpp +++ b/tool/CommandSiiWrite.cpp @@ -45,11 +45,12 @@ CommandSiiWrite::CommandSiiWrite(): /*****************************************************************************/ -string CommandSiiWrite::helpString() const +string CommandSiiWrite::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <FILENAME>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <FILENAME>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandSiiWrite.h b/tool/CommandSiiWrite.h index a22b8db69e6fab759fe05f9ea91b6ae1de98516a..f40cada5d0af5d344a4b45a586f0157b783e6e5c 100644 --- a/tool/CommandSiiWrite.h +++ b/tool/CommandSiiWrite.h @@ -40,7 +40,7 @@ class CommandSiiWrite: public: CommandSiiWrite(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSlaves.cpp b/tool/CommandSlaves.cpp index fe8cb516f451a7f045923fe027fd34e504db5899..2485bb31cccfabf80f30eac8380508f48cf78f59 100644 --- a/tool/CommandSlaves.cpp +++ b/tool/CommandSlaves.cpp @@ -45,11 +45,11 @@ CommandSlaves::CommandSlaves(): /*****************************************************************************/ -string CommandSlaves::helpString() const +string CommandSlaves::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandSlaves.h b/tool/CommandSlaves.h index 1ac5b673a24a9323ed9df86deb92cad8431923bf..c04ce74a2e4f51b16762c33f5021b7b0682f38f1 100644 --- a/tool/CommandSlaves.h +++ b/tool/CommandSlaves.h @@ -40,7 +40,7 @@ class CommandSlaves: public: CommandSlaves(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSoeRead.cpp b/tool/CommandSoeRead.cpp index 18f1bec9729e04d792bc6fc187a1a76aeea73184..2ad4c0f8ad4741a6df975b40a93796734509aa66 100644 --- a/tool/CommandSoeRead.cpp +++ b/tool/CommandSoeRead.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include <iostream> +#include <iomanip> using namespace std; #include "CommandSoeRead.h" @@ -42,17 +43,22 @@ CommandSoeRead::CommandSoeRead(): /*****************************************************************************/ -string CommandSoeRead::helpString() const +string CommandSoeRead::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <IDN>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <IDN>" << endl + << binaryBaseName << " " << getName() + << " [OPTIONS] <DRIVE> <IDN>" << endl << endl << getBriefDescription() << endl << endl << "This command requires a single slave to be selected." << endl << endl << "Arguments:" << endl + << " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed." + << endl << " IDN is the IDN and must be either an unsigned" << endl << " 16 bit number acc. to IEC 61800-7-204:" << endl << " Bit 15: (0) Standard data, (1) Product data" << endl @@ -84,18 +90,38 @@ void CommandSoeRead::execute(const StringVector &args) stringstream err; const DataType *dataType = NULL; ec_ioctl_slave_soe_read_t ioctl; + int driveArgIndex = -1, idnArgIndex = -1; - if (args.size() != 1) { - err << "'" << getName() << "' takes one argument!"; + if (args.size() == 1) { + idnArgIndex = 0; + } else if (args.size() == 2) { + driveArgIndex = 0; + idnArgIndex = 1; + } else { + err << "'" << getName() << "' takes eiter 1 or 2 arguments!"; throwInvalidUsageException(err); } - ioctl.drive_no = 0; // FIXME + if (driveArgIndex >= 0) { + stringstream str; + unsigned int number; + str << args[driveArgIndex]; + str + >> resetiosflags(ios::basefield) // guess base from prefix + >> number; + if (str.fail() || number > 7) { + err << "Invalid drive number '" << args[driveArgIndex] << "'!"; + throwInvalidUsageException(err); + } + ioctl.drive_no = number; + } else { + ioctl.drive_no = 0; + } try { - ioctl.idn = parseIdn(args[0]); + ioctl.idn = parseIdn(args[idnArgIndex]); } catch (runtime_error &e) { - err << "Invalid IDN '" << args[0] << "': " << e.what(); + err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what(); throwInvalidUsageException(err); } diff --git a/tool/CommandSoeRead.h b/tool/CommandSoeRead.h index a6e73d7a59b910fffed356b32fc08fa0df428abd..06e0c8e0d5616f9b3d399c157eab18dae453bfba 100644 --- a/tool/CommandSoeRead.h +++ b/tool/CommandSoeRead.h @@ -42,7 +42,7 @@ class CommandSoeRead: public: CommandSoeRead(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandSoeWrite.cpp b/tool/CommandSoeWrite.cpp index 16f76ccd4cbc0d04769bf3a20f5146547f332e67..382ba8d675617d6549c31daff9fcddb95ef91669 100644 --- a/tool/CommandSoeWrite.cpp +++ b/tool/CommandSoeWrite.cpp @@ -28,6 +28,7 @@ ****************************************************************************/ #include <iostream> +#include <iomanip> using namespace std; #include "CommandSoeWrite.h" @@ -42,17 +43,22 @@ CommandSoeWrite::CommandSoeWrite(): /*****************************************************************************/ -string CommandSoeWrite::helpString() const +string CommandSoeWrite::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <IDN> <VALUE>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <IDN> <VALUE>" << endl + << binaryBaseName << " " << getName() + << " [OPTIONS] <DRIVE> <IDN> <VALUE>" << endl << endl << getBriefDescription() << endl << endl << "This command requires a single slave to be selected." << endl << endl << "Arguments:" << endl + << " DRIVE is the drive number (0 - 7). If omitted, 0 is assumed." + << endl << " IDN is the IDN and must be either an unsigned" << endl << " 16 bit number acc. to IEC 61800-7-204:" << endl << " Bit 15: (0) Standard data, (1) Product data" << endl @@ -81,23 +87,45 @@ string CommandSoeWrite::helpString() const void CommandSoeWrite::execute(const StringVector &args) { - stringstream strIdn, err; + stringstream err; const DataType *dataType = NULL; ec_ioctl_slave_soe_write_t ioctl; SlaveList slaves; size_t memSize; - - if (args.size() != 2) { - err << "'" << getName() << "' takes 2 arguments!"; + int driveArgIndex = -1, idnArgIndex = -1, valueArgIndex = -1; + + if (args.size() == 2) { + idnArgIndex = 0; + valueArgIndex = 1; + } else if (args.size() == 3) { + driveArgIndex = 0; + idnArgIndex = 1; + valueArgIndex = 2; + } else { + err << "'" << getName() << "' takes eiter 2 or 3 arguments!"; throwInvalidUsageException(err); } - ioctl.drive_no = 0; // FIXME + if (driveArgIndex >= 0) { + stringstream str; + unsigned int number; + str << args[driveArgIndex]; + str + >> resetiosflags(ios::basefield) // guess base from prefix + >> number; + if (str.fail() || number > 7) { + err << "Invalid drive number '" << args[driveArgIndex] << "'!"; + throwInvalidUsageException(err); + } + ioctl.drive_no = number; + } else { + ioctl.drive_no = 0; + } try { - ioctl.idn = parseIdn(args[0]); + ioctl.idn = parseIdn(args[idnArgIndex]); } catch (runtime_error &e) { - err << "Invalid IDN '" << args[0] << "': " << e.what(); + err << "Invalid IDN '" << args[idnArgIndex] << "': " << e.what(); throwInvalidUsageException(err); } @@ -123,7 +151,7 @@ void CommandSoeWrite::execute(const StringVector &args) memSize = dataType->byteSize; } else { // guess string type size - memSize = args[1].size() + 1; + memSize = args[valueArgIndex].size() + 1; if (!memSize) { err << "Empty argument not allowed."; throwInvalidUsageException(err); @@ -134,13 +162,13 @@ void CommandSoeWrite::execute(const StringVector &args) try { ioctl.data_size = interpretAsType( - dataType, args[1], ioctl.data, memSize); + dataType, args[valueArgIndex], ioctl.data, memSize); } catch (SizeException &e) { delete [] ioctl.data; throwCommandException(e.what()); } catch (ios::failure &e) { delete [] ioctl.data; - err << "Invalid value argument '" << args[1] + err << "Invalid value argument '" << args[valueArgIndex] << "' for type '" << dataType->name << "'!"; throwInvalidUsageException(err); } diff --git a/tool/CommandSoeWrite.h b/tool/CommandSoeWrite.h index f6462c0632bf4939d551a24f980052f4229bbe3b..f86134c489019f5b7d8a7a661ad66cc3c89bb78e 100644 --- a/tool/CommandSoeWrite.h +++ b/tool/CommandSoeWrite.h @@ -42,7 +42,7 @@ class CommandSoeWrite: public: CommandSoeWrite(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandStates.cpp b/tool/CommandStates.cpp index 663979c897b580025ce7684d78d7509dd72aa33b..32e710a468379581689e83682dca848134f22b3f 100644 --- a/tool/CommandStates.cpp +++ b/tool/CommandStates.cpp @@ -43,11 +43,11 @@ CommandStates::CommandStates(): /*****************************************************************************/ -string CommandStates::helpString() const +string CommandStates::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <STATE>" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS] <STATE>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandStates.h b/tool/CommandStates.h index 305b8347f13bdcdf29e6d71f2fc3368405038491..77f8e6b5c5f3741b746ea9a7b10cd5ac0b0244ae 100644 --- a/tool/CommandStates.h +++ b/tool/CommandStates.h @@ -40,7 +40,7 @@ class CommandStates: public: CommandStates(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandUpload.cpp b/tool/CommandUpload.cpp index 4146ab6937826bb1ac30d8665745154048afc7d3..439eeab3f9068b05a30f45945aa078e07d9af061 100644 --- a/tool/CommandUpload.cpp +++ b/tool/CommandUpload.cpp @@ -43,11 +43,12 @@ CommandUpload::CommandUpload(): /*****************************************************************************/ -string CommandUpload::helpString() const +string CommandUpload::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS] <INDEX> <SUBINDEX>" << endl + str << binaryBaseName << " " << getName() + << " [OPTIONS] <INDEX> <SUBINDEX>" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandUpload.h b/tool/CommandUpload.h index 5d99ba4d3441c7b8fac7fa6c9669ed3344866458..f9cdc4663a89046afc4a25f93cd9b16e45c87640 100644 --- a/tool/CommandUpload.h +++ b/tool/CommandUpload.h @@ -40,7 +40,7 @@ class CommandUpload: public: CommandUpload(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandVersion.cpp b/tool/CommandVersion.cpp index c81b8be79ddc6d16e07ae1062ccb938b353376bd..ccf9913dbc1ad9f3c7184927b5f727c2d01b276c 100644 --- a/tool/CommandVersion.cpp +++ b/tool/CommandVersion.cpp @@ -41,11 +41,11 @@ CommandVersion::CommandVersion(): /****************************************************************************/ -string CommandVersion::helpString() const +string CommandVersion::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl; diff --git a/tool/CommandVersion.h b/tool/CommandVersion.h index 842db32082e4ee4a4457b8eb01bfb0267184894b..0592e2f96edfebdf4d61a2e3bbc8d38c85cf73a8 100644 --- a/tool/CommandVersion.h +++ b/tool/CommandVersion.h @@ -40,7 +40,7 @@ class CommandVersion: public: CommandVersion(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandXml.cpp b/tool/CommandXml.cpp index 28576a85061aedcffdda70611887a38db5cfcd7f..de5086f4c3980d7262f2f36981abda6faef17f0e 100644 --- a/tool/CommandXml.cpp +++ b/tool/CommandXml.cpp @@ -44,11 +44,11 @@ CommandXml::CommandXml(): /*****************************************************************************/ -string CommandXml::helpString() const +string CommandXml::helpString(const string &binaryBaseName) const { stringstream str; - str << getName() << " [OPTIONS]" << endl + str << binaryBaseName << " " << getName() << " [OPTIONS]" << endl << endl << getBriefDescription() << endl << endl diff --git a/tool/CommandXml.h b/tool/CommandXml.h index 5e8a2b559b2fcd6bc96df8308646e8ac9ecaaadd..2f7ec6a87c2c52bc398e69762f1f53c8af4f852c 100644 --- a/tool/CommandXml.h +++ b/tool/CommandXml.h @@ -40,7 +40,7 @@ class CommandXml: public: CommandXml(); - string helpString() const; + string helpString(const string &) const; void execute(const StringVector &); protected: diff --git a/tool/main.cpp b/tool/main.cpp index 0afa35c90195563bb12c3fe39cb41e3f9ed70381..c4fa59d0de20163640f5647bf471ff0634aa49d6 100644 --- a/tool/main.cpp +++ b/tool/main.cpp @@ -340,7 +340,7 @@ int main(int argc, char **argv) cmd->execute(commandArgs); } catch (InvalidUsageException &e) { cerr << e.what() << endl << endl; - cerr << binaryBaseName << " " << cmd->helpString(); + cerr << cmd->helpString(binaryBaseName); retval = 1; } catch (CommandException &e) { cerr << e.what() << endl; @@ -350,7 +350,7 @@ int main(int argc, char **argv) retval = 1; } } else { - cout << binaryBaseName << " " << cmd->helpString(); + cout << cmd->helpString(binaryBaseName); } } else { cerr << "Ambiguous command abbreviation! Matching:" << endl;