Avoided using namespace in tool.

This commit is contained in:
Florian Pose
2026-08-11 15:03:59 +02:00
parent 305d13544d
commit 1e61ca80fa
65 changed files with 580 additions and 290 deletions
+5
View File
@@ -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
+15 -12
View File
@@ -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 <map>
using namespace std;
#include "Command.h"
#include "MasterDevice.h"
#include "NumberListParser.h"
#include "MasterDevice.h"
#include <map>
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<ec_ioctl_slave_t> aliasSlaves;
std::vector<ec_ioctl_slave_t> 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;
+11 -6
View File
@@ -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 <iostream>
#include <iomanip>
#include <sstream>
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] << "'!";
+2 -2
View File
@@ -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:
+15 -5
View File
@@ -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 <string.h>
#include <iostream>
#include <iomanip>
#include <string.h>
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;
/****************************************************************************/
+2 -2
View File
@@ -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:
+20 -8
View File
@@ -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 <arpa/inet.h>
#include <list>
#include <iostream>
#include <iomanip>
#include <sstream>
using namespace std;
#include <arpa/inet.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;
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<Info> InfoList;
typedef std::list<Info> 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();
+14 -8
View File
@@ -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 <iostream>
#include <iomanip>
#include <algorithm>
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);
+2 -2
View File
@@ -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 &);
};
+9 -4
View File
@@ -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 <iostream>
using namespace std;
#include "CommandData.h"
#include "MasterDevice.h"
#include <iostream>
using std::string;
using std::stringstream;
using std::endl;
using std::cout;
/****************************************************************************/
CommandData::CommandData():
+2 -2
View File
@@ -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:
+11 -7
View File
@@ -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 <sstream>
#include <iomanip>
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++) {
+2 -2
View File
@@ -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 &);
};
+17 -7
View File
@@ -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 <iostream>
#include <iomanip>
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();
+2 -2
View File
@@ -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:
+14 -6
View File
@@ -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 <iostream>
#include <iomanip>
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()) {
+2 -2
View File
@@ -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:
+15 -7
View File
@@ -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 <string.h>
#include <iostream>
#include <iomanip>
#include <list>
#include <string.h>
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;
+2 -2
View File
@@ -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 &);
};
+15 -7
View File
@@ -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 <string.h>
#include <iostream>
#include <iomanip>
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;
+2 -2
View File
@@ -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 &);
};
+17 -8
View File
@@ -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 <libgen.h> // basename()
#include <string.h>
#include <iostream>
#include <iomanip>
#include <fstream>
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();
+3 -3
View File
@@ -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 &);
};
/****************************************************************************/
+14 -6
View File
@@ -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 <iostream>
#include <map>
#include <algorithm>
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) {
+2 -2
View File
@@ -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 &);
};
+9 -4
View File
@@ -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 <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <iostream>
#include <algorithm>
using namespace std;
#include "CommandIp.h"
#include "MasterDevice.h"
using std::string;
using std::stringstream;
using std::endl;
using std::hex;
/****************************************************************************/
+5 -5
View File
@@ -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 &);
};
/****************************************************************************/
+20 -8
View File
@@ -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 <iostream>
#include <iomanip>
using namespace std;
#include "CommandMaster.h"
#include "MasterDevice.h"
#include <iostream>
#include <iomanip>
#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 <indices> Master indices. A comma-separated" << endl
<< " --master -m <indices> 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++) {
+2 -2
View File
@@ -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:
+16 -6
View File
@@ -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 <cstring>
#include <iostream>
#include <iomanip>
#include <cstring>
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;
+2 -2
View File
@@ -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:
+10 -4
View File
@@ -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 <iostream>
#include <iomanip>
using namespace std;
#include "CommandRegRead.h"
#include "MasterDevice.h"
using std::string;
using std::stringstream;
using std::endl;
using std::ios;
using std::cout;
/****************************************************************************/
+2 -2
View File
@@ -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 &);
};
+15 -5
View File
@@ -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 <iostream>
#include <iomanip>
#include <fstream>
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;
/****************************************************************************/
+3 -3
View File
@@ -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 &);
};
/****************************************************************************/
+10 -6
View File
@@ -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 <sstream>
#include <iomanip>
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++) {
+2 -2
View File
@@ -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 &);
};
+17 -7
View File
@@ -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 <iostream>
#include <iomanip>
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" : "-")
<< ", ";
+2 -2
View File
@@ -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:
+19 -6
View File
@@ -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 <cstdlib>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdlib>
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
+3 -1
View File
@@ -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 &);
};
+16 -4
View File
@@ -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 <iostream>
#include <iomanip>
using namespace std;
#include <algorithm>
#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;
/****************************************************************************/
+2 -2
View File
@@ -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:
+17 -5
View File
@@ -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 <iostream>
#include <iomanip>
#include <fstream>
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;
/****************************************************************************/
+3 -3
View File
@@ -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);
};
+19 -6
View File
@@ -19,14 +19,27 @@
*
****************************************************************************/
#include "CommandSlaves.h"
#include "MasterDevice.h"
#include <string.h>
#include <iostream>
#include <iomanip>
#include <list>
#include <string.h>
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();
+9 -9
View File
@@ -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 &);
};
/****************************************************************************/
+11 -4
View File
@@ -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 <iostream>
#include <iomanip>
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;
/****************************************************************************/
+2 -2
View File
@@ -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 &);
};
+14 -8
View File
@@ -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 <iostream>
#include <iomanip>
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 <alias>" << endl

Some files were not shown because too many files have changed in this diff Show More