From 305d13544dc29f55d194daf3c09a6f89e995c96a Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 11 Aug 2026 12:39:02 +0200 Subject: [PATCH 1/4] Avoid using namespace in headers. --- tool/Command.h | 101 ++++++++++++++++++++-------------------- tool/CommandConfig.h | 15 +++--- tool/FoeCommand.cpp | 2 + tool/FoeCommand.h | 2 +- tool/MasterDevice.h | 13 +++--- tool/NumberListParser.h | 3 +- tool/SdoCommand.cpp | 2 + tool/SdoCommand.h | 2 +- tool/SoeCommand.h | 2 +- 9 files changed, 71 insertions(+), 71 deletions(-) diff --git a/tool/Command.h b/tool/Command.h index 5fe878bb..fdb92edc 100644 --- a/tool/Command.h +++ b/tool/Command.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -26,7 +26,6 @@ #include #include #include -using namespace std; #include "../master/ioctl.h" @@ -35,34 +34,34 @@ class MasterDevice; /****************************************************************************/ class InvalidUsageException: - public runtime_error + public std::runtime_error { friend class Command; protected: /** Constructor with stringstream parameter. */ InvalidUsageException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ class CommandException: - public runtime_error + public std::runtime_error { friend class Command; protected: /** Constructor with char * parameter. */ CommandException( - const string &msg /**< Message. */ - ): runtime_error(msg) {} + const std::string &msg /**< Message. */ + ): std::runtime_error(msg) {} /** Constructor with stringstream parameter. */ CommandException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ @@ -70,14 +69,14 @@ class CommandException: class Command { public: - Command(const string &, const string &); + Command(const std::string &, const std::string &); virtual ~Command(); - const string &getName() const; - const string &getBriefDescription() const; + const std::string &getName() const; + const std::string &getBriefDescription() const; - typedef list MasterIndexList; - void setMasters(const string &); + typedef std::list MasterIndexList; + void setMasters(const std::string &); MasterIndexList getMasterIndices() const; unsigned int getSingleMasterIndex() const; @@ -89,15 +88,15 @@ class Command void setVerbosity(Verbosity); Verbosity getVerbosity() const; - void setAliases(const string &); - void setPositions(const string &); + void setAliases(const std::string &); + void setPositions(const std::string &); - void setDomains(const string &); - typedef list DomainIndexList; + void setDomains(const std::string &); + typedef std::list DomainIndexList; DomainIndexList getDomainIndices() const; - void setDataType(const string &); - const string &getDataType() const; + void setDataType(const std::string &); + const std::string &getDataType() const; void setEmergency(bool); bool getEmergency() const; @@ -105,67 +104,67 @@ class Command void setForce(bool); bool getForce() const; - void setOutputFile(const string &); - const string &getOutputFile() const; + void setOutputFile(const std::string &); + const std::string &getOutputFile() const; - void setSkin(const string &); - const string &getSkin() const; + void setSkin(const std::string &); + const std::string &getSkin() const; - bool matchesSubstr(const string &) const; - bool matchesAbbrev(const string &) const; + bool matchesSubstr(const std::string &) const; + bool matchesAbbrev(const std::string &) const; - virtual string helpString(const string &) const = 0; + virtual std::string helpString(const std::string &) const = 0; - typedef vector StringVector; + typedef std::vector StringVector; virtual void execute(const StringVector &) = 0; - static string numericInfo(); + static std::string numericInfo(); protected: enum {BreakAfterBytes = 16}; - void throwInvalidUsageException(const stringstream &) const; - void throwCommandException(const string &) const; - void throwCommandException(const stringstream &) const; + void throwInvalidUsageException(const std::stringstream &) const; + void throwCommandException(const std::string &) const; + void throwCommandException(const std::stringstream &) const; void throwSingleSlaveRequired(unsigned int) const; - typedef list SlaveList; + typedef std::list SlaveList; SlaveList selectedSlaves(MasterDevice &); - typedef list ConfigList; + typedef std::list ConfigList; ConfigList selectedConfigs(MasterDevice &); - typedef list DomainList; + typedef std::list DomainList; DomainList selectedDomains(MasterDevice &, const ec_ioctl_master_t &); int emergencySlave() const; - static string alStateString(uint8_t); + static std::string alStateString(uint8_t); private: - string name; - string briefDesc; - string masters; + std::string name; + std::string briefDesc; + std::string masters; Verbosity verbosity; - string aliases; - string positions; - string domains; - string dataType; + std::string aliases; + std::string positions; + std::string domains; + std::string dataType; bool emergency; bool force; - string outputFile; - string skin; + std::string outputFile; + std::string skin; Command(); }; /****************************************************************************/ -inline const string &Command::getName() const +inline const std::string &Command::getName() const { return name; } /****************************************************************************/ -inline const string &Command::getBriefDescription() const +inline const std::string &Command::getBriefDescription() const { return briefDesc; } @@ -179,7 +178,7 @@ inline Command::Verbosity Command::getVerbosity() const /****************************************************************************/ -inline const string &Command::getDataType() const +inline const std::string &Command::getDataType() const { return dataType; } @@ -200,14 +199,14 @@ inline bool Command::getForce() const /****************************************************************************/ -inline const string &Command::getOutputFile() const +inline const std::string &Command::getOutputFile() const { return outputFile; } /****************************************************************************/ -inline const string &Command::getSkin() const +inline const std::string &Command::getSkin() const { return skin; } diff --git a/tool/CommandConfig.h b/tool/CommandConfig.h index f58d4324..7cc9e4e7 100644 --- a/tool/CommandConfig.h +++ b/tool/CommandConfig.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -23,7 +23,6 @@ #define __COMMANDCONFIG_H__ #include -using namespace std; #include "Command.h" #include "SoeCommand.h" @@ -37,16 +36,16 @@ class CommandConfig: public: CommandConfig(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: struct Info { - string alias; - string pos; - string ident; - string slavePos; - string state; + std::string alias; + std::string pos; + std::string ident; + std::string slavePos; + std::string state; }; void showDetailedConfigs(MasterDevice &, const ConfigList &, bool); diff --git a/tool/FoeCommand.cpp b/tool/FoeCommand.cpp index 82443085..3ebd2ea0 100644 --- a/tool/FoeCommand.cpp +++ b/tool/FoeCommand.cpp @@ -22,6 +22,8 @@ #include "FoeCommand.h" #include "foe.h" +using std::string; + /****************************************************************************/ FoeCommand::FoeCommand(const string &name, const string &briefDesc): diff --git a/tool/FoeCommand.h b/tool/FoeCommand.h index 6becbde9..6d93dd5c 100644 --- a/tool/FoeCommand.h +++ b/tool/FoeCommand.h @@ -30,7 +30,7 @@ class FoeCommand: public Command { public: - FoeCommand(const string &, const string &); + FoeCommand(const std::string &, const std::string &); protected: static std::string resultText(int); diff --git a/tool/MasterDevice.h b/tool/MasterDevice.h index 204fd1ba..8762f2bf 100644 --- a/tool/MasterDevice.h +++ b/tool/MasterDevice.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -24,7 +24,6 @@ #include #include -using namespace std; #include "ecrt.h" #include "ioctl.h" @@ -32,20 +31,20 @@ using namespace std; /****************************************************************************/ class MasterDeviceException: - public runtime_error + public std::runtime_error { friend class MasterDevice; protected: /** Constructor with string parameter. */ MasterDeviceException( - const string &s /**< Message. */ - ): runtime_error(s) {} + const std::string &s /**< Message. */ + ): std::runtime_error(s) {} /** Constructor with stringstream parameter. */ MasterDeviceException( - const stringstream &s /**< Message. */ - ): runtime_error(s.str()) {} + const std::stringstream &s /**< Message. */ + ): std::runtime_error(s.str()) {} }; /****************************************************************************/ diff --git a/tool/NumberListParser.h b/tool/NumberListParser.h index 37b89f33..15ebdccf 100644 --- a/tool/NumberListParser.h +++ b/tool/NumberListParser.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -20,7 +20,6 @@ ****************************************************************************/ #include -using namespace std; /****************************************************************************/ diff --git a/tool/SdoCommand.cpp b/tool/SdoCommand.cpp index aa93583f..c21a0e71 100644 --- a/tool/SdoCommand.cpp +++ b/tool/SdoCommand.cpp @@ -21,6 +21,8 @@ #include "SdoCommand.h" +using std::string; + /****************************************************************************/ SdoCommand::SdoCommand(const string &name, const string &briefDesc): diff --git a/tool/SdoCommand.h b/tool/SdoCommand.h index 794ddc80..41ca24a8 100644 --- a/tool/SdoCommand.h +++ b/tool/SdoCommand.h @@ -32,7 +32,7 @@ class SdoCommand: public DataTypeHandler { public: - SdoCommand(const string &, const string &); + SdoCommand(const std::string &, const std::string &); static const char *abortText(uint32_t); diff --git a/tool/SoeCommand.h b/tool/SoeCommand.h index 2391b25a..864dfb88 100644 --- a/tool/SoeCommand.h +++ b/tool/SoeCommand.h @@ -32,7 +32,7 @@ class SoeCommand { protected: - static uint16_t parseIdn(const string &); + static uint16_t parseIdn(const std::string &); static std::string outputIdn(uint16_t); static std::string errorMsg(uint16_t); }; From 1e61ca80fa800c0e1e8aeb181cc6bc61974e2a41 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 11 Aug 2026 15:03:59 +0200 Subject: [PATCH 2/4] Avoided using namespace in tool. --- CPPLINT.cfg | 5 +++++ tool/Command.cpp | 27 +++++++++++++++------------ tool/CommandAlias.cpp | 17 +++++++++++------ tool/CommandAlias.h | 4 ++-- tool/CommandCStruct.cpp | 20 +++++++++++++++----- tool/CommandCStruct.h | 4 ++-- tool/CommandConfig.cpp | 28 ++++++++++++++++++++-------- tool/CommandCrc.cpp | 22 ++++++++++++++-------- tool/CommandCrc.h | 4 ++-- tool/CommandData.cpp | 13 +++++++++---- tool/CommandData.h | 4 ++-- tool/CommandDebug.cpp | 18 +++++++++++------- tool/CommandDebug.h | 4 ++-- tool/CommandDomains.cpp | 24 +++++++++++++++++------- tool/CommandDomains.h | 4 ++-- tool/CommandDownload.cpp | 20 ++++++++++++++------ tool/CommandDownload.h | 4 ++-- tool/CommandEoe.cpp | 22 +++++++++++++++------- tool/CommandEoe.h | 4 ++-- tool/CommandFoeRead.cpp | 22 +++++++++++++++------- tool/CommandFoeRead.h | 4 ++-- tool/CommandFoeWrite.cpp | 25 +++++++++++++++++-------- tool/CommandFoeWrite.h | 6 +++--- tool/CommandGraph.cpp | 20 ++++++++++++++------ tool/CommandGraph.h | 4 ++-- tool/CommandIp.cpp | 13 +++++++++---- tool/CommandIp.h | 10 +++++----- tool/CommandMaster.cpp | 28 ++++++++++++++++++++-------- tool/CommandMaster.h | 4 ++-- tool/CommandPdos.cpp | 22 ++++++++++++++++------ tool/CommandPdos.h | 4 ++-- tool/CommandRegRead.cpp | 14 ++++++++++---- tool/CommandRegRead.h | 4 ++-- tool/CommandRegWrite.cpp | 20 +++++++++++++++----- tool/CommandRegWrite.h | 6 +++--- tool/CommandRescan.cpp | 16 ++++++++++------ tool/CommandRescan.h | 4 ++-- tool/CommandSdos.cpp | 24 +++++++++++++++++------- tool/CommandSdos.h | 4 ++-- tool/CommandSiiCaching.cpp | 25 +++++++++++++++++++------ tool/CommandSiiCaching.h | 4 +++- tool/CommandSiiRead.cpp | 20 ++++++++++++++++---- tool/CommandSiiRead.h | 4 ++-- tool/CommandSiiWrite.cpp | 22 +++++++++++++++++----- tool/CommandSiiWrite.h | 6 +++--- tool/CommandSlaves.cpp | 25 +++++++++++++++++++------ tool/CommandSlaves.h | 18 +++++++++--------- tool/CommandSoeRead.cpp | 15 +++++++++++---- tool/CommandSoeRead.h | 4 ++-- tool/CommandSoeWrite.cpp | 22 ++++++++++++++-------- tool/CommandSoeWrite.h | 4 ++-- tool/CommandStates.cpp | 23 +++++++++++++++-------- tool/CommandStates.h | 4 ++-- tool/CommandUpload.cpp | 17 +++++++++++++---- tool/CommandUpload.h | 4 ++-- tool/CommandVersion.cpp | 12 ++++++++---- tool/CommandVersion.h | 4 ++-- tool/CommandXml.cpp | 20 +++++++++++++++----- tool/CommandXml.h | 4 ++-- tool/DataTypeHandler.cpp | 34 ++++++++++++++++++++++++---------- tool/MasterDevice.cpp | 8 +++++--- tool/NumberListParser.cpp | 11 ++++++++--- tool/NumberListParser.h | 2 +- tool/SoeCommand.cpp | 30 +++++++++++++++++++----------- tool/main.cpp | 26 +++++++++++++++++--------- 65 files changed, 580 insertions(+), 290 deletions(-) diff --git a/CPPLINT.cfg b/CPPLINT.cfg index 9ff7e021..b05ed736 100644 --- a/CPPLINT.cfg +++ b/CPPLINT.cfg @@ -1,12 +1,17 @@ filter=-build/header_guard +filter=-build/include_order filter=-build/include_subdir filter=-build/include_what_you_use +filter=-readability/alt_tokens filter=-readability/braces +filter=-readability/casting filter=-readability/multiline_comment filter=-runtime/int filter=-runtime/printf +filter=-runtime/string filter=-whitespace/braces filter=-whitespace/comments filter=-whitespace/empty_loop_body +filter=-whitespace/indent filter=-whitespace/newline linelength=78 diff --git a/tool/Command.cpp b/tool/Command.cpp index 4f539ab6..9cf126fe 100644 --- a/tool/Command.cpp +++ b/tool/Command.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,12 +21,17 @@ * ****************************************************************************/ -#include -using namespace std; - #include "Command.h" -#include "MasterDevice.h" + #include "NumberListParser.h" +#include "MasterDevice.h" + +#include + +using std::string; +using std::stringstream; +using std::endl; +using std::map; /****************************************************************************/ @@ -82,7 +87,7 @@ class ConfigAliasParser: public NumberListParser { public: - ConfigAliasParser(unsigned int maxAlias): + explicit ConfigAliasParser(unsigned int maxAlias): maxAlias(maxAlias) {} protected: @@ -98,7 +103,7 @@ class PositionParser: public NumberListParser { public: - PositionParser(unsigned int count): + explicit PositionParser(unsigned int count): count(count) {} protected: @@ -116,7 +121,7 @@ class AliasPositionParser: public NumberListParser { public: - AliasPositionParser(const AliasMap &aliasMap): + explicit AliasPositionParser(const AliasMap &aliasMap): aliasMap(aliasMap) {} protected: @@ -306,7 +311,7 @@ Command::MasterIndexList Command::getMasterIndices() const stringstream err; err << "Failed to obtain number of masters: " << e.what(); throwCommandException(err); - } catch (runtime_error &e) { + } catch (std::runtime_error &e) { stringstream err; err << "Invalid master argument '" << masters << "': " << e.what(); throwInvalidUsageException(err); @@ -358,10 +363,9 @@ Command::SlaveList Command::selectedSlaves(MasterDevice &m) NumberListParser::List::const_iterator ai; for (ai = aliasList.begin(); ai != aliasList.end(); ai++) { - // gather slaves with that alias (and following) uint16_t lastAlias = 0; - vector aliasSlaves; + std::vector aliasSlaves; for (i = 0; i < master.slave_count; i++) { m.getSlave(&slave, i); @@ -440,7 +444,6 @@ Command::ConfigList Command::selectedConfigs(MasterDevice &m) NumberListParser::List::const_iterator ai; for (ai = aliasList.begin(); ai != aliasList.end(); ai++) { - ConfigMap::iterator ci = configs.find(*ai); if (ci == configs.end()) { continue; diff --git a/tool/CommandAlias.cpp b/tool/CommandAlias.cpp index d3282e91..1d410378 100644 --- a/tool/CommandAlias.cpp +++ b/tool/CommandAlias.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,14 +19,19 @@ * ****************************************************************************/ +#include "CommandAlias.h" + +#include "sii_crc.h" +#include "MasterDevice.h" + #include #include #include -using namespace std; -#include "CommandAlias.h" -#include "sii_crc.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cerr; /****************************************************************************/ @@ -83,7 +88,7 @@ void CommandAlias::execute(const StringVector &args) strAlias << args[0]; strAlias - >> resetiosflags(ios::basefield) // guess base from prefix + >> resetiosflags(std::ios::basefield) // guess base from prefix >> number; if (strAlias.fail() || number < 0x0000 || number > 0xffff) { err << "Invalid alias '" << args[0] << "'!"; diff --git a/tool/CommandAlias.h b/tool/CommandAlias.h index 8189c87f..aa853fff 100644 --- a/tool/CommandAlias.h +++ b/tool/CommandAlias.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandAlias: public: CommandAlias(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandCStruct.cpp b/tool/CommandCStruct.cpp index 1623666d..b6ca7cec 100644 --- a/tool/CommandCStruct.cpp +++ b/tool/CommandCStruct.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,13 +21,23 @@ * ****************************************************************************/ +#include "CommandCStruct.h" + +#include "MasterDevice.h" + +#include + #include #include -#include -using namespace std; -#include "CommandCStruct.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::dec; +using std::hex; +using std::setfill; +using std::setw; +using std::cout; /****************************************************************************/ diff --git a/tool/CommandCStruct.h b/tool/CommandCStruct.h index cf78d7d7..4e2f7a43 100644 --- a/tool/CommandCStruct.h +++ b/tool/CommandCStruct.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandCStruct: public: CommandCStruct(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandConfig.cpp b/tool/CommandConfig.cpp index cf726faa..169d1155 100644 --- a/tool/CommandConfig.cpp +++ b/tool/CommandConfig.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -22,15 +22,27 @@ ****************************************************************************/ #include "CommandConfig.h" + #include "MasterDevice.h" +#include + #include #include #include #include -using namespace std; -#include +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::dec; +using std::hex; +using std::setw; +using std::setfill; +using std::min; +using std::right; +using std::left; /****************************************************************************/ @@ -55,11 +67,13 @@ string CommandConfig::helpString(const string &binaryBaseName) const << "1001:0 0x0000003b/0x02010000 3 OP" << endl << "| | | |" << endl << "| | | \\- Application-layer" << endl - << "| | | state of the attached" << endl + << "| | | state of the attached" + << endl << "| | | slave, or '-', if no" << endl << "| | | slave is attached." << endl << "| | \\- Absolute decimal ring" << endl - << "| | position of the attached" << endl + << "| | position of the attached" + << endl << "| | slave, or '-' if none" << endl << "| | attached." << endl << "| \\- Expected vendor ID and product code (both" << endl @@ -157,7 +171,6 @@ void CommandConfig::showDetailedConfigs( for (configIter = configList.begin(); configIter != configList.end(); configIter++) { - cout << indent << "Alias: " << dec << configIter->alias << endl << indent @@ -377,7 +390,7 @@ void CommandConfig::listConfigs( ConfigList::const_iterator configIter; stringstream str; Info info; - typedef list InfoList; + typedef std::list InfoList; InfoList list; InfoList::const_iterator iter; unsigned int maxAliasWidth = 0, maxPosWidth = 0, @@ -388,7 +401,6 @@ void CommandConfig::listConfigs( for (configIter = configList.begin(); configIter != configList.end(); configIter++) { - str << dec << configIter->alias; info.alias = str.str(); str.clear(); diff --git a/tool/CommandCrc.cpp b/tool/CommandCrc.cpp index 05df4b11..a0f382c2 100644 --- a/tool/CommandCrc.cpp +++ b/tool/CommandCrc.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2017 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,13 +19,19 @@ * ****************************************************************************/ +#include "CommandCrc.h" + +#include "MasterDevice.h" + #include #include #include -using namespace std; -#include "CommandCrc.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::setw; /****************************************************************************/ @@ -75,10 +81,12 @@ void CommandCrc::execute(const StringVector &args) if (args.size() == 1) { string arg = args[0]; transform(arg.begin(), arg.end(), - arg.begin(), (int (*) (int)) std::tolower); + arg.begin(), + (int (*) (int)) std::tolower); // NOLINT(whitespace/parens) if (arg != "reset") { stringstream err; - err << "'" << getName() << "' takes either no or 'reset' argument!"; + err << "'" << getName() + << "' takes either no or 'reset' argument!"; throwInvalidUsageException(err); } @@ -104,7 +112,6 @@ void CommandCrc::execute(const StringVector &args) } for (unsigned int i = 0; i < master.slave_count; i++) { - io.slave_position = i; try { m.writeReg(&io); @@ -128,7 +135,6 @@ void CommandCrc::execute(const StringVector &args) cout << endl; for (unsigned int i = 0; i < master.slave_count; i++) { - ec_ioctl_slave_t slave; m.getSlave(&slave, i); diff --git a/tool/CommandCrc.h b/tool/CommandCrc.h index 6ecbfbfe..07ac0652 100644 --- a/tool/CommandCrc.h +++ b/tool/CommandCrc.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2017 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -34,7 +34,7 @@ class CommandCrc: public: CommandCrc(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandData.cpp b/tool/CommandData.cpp index 6fc58912..ca03de73 100644 --- a/tool/CommandData.cpp +++ b/tool/CommandData.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,12 +21,17 @@ * ****************************************************************************/ -#include -using namespace std; - #include "CommandData.h" + #include "MasterDevice.h" +#include + +using std::string; +using std::stringstream; +using std::endl; +using std::cout; + /****************************************************************************/ CommandData::CommandData(): diff --git a/tool/CommandData.h b/tool/CommandData.h index 64b3be9f..58496533 100644 --- a/tool/CommandData.h +++ b/tool/CommandData.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandData: public: CommandData(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandDebug.cpp b/tool/CommandDebug.cpp index b106da2d..ab846495 100644 --- a/tool/CommandDebug.cpp +++ b/tool/CommandDebug.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,12 +21,16 @@ * ****************************************************************************/ +#include "CommandDebug.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandDebug.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; /****************************************************************************/ @@ -62,7 +66,7 @@ string CommandDebug::helpString(const string &binaryBaseName) const void CommandDebug::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; stringstream str; int debugLevel; @@ -73,7 +77,7 @@ void CommandDebug::execute(const StringVector &args) } str << args[0]; - str >> resetiosflags(ios::basefield) // guess base from prefix + str >> resetiosflags(std::ios::basefield) // guess base from prefix >> debugLevel; if (str.fail()) { @@ -82,7 +86,7 @@ void CommandDebug::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); mi != masterIndices.end(); mi++) { diff --git a/tool/CommandDebug.h b/tool/CommandDebug.h index b9f0fe59..758b907c 100644 --- a/tool/CommandDebug.h +++ b/tool/CommandDebug.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandDebug: public: CommandDebug(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandDomains.cpp b/tool/CommandDomains.cpp index 83abf1fd..52b5c466 100644 --- a/tool/CommandDomains.cpp +++ b/tool/CommandDomains.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,21 @@ * ****************************************************************************/ +#include "CommandDomains.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandDomains.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::dec; +using std::hex; +using std::setw; +using std::setfill; /****************************************************************************/ @@ -50,7 +59,8 @@ string CommandDomains::helpString(const string &binaryBaseName) const << endl << endl << "The domain's base address for the logical datagram" << endl << "(LRD/LWR/LRW) is displayed followed by the domain's" << endl - << "process data size in byte. The last values are the current" << endl + << "process data size in byte. The last values are the current" + << endl << "datagram working counter sum and the expected working" << endl << "counter sum. If the values are equal, all PDOs were" << endl << "exchanged during the last cycle." << endl @@ -84,7 +94,7 @@ string CommandDomains::helpString(const string &binaryBaseName) const void CommandDomains::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; bool doIndent; DomainList domains; DomainList::const_iterator di; @@ -95,7 +105,7 @@ void CommandDomains::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); doIndent = masterIndices.size() > 1; MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); diff --git a/tool/CommandDomains.h b/tool/CommandDomains.h index cfb966dd..ae8495c5 100644 --- a/tool/CommandDomains.h +++ b/tool/CommandDomains.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandDomains: public: CommandDomains(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandDownload.cpp b/tool/CommandDownload.cpp index 4daeb7dd..169be24c 100644 --- a/tool/CommandDownload.cpp +++ b/tool/CommandDownload.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2022 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,20 @@ * ****************************************************************************/ +#include "CommandDownload.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandDownload.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ios; +using std::hex; +using std::setfill; +using std::setw; /****************************************************************************/ @@ -154,9 +162,9 @@ void CommandDownload::execute(const StringVector &args) } if (args[valueIndex] == "-") { - ostringstream tmp; + std::ostringstream tmp; - tmp << cin.rdbuf(); + tmp << std::cin.rdbuf(); string const &contents = tmp.str(); if (!contents.size()) { diff --git a/tool/CommandDownload.h b/tool/CommandDownload.h index 2d3f6863..f8af5ad3 100644 --- a/tool/CommandDownload.h +++ b/tool/CommandDownload.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandDownload: public: CommandDownload(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandEoe.cpp b/tool/CommandEoe.cpp index f87e3a0a..f16e5ad5 100644 --- a/tool/CommandEoe.cpp +++ b/tool/CommandEoe.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,14 +19,22 @@ * ****************************************************************************/ +#include "CommandEoe.h" + +#include "MasterDevice.h" + +#include + #include #include #include -#include -using namespace std; -#include "CommandEoe.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::dec; +using std::setw; /****************************************************************************/ @@ -55,7 +63,7 @@ string CommandEoe::helpString(const string &binaryBaseName) const void CommandEoe::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; ec_ioctl_master_t master; unsigned int i; ec_ioctl_eoe_handler_t eoe; @@ -68,7 +76,7 @@ void CommandEoe::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); doIndent = masterIndices.size(); indent = doIndent ? " " : ""; MasterIndexList::const_iterator mi; diff --git a/tool/CommandEoe.h b/tool/CommandEoe.h index 4c1bd8a8..f96f1611 100644 --- a/tool/CommandEoe.h +++ b/tool/CommandEoe.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandEoe: public: CommandEoe(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandFoeRead.cpp b/tool/CommandFoeRead.cpp index bb329561..2b29c8c5 100644 --- a/tool/CommandFoeRead.cpp +++ b/tool/CommandFoeRead.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,15 +19,23 @@ * ****************************************************************************/ +#include "CommandFoeRead.h" + +#include "MasterDevice.h" +#include "foe.h" + #include #include #include -using namespace std; -#include "CommandFoeRead.h" -#include "foe.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::setw; +using std::setfill; +using std::hex; +using std::cout; /****************************************************************************/ @@ -118,10 +126,10 @@ void CommandFoeRead::execute(const StringVector &args) } } - // TODO --output-file + // TODO(fp) --output-file for (i = 0; i < data.data_size; i++) { uint8_t *w = data.buffer + i; - cout << *(uint8_t *) w ; + cout << *(uint8_t *) w; } delete [] data.buffer; diff --git a/tool/CommandFoeRead.h b/tool/CommandFoeRead.h index 717158d6..99ec9a5d 100644 --- a/tool/CommandFoeRead.h +++ b/tool/CommandFoeRead.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandFoeRead: public: CommandFoeRead(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandFoeWrite.cpp b/tool/CommandFoeWrite.cpp index 6574f3f7..9e0cdef1 100644 --- a/tool/CommandFoeWrite.cpp +++ b/tool/CommandFoeWrite.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,17 +19,26 @@ * ****************************************************************************/ +#include "CommandFoeWrite.h" + +#include "MasterDevice.h" +#include "foe.h" + #include // basename() #include #include #include #include -using namespace std; -#include "CommandFoeWrite.h" -#include "foe.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ifstream; +using std::setw; +using std::setfill; +using std::hex; +using std::cerr; /****************************************************************************/ @@ -87,7 +96,7 @@ void CommandFoeWrite::execute(const StringVector &args) } if (args[0] == "-") { - loadFoeData(&data, cin); + loadFoeData(&data, std::cin); if (getOutputFile().empty()) { err << "Please specify a filename for the slave side" << " with --output-file!"; @@ -167,11 +176,11 @@ void CommandFoeWrite::execute(const StringVector &args) void CommandFoeWrite::loadFoeData( ec_ioctl_slave_foe_t *data, - const istream &in + const std::istream &in ) { stringstream err; - ostringstream tmp; + std::ostringstream tmp; tmp << in.rdbuf(); string const &contents = tmp.str(); diff --git a/tool/CommandFoeWrite.h b/tool/CommandFoeWrite.h index f1cd6038..f79706ef 100644 --- a/tool/CommandFoeWrite.h +++ b/tool/CommandFoeWrite.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,11 +32,11 @@ class CommandFoeWrite: public: CommandFoeWrite(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: - void loadFoeData(ec_ioctl_slave_foe_t *, const istream &); + void loadFoeData(ec_ioctl_slave_foe_t *, const std::istream &); }; /****************************************************************************/ diff --git a/tool/CommandGraph.cpp b/tool/CommandGraph.cpp index 4aa2bb88..f58b7e5d 100644 --- a/tool/CommandGraph.cpp +++ b/tool/CommandGraph.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,13 +19,21 @@ * ****************************************************************************/ +#include "CommandGraph.h" + +#include "MasterDevice.h" + #include #include #include -using namespace std; -#include "CommandGraph.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::vector; +using std::map; +using std::cout; +using std::cerr; /****************************************************************************/ @@ -111,7 +119,8 @@ void CommandGraph::execute(const StringVector &args) if (args.size() == 1) { string arg = args[0]; transform(arg.begin(), arg.end(), - arg.begin(), (int (*) (int)) std::toupper); + arg.begin(), + (int (*) (int)) std::toupper); // NOLINT(whitespace/parens) if (arg == "DC") { info = DC; } @@ -132,7 +141,6 @@ void CommandGraph::execute(const StringVector &args) for (unsigned int i = 0; i < master.slave_count; i++) { m.getSlave(&slave, i); slaves.push_back(slave); - } if (info == CRC) { diff --git a/tool/CommandGraph.h b/tool/CommandGraph.h index 389fcd4a..31f4d3ff 100644 --- a/tool/CommandGraph.h +++ b/tool/CommandGraph.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandGraph: public: CommandGraph(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandIp.cpp b/tool/CommandIp.cpp index 3c0484a5..4c686b09 100644 --- a/tool/CommandIp.cpp +++ b/tool/CommandIp.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2014 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,16 +21,21 @@ * ****************************************************************************/ +#include "CommandIp.h" + +#include "MasterDevice.h" + #include #include #include #include #include -using namespace std; -#include "CommandIp.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::hex; /****************************************************************************/ diff --git a/tool/CommandIp.h b/tool/CommandIp.h index bc6d9b8c..3872add1 100644 --- a/tool/CommandIp.h +++ b/tool/CommandIp.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2014 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,13 +32,13 @@ class CommandIp: public: CommandIp(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: - void parseMac(unsigned char [6], const string &); - void parseIpv4Prefix(ec_ioctl_eoe_ip_t *, const string &); - void resolveIpv4(struct in_addr *, const string &); + void parseMac(unsigned char [6], const std::string &); + void parseIpv4Prefix(ec_ioctl_eoe_ip_t *, const std::string &); + void resolveIpv4(struct in_addr *, const std::string &); }; /****************************************************************************/ diff --git a/tool/CommandMaster.cpp b/tool/CommandMaster.cpp index 500706fd..f490774f 100644 --- a/tool/CommandMaster.cpp +++ b/tool/CommandMaster.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,15 +19,26 @@ * ****************************************************************************/ -#include -#include -using namespace std; - #include "CommandMaster.h" + #include "MasterDevice.h" +#include +#include + #define MAX_TIME_STR_SIZE 50 +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::dec; +using std::setw; +using std::setfill; +using std::setprecision; +using std::fixed; + /****************************************************************************/ CommandMaster::CommandMaster(): @@ -46,7 +57,8 @@ string CommandMaster::helpString(const string &binaryBaseName) const << getBriefDescription() << endl << endl << "Command-specific options:" << endl - << " --master -m Master indices. A comma-separated" << endl + << " --master -m Master indices. A comma-separated" + << endl << " list with ranges is supported." << endl << " Example: 1,4,5,7-9. Default: - (all)." << endl << endl @@ -59,7 +71,7 @@ string CommandMaster::helpString(const string &binaryBaseName) const void CommandMaster::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; ec_ioctl_master_t data; stringstream err; unsigned int dev_idx, j; @@ -72,7 +84,7 @@ void CommandMaster::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); mi != masterIndices.end(); mi++) { diff --git a/tool/CommandMaster.h b/tool/CommandMaster.h index d807f417..a9860c0f 100644 --- a/tool/CommandMaster.h +++ b/tool/CommandMaster.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandMaster: public: CommandMaster(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); private: diff --git a/tool/CommandPdos.cpp b/tool/CommandPdos.cpp index bbb8cdd5..0fa74ccc 100644 --- a/tool/CommandPdos.cpp +++ b/tool/CommandPdos.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,13 +19,23 @@ * ****************************************************************************/ +#include "CommandPdos.h" + +#include "MasterDevice.h" + +#include + #include #include -#include -using namespace std; -#include "CommandPdos.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::setfill; +using std::setw; +using std::dec; /****************************************************************************/ @@ -91,7 +101,7 @@ string CommandPdos::helpString(const string &binaryBaseName) const void CommandPdos::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; SlaveList slaves; SlaveList::const_iterator si; bool showHeader, multiMaster; diff --git a/tool/CommandPdos.h b/tool/CommandPdos.h index 072ba0cb..b2575970 100644 --- a/tool/CommandPdos.h +++ b/tool/CommandPdos.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandPdos: public: CommandPdos(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandRegRead.cpp b/tool/CommandRegRead.cpp index c3595389..d970cbbb 100644 --- a/tool/CommandRegRead.cpp +++ b/tool/CommandRegRead.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,18 @@ * ****************************************************************************/ +#include "CommandRegRead.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandRegRead.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ios; +using std::cout; /****************************************************************************/ diff --git a/tool/CommandRegRead.h b/tool/CommandRegRead.h index 01321363..c0b6c1e7 100644 --- a/tool/CommandRegRead.h +++ b/tool/CommandRegRead.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -34,7 +34,7 @@ class CommandRegRead: public: CommandRegRead(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandRegWrite.cpp b/tool/CommandRegWrite.cpp index 5a1e9d5c..d00040fa 100644 --- a/tool/CommandRegWrite.cpp +++ b/tool/CommandRegWrite.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2012 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,14 +19,24 @@ * ****************************************************************************/ +#include "CommandRegWrite.h" + +#include "sii_crc.h" +#include "MasterDevice.h" + #include #include #include -using namespace std; -#include "CommandRegWrite.h" -#include "sii_crc.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::ostringstream; +using std::endl; +using std::ios; +using std::ifstream; +using std::istream; +using std::cin; +using std::cerr; /****************************************************************************/ diff --git a/tool/CommandRegWrite.h b/tool/CommandRegWrite.h index c70c41c3..857e907c 100644 --- a/tool/CommandRegWrite.h +++ b/tool/CommandRegWrite.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -34,11 +34,11 @@ class CommandRegWrite: public: CommandRegWrite(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); private: - void loadRegData(ec_ioctl_slave_reg_t *, const istream &); + void loadRegData(ec_ioctl_slave_reg_t *, const std::istream &); }; /****************************************************************************/ diff --git a/tool/CommandRescan.cpp b/tool/CommandRescan.cpp index a1cd8807..f3f083c8 100644 --- a/tool/CommandRescan.cpp +++ b/tool/CommandRescan.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,12 +21,16 @@ * ****************************************************************************/ +#include "CommandRescan.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandRescan.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; /****************************************************************************/ @@ -56,7 +60,7 @@ string CommandRescan::helpString(const string &binaryBaseName) const void CommandRescan::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; if (args.size() != 0) { stringstream err; @@ -64,7 +68,7 @@ void CommandRescan::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); mi != masterIndices.end(); mi++) { diff --git a/tool/CommandRescan.h b/tool/CommandRescan.h index 540bcc6f..2ebd22aa 100644 --- a/tool/CommandRescan.h +++ b/tool/CommandRescan.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandRescan: public: CommandRescan(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandSdos.cpp b/tool/CommandSdos.cpp index 5a472eb7..24b5ce06 100644 --- a/tool/CommandSdos.cpp +++ b/tool/CommandSdos.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,21 @@ * ****************************************************************************/ +#include "CommandSdos.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandSdos.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::dec; +using std::setfill; +using std::setw; /****************************************************************************/ @@ -81,7 +90,7 @@ string CommandSdos::helpString(const string &binaryBaseName) const void CommandSdos::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; SlaveList slaves; SlaveList::const_iterator si; bool showHeader, multiMaster; @@ -92,7 +101,7 @@ void CommandSdos::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); multiMaster = masterIndices.size() > 1; MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); @@ -151,7 +160,8 @@ void CommandSdos::listSlaveSdos( << (entry.read_access[EC_SDO_ENTRY_ACCESS_PREOP] ? "r" : "-") << (entry.write_access[EC_SDO_ENTRY_ACCESS_PREOP] ? "w" : "-") << (entry.read_access[EC_SDO_ENTRY_ACCESS_SAFEOP] ? "r" : "-") - << (entry.write_access[EC_SDO_ENTRY_ACCESS_SAFEOP] ? "w" : "-") + << (entry.write_access[EC_SDO_ENTRY_ACCESS_SAFEOP] ? + "w" : "-") << (entry.read_access[EC_SDO_ENTRY_ACCESS_OP] ? "r" : "-") << (entry.write_access[EC_SDO_ENTRY_ACCESS_OP] ? "w" : "-") << ", "; diff --git a/tool/CommandSdos.h b/tool/CommandSdos.h index 313f07e4..d5543fac 100644 --- a/tool/CommandSdos.h +++ b/tool/CommandSdos.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandSdos: public: CommandSdos(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSiiCaching.cpp b/tool/CommandSiiCaching.cpp index b3779d69..aa64e185 100644 --- a/tool/CommandSiiCaching.cpp +++ b/tool/CommandSiiCaching.cpp @@ -1,5 +1,6 @@ /***************************************************************************** * + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -18,14 +19,24 @@ * ****************************************************************************/ +#include "CommandSiiCaching.h" + +#include "MasterDevice.h" + +#include + #include #include #include -#include -using namespace std; -#include "CommandSiiCaching.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::dec; +using std::setfill; +using std::setw; /****************************************************************************/ @@ -44,9 +55,11 @@ string CommandCache::helpString(const string &binaryBaseName) const << endl << getBriefDescription() << endl << endl - << "This command configures cache level to speed up scanning process" << endl + << "This command configures cache level to speed up scanning process" + << endl + << endl + << "Caching fields are specified as a decimal number that is a" << endl - << "Caching fields are specified as a decimal number that is a" << endl << "combination of the following flags:" << endl << " 0 - Disable SII caching" << endl << " 1 - Use vendor ID" << endl diff --git a/tool/CommandSiiCaching.h b/tool/CommandSiiCaching.h index 8ccc4404..da181b73 100644 --- a/tool/CommandSiiCaching.h +++ b/tool/CommandSiiCaching.h @@ -1,4 +1,6 @@ /***************************************************************************** + * + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -30,7 +32,7 @@ class CommandCache: public: CommandCache(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandSiiRead.cpp b/tool/CommandSiiRead.cpp index f7b474e5..5e6f23a2 100644 --- a/tool/CommandSiiRead.cpp +++ b/tool/CommandSiiRead.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,24 @@ * ****************************************************************************/ +#include "CommandSiiRead.h" + +#include "MasterDevice.h" + #include #include -using namespace std; +#include -#include "CommandSiiRead.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::dec; +using std::flush; +using std::setfill; +using std::setw; +using std::min; /****************************************************************************/ diff --git a/tool/CommandSiiRead.h b/tool/CommandSiiRead.h index db642a35..0aa813f3 100644 --- a/tool/CommandSiiRead.h +++ b/tool/CommandSiiRead.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandSiiRead: public: CommandSiiRead(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandSiiWrite.cpp b/tool/CommandSiiWrite.cpp index 0c7adb08..66ae0b5d 100644 --- a/tool/CommandSiiWrite.cpp +++ b/tool/CommandSiiWrite.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,14 +19,26 @@ * ****************************************************************************/ +#include "CommandSiiWrite.h" + +#include "sii_crc.h" +#include "MasterDevice.h" + #include #include #include -using namespace std; -#include "CommandSiiWrite.h" -#include "sii_crc.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::ostringstream; +using std::endl; +using std::ifstream; +using std::istream; +using std::cin; +using std::cerr; +using std::hex; +using std::setfill; +using std::setw; /****************************************************************************/ diff --git a/tool/CommandSiiWrite.h b/tool/CommandSiiWrite.h index c475e07c..adc648a0 100644 --- a/tool/CommandSiiWrite.h +++ b/tool/CommandSiiWrite.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,11 +32,11 @@ class CommandSiiWrite: public: CommandSiiWrite(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: - void loadSiiData(ec_ioctl_slave_sii_t *, const istream &); + void loadSiiData(ec_ioctl_slave_sii_t *, const std::istream &); void checkSiiData(const ec_ioctl_slave_sii_t *data); }; diff --git a/tool/CommandSlaves.cpp b/tool/CommandSlaves.cpp index 31ecf47d..baba6d01 100644 --- a/tool/CommandSlaves.cpp +++ b/tool/CommandSlaves.cpp @@ -19,14 +19,27 @@ * ****************************************************************************/ +#include "CommandSlaves.h" + +#include "MasterDevice.h" + +#include + #include #include #include -#include -using namespace std; -#include "CommandSlaves.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::list; +using std::hex; +using std::dec; +using std::setfill; +using std::setw; +using std::left; +using std::right; /****************************************************************************/ @@ -100,7 +113,7 @@ string CommandSlaves::helpString(const string &binaryBaseName) const void CommandSlaves::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; SlaveList slaves; bool doIndent; @@ -110,7 +123,7 @@ void CommandSlaves::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); doIndent = masterIndices.size() > 1; MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); diff --git a/tool/CommandSlaves.h b/tool/CommandSlaves.h index c3eb45df..74acbc2e 100644 --- a/tool/CommandSlaves.h +++ b/tool/CommandSlaves.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,24 +32,24 @@ class CommandSlaves: public: CommandSlaves(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: struct Info { - string pos; - string alias; - string relPos; - string state; - string flag; - string name; + std::string pos; + std::string alias; + std::string relPos; + std::string state; + std::string flag; + std::string name; unsigned int device; }; void listSlaves(MasterDevice &, const SlaveList &, bool); void showSlaves(MasterDevice &, const SlaveList &); - static bool slaveInList( const ec_ioctl_slave_t &, const SlaveList &); + static bool slaveInList(const ec_ioctl_slave_t &, const SlaveList &); }; /****************************************************************************/ diff --git a/tool/CommandSoeRead.cpp b/tool/CommandSoeRead.cpp index de30e83e..b4ff14a3 100644 --- a/tool/CommandSoeRead.cpp +++ b/tool/CommandSoeRead.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,19 @@ * ****************************************************************************/ +#include "CommandSoeRead.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandSoeRead.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ios; +using std::cout; +using std::runtime_error; /****************************************************************************/ diff --git a/tool/CommandSoeRead.h b/tool/CommandSoeRead.h index 6cf43796..8782bd6a 100644 --- a/tool/CommandSoeRead.h +++ b/tool/CommandSoeRead.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -34,7 +34,7 @@ class CommandSoeRead: public: CommandSoeRead(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandSoeWrite.cpp b/tool/CommandSoeWrite.cpp index a227d470..a96312e6 100644 --- a/tool/CommandSoeWrite.cpp +++ b/tool/CommandSoeWrite.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,18 @@ * ****************************************************************************/ +#include "CommandSoeWrite.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandSoeWrite.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ios; +using std::runtime_error; /****************************************************************************/ @@ -58,11 +64,11 @@ string CommandSoeWrite::helpString(const string &binaryBaseName) const << " Bit 11 - 0: Data block number" << endl << " or a string like 'P-0-150'." << endl << " VALUE is the value to write (see below)." << endl - << endl - << "The VALUE argument is interpreted as the given data type" << endl - << "(--type is mandatory) and written to the selected slave." << endl << endl - << typeInfo() + << "The VALUE argument is interpreted as the given data type" << endl + << "(--type is mandatory) and written to the selected slave." << endl + << endl + << typeInfo() << endl << "Command-specific options:" << endl << " --alias -a " << endl diff --git a/tool/CommandSoeWrite.h b/tool/CommandSoeWrite.h index 5c754b31..ef677fdd 100644 --- a/tool/CommandSoeWrite.h +++ b/tool/CommandSoeWrite.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -34,7 +34,7 @@ class CommandSoeWrite: public: CommandSoeWrite(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandStates.cpp b/tool/CommandStates.cpp index 2cea1539..fb6b8485 100644 --- a/tool/CommandStates.cpp +++ b/tool/CommandStates.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,17 @@ * ****************************************************************************/ +#include "CommandStates.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandStates.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::transform; /****************************************************************************/ @@ -44,7 +49,8 @@ string CommandStates::helpString(const string &binaryBaseName) const << getBriefDescription() << endl << endl << "Arguments:" << endl - << " STATE can be 'INIT', 'PREOP', 'BOOT', 'SAFEOP', or 'OP'." << endl + << " STATE can be 'INIT', 'PREOP', 'BOOT', 'SAFEOP', or 'OP'." + << endl << endl << "Command-specific options:" << endl << " --alias -a " << endl @@ -60,7 +66,7 @@ string CommandStates::helpString(const string &binaryBaseName) const void CommandStates::execute(const StringVector &args) { - MasterIndexList masterIndices; + MasterIndexList masterIndices; SlaveList slaves; SlaveList::const_iterator si; stringstream err; @@ -74,7 +80,8 @@ void CommandStates::execute(const StringVector &args) stateStr = args[0]; transform(stateStr.begin(), stateStr.end(), - stateStr.begin(), (int (*) (int)) std::toupper); + stateStr.begin(), + (int (*) (int)) std::toupper); // NOLINT(whitespace/parens) if (stateStr == "INIT") { state = 0x01; @@ -91,7 +98,7 @@ void CommandStates::execute(const StringVector &args) throwInvalidUsageException(err); } - masterIndices = getMasterIndices(); + masterIndices = getMasterIndices(); MasterIndexList::const_iterator mi; for (mi = masterIndices.begin(); mi != masterIndices.end(); mi++) { diff --git a/tool/CommandStates.h b/tool/CommandStates.h index a673d115..abe1c72c 100644 --- a/tool/CommandStates.h +++ b/tool/CommandStates.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandStates: public: CommandStates(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandUpload.cpp b/tool/CommandUpload.cpp index fbae3924..965da4a4 100644 --- a/tool/CommandUpload.cpp +++ b/tool/CommandUpload.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,21 @@ * ****************************************************************************/ +#include "CommandUpload.h" + +#include "MasterDevice.h" + #include #include -using namespace std; -#include "CommandUpload.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::ios; +using std::cout; +using std::hex; +using std::setfill; +using std::setw; /****************************************************************************/ diff --git a/tool/CommandUpload.h b/tool/CommandUpload.h index 8ebf66df..6f918993 100644 --- a/tool/CommandUpload.h +++ b/tool/CommandUpload.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandUpload: public: CommandUpload(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/CommandVersion.cpp b/tool/CommandVersion.cpp index b651de42..c6195e96 100644 --- a/tool/CommandVersion.cpp +++ b/tool/CommandVersion.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,11 +19,15 @@ * ****************************************************************************/ -#include -using namespace std; - #include "CommandVersion.h" +#include + +using std::string; +using std::stringstream; +using std::endl; +using std::cout; + /****************************************************************************/ CommandVersion::CommandVersion(): diff --git a/tool/CommandVersion.h b/tool/CommandVersion.h index f1552d2d..da2433de 100644 --- a/tool/CommandVersion.h +++ b/tool/CommandVersion.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandVersion: public: CommandVersion(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); }; diff --git a/tool/CommandXml.cpp b/tool/CommandXml.cpp index afe45599..c2a6b89d 100644 --- a/tool/CommandXml.cpp +++ b/tool/CommandXml.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2014 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,13 +19,23 @@ * ****************************************************************************/ +#include "CommandXml.h" + +#include "MasterDevice.h" + +#include + #include #include -#include -using namespace std; -#include "CommandXml.h" -#include "MasterDevice.h" +using std::string; +using std::stringstream; +using std::endl; +using std::cout; +using std::hex; +using std::dec; +using std::setfill; +using std::setw; /****************************************************************************/ diff --git a/tool/CommandXml.h b/tool/CommandXml.h index 09d806dc..37428e56 100644 --- a/tool/CommandXml.h +++ b/tool/CommandXml.h @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -32,7 +32,7 @@ class CommandXml: public: CommandXml(); - string helpString(const string &) const; + std::string helpString(const std::string &) const; void execute(const StringVector &); protected: diff --git a/tool/DataTypeHandler.cpp b/tool/DataTypeHandler.cpp index 9f0ebc62..fe37de28 100644 --- a/tool/DataTypeHandler.cpp +++ b/tool/DataTypeHandler.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2022 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -21,18 +21,31 @@ #define DEBUG 0 -#if DEBUG -#include -#endif - -#include -#include -using namespace std; - #include "DataTypeHandler.h" #include "ecrt.h" +#if DEBUG +#include +#endif +#include +#include + +using std::string; +using std::stringstream; +using std::ostream; +using std::endl; +using std::flush; +using std::ios; +using std::runtime_error; +using std::hex; +using std::dec; +using std::setw; +using std::setfill; +#if DEBUG +using std::cerr; +#endif + /****************************************************************************/ DataTypeHandler::DataTypeHandler() @@ -184,7 +197,8 @@ size_t DataTypeHandler::interpretAsType( << dataSize << " > " << targetSize << ")"; throw SizeException(err.str()); } - str >> (char *) target; + //str >> (char *) target; + str.read((char *) target, dataSize + 1); // including \0 FIXME break; case 0x0011: // double { diff --git a/tool/MasterDevice.cpp b/tool/MasterDevice.cpp index 7876f736..161cb163 100644 --- a/tool/MasterDevice.cpp +++ b/tool/MasterDevice.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2024 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,6 +19,8 @@ * ****************************************************************************/ +#include "MasterDevice.h" + #include #include #include @@ -28,9 +30,9 @@ #include #include -using namespace std; -#include "MasterDevice.h" +using std::stringstream; +using std::endl; /****************************************************************************/ diff --git a/tool/NumberListParser.cpp b/tool/NumberListParser.cpp index c72d6d59..aa557cd3 100644 --- a/tool/NumberListParser.cpp +++ b/tool/NumberListParser.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,12 +19,17 @@ * ****************************************************************************/ +#include "NumberListParser.h" + #include + #include #include -using namespace std; -#include "NumberListParser.h" +using std::string; +using std::stringstream; +using std::endl; +using std::runtime_error; /****************************************************************************/ diff --git a/tool/NumberListParser.h b/tool/NumberListParser.h index 15ebdccf..08a9e5e2 100644 --- a/tool/NumberListParser.h +++ b/tool/NumberListParser.h @@ -29,7 +29,7 @@ class NumberListParser NumberListParser(); virtual ~NumberListParser(); - typedef list List; + typedef std::list List; List parse(const char *); diff --git a/tool/SoeCommand.cpp b/tool/SoeCommand.cpp index 278dba7c..1dbb9bed 100644 --- a/tool/SoeCommand.cpp +++ b/tool/SoeCommand.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,11 +19,19 @@ * ****************************************************************************/ -#include -using namespace std; - #include "SoeCommand.h" -#include "../master/soe_errors.c" + +#include "../master/soe_errors.c" // NOLINT(build/include) + +#include + +using std::string; +using std::stringstream; +using std::ios; +using std::runtime_error; +using std::hex; +using std::setfill; +using std::setw; /****************************************************************************/ @@ -111,19 +119,19 @@ string SoeCommand::outputIdn(uint16_t idn) std::string SoeCommand::errorMsg(uint16_t code) { const ec_code_msg_t *error_msg; - stringstream str; + stringstream str; - str << "0x" << hex << setfill('0') << setw(4) << code << ": "; + str << "0x" << hex << setfill('0') << setw(4) << code << ": "; for (error_msg = soe_error_codes; error_msg->code; error_msg++) { if (error_msg->code == code) { - str << error_msg->message; - return str.str(); + str << error_msg->message; + return str.str(); } } - str << "(Unknown)"; - return str.str(); + str << "(Unknown)"; + return str.str(); } /****************************************************************************/ diff --git a/tool/main.cpp b/tool/main.cpp index 6c3fdfc2..23105367 100644 --- a/tool/main.cpp +++ b/tool/main.cpp @@ -1,6 +1,6 @@ /***************************************************************************** * - * Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH + * Copyright (C) 2006-2026 Florian Pose, Ingenieurgemeinschaft IgH * * This file is part of the IgH EtherCAT Master. * @@ -19,14 +19,6 @@ * ****************************************************************************/ -#include -#include // basename() -#include - -#include -#include -using namespace std; - #include "CommandAlias.h" #include "CommandCStruct.h" #include "CommandConfig.h" @@ -63,6 +55,22 @@ using namespace std; #include "MasterDevice.h" +#include +#include // basename() +#include + +#include +#include + +using std::string; +using std::stringstream; +using std::endl; +using std::list; +using std::cout; +using std::cerr; +using std::left; +using std::setw; + /****************************************************************************/ typedef list CommandList; From 71afaff49d9ab08b438489e168ec5c216c78ffd7 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 11 Aug 2026 15:09:09 +0200 Subject: [PATCH 3/4] Fixed cpplint warnings. --- tool/Command.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tool/Command.h b/tool/Command.h index fdb92edc..247ed235 100644 --- a/tool/Command.h +++ b/tool/Command.h @@ -41,8 +41,8 @@ class InvalidUsageException: protected: /** Constructor with stringstream parameter. */ InvalidUsageException( - const std::stringstream &s /**< Message. */ - ): std::runtime_error(s.str()) {} + const std::stringstream &s): /**< Message. */ + std::runtime_error(s.str()) {} }; /****************************************************************************/ @@ -55,13 +55,13 @@ class CommandException: protected: /** Constructor with char * parameter. */ CommandException( - const std::string &msg /**< Message. */ - ): std::runtime_error(msg) {} + const std::string &msg): /**< Message. */ + std::runtime_error(msg) {} /** Constructor with stringstream parameter. */ CommandException( - const std::stringstream &s /**< Message. */ - ): std::runtime_error(s.str()) {} + const std::stringstream &s): /**< Message. */ + std::runtime_error(s.str()) {} }; /****************************************************************************/ @@ -78,7 +78,7 @@ class Command typedef std::list MasterIndexList; void setMasters(const std::string &); MasterIndexList getMasterIndices() const; - unsigned int getSingleMasterIndex() const; + unsigned int getSingleMasterIndex() const; enum Verbosity { Quiet, From 345591789480807c5c2be00b7659399d729b329e Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Tue, 11 Aug 2026 15:15:16 +0200 Subject: [PATCH 4/4] Fixed cpplint warnings. --- tool/MasterDevice.h | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tool/MasterDevice.h b/tool/MasterDevice.h index 8762f2bf..2da3e055 100644 --- a/tool/MasterDevice.h +++ b/tool/MasterDevice.h @@ -38,13 +38,13 @@ class MasterDeviceException: protected: /** Constructor with string parameter. */ MasterDeviceException( - const std::string &s /**< Message. */ - ): std::runtime_error(s) {} + const std::string &s): /**< Message. */ + std::runtime_error(s) {} /** Constructor with stringstream parameter. */ MasterDeviceException( - const std::stringstream &s /**< Message. */ - ): std::runtime_error(s.str()) {} + const std::stringstream &s): /**< Message. */ + std::runtime_error(s.str()) {} }; /****************************************************************************/ @@ -59,7 +59,7 @@ class MasterDeviceSdoAbortException: protected: /** Constructor with abort code parameter. */ - MasterDeviceSdoAbortException(uint32_t code): + explicit MasterDeviceSdoAbortException(uint32_t code): MasterDeviceException("SDO transfer aborted.") { abortCode = code; }; @@ -77,7 +77,7 @@ class MasterDeviceSoeException: protected: /** Constructor with error code parameter. */ - MasterDeviceSoeException(uint16_t code): + explicit MasterDeviceSoeException(uint16_t code): MasterDeviceException("SoE transfer aborted.") { errorCode = code; }; @@ -96,7 +96,7 @@ class MasterDeviceEoeException: protected: /** Constructor with error code parameter. */ - MasterDeviceEoeException(uint16_t result): + explicit MasterDeviceEoeException(uint16_t result): MasterDeviceException("EoE set IP parameter failed."), result(result) {}; }; @@ -107,7 +107,7 @@ class MasterDeviceEoeException: class MasterDevice { public: - MasterDevice(unsigned int = 0U); + explicit MasterDevice(unsigned int = 0U); ~MasterDevice(); void setIndex(unsigned int); @@ -125,8 +125,10 @@ class MasterDevice uint16_t); void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int, uint8_t, uint16_t, uint8_t); - void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int); - void getConfigIdn(ec_ioctl_config_idn_t *, unsigned int, unsigned int); + void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, + unsigned int); + void getConfigIdn(ec_ioctl_config_idn_t *, unsigned int, + unsigned int); void getConfigFlag(ec_ioctl_config_flag_t *, unsigned int, unsigned int); void getDomain(ec_ioctl_domain_t *, unsigned int); @@ -139,7 +141,8 @@ class MasterDevice void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t, uint8_t, uint8_t); void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t); - void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t); + void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, + uint8_t); void readSii(ec_ioctl_slave_sii_t *); void writeSii(ec_ioctl_slave_sii_t *); void readReg(ec_ioctl_slave_reg_t *);