From 434fab9586aa787ab112864b5d133d54b7e9cfaf Mon Sep 17 00:00:00 2001 From: Florian Pose <fp@igh-essen.com> Date: Mon, 28 Jul 2008 14:06:03 +0000 Subject: [PATCH] Added 'ethercat version' command. --- TODO | 6 +++--- tool/CommandVersion.cpp | 39 +++++++++++++++++++++++++++++++++++++++ tool/CommandVersion.h | 26 ++++++++++++++++++++++++++ tool/Makefile.am | 11 +++++++++-- tool/main.cpp | 8 +++++--- 5 files changed, 82 insertions(+), 8 deletions(-) create mode 100644 tool/CommandVersion.cpp create mode 100644 tool/CommandVersion.h diff --git a/TODO b/TODO index 30d59b8e..c3db2d15 100644 --- a/TODO +++ b/TODO @@ -14,10 +14,7 @@ Version 1.4.0: * Get original driver for r8169. * Race in jiffies frame timeout? * ethercat tool: - - Data type abbreviations. - - Add a -n (numeric) switch. - Check for options, remove global variables. - - Add 'etherlab version'. Future issues: @@ -36,6 +33,9 @@ Future issues: * Interface/buffers for asynchronous domain IO. * Make scanning and configuration run parallel (each). * File access over EtherCAT (FoE). +* ethercat tool: + - Data type abbreviations. + - Add a -n (numeric) switch. Smaller issues: diff --git a/tool/CommandVersion.cpp b/tool/CommandVersion.cpp new file mode 100644 index 00000000..eae78696 --- /dev/null +++ b/tool/CommandVersion.cpp @@ -0,0 +1,39 @@ +/***************************************************************************** + * + * $Id$ + * + ****************************************************************************/ + +#include <iostream> +using namespace std; + +#include "CommandVersion.h" + +/*****************************************************************************/ + +CommandVersion::CommandVersion(): + Command("version", "Show version information.") +{ +} + +/****************************************************************************/ + +string CommandVersion::helpString() const +{ + stringstream str; + + str << getName() << " [OPTIONS]" << endl + << endl + << getBriefDescription() << endl; + + return str.str(); +} + +/****************************************************************************/ + +void CommandVersion::execute(MasterDevice &m, const StringVector &args) +{ + cout << "IgH EtherCAT master " << EC_MASTER_VERSION << endl; +} + +/*****************************************************************************/ diff --git a/tool/CommandVersion.h b/tool/CommandVersion.h new file mode 100644 index 00000000..b056faa0 --- /dev/null +++ b/tool/CommandVersion.h @@ -0,0 +1,26 @@ +/***************************************************************************** + * + * $Id$ + * + ****************************************************************************/ + +#ifndef __COMMANDVERSION_H__ +#define __COMMANDVERSION_H__ + +#include "Command.h" + +/****************************************************************************/ + +class CommandVersion: + public Command +{ + public: + CommandVersion(); + + string helpString() const; + void execute(MasterDevice &, const StringVector &); +}; + +/****************************************************************************/ + +#endif diff --git a/tool/Makefile.am b/tool/Makefile.am index eb49fdb0..5cff1b27 100644 --- a/tool/Makefile.am +++ b/tool/Makefile.am @@ -37,9 +37,9 @@ bin_PROGRAMS = ethercat ethercat_SOURCES = \ MasterDevice.cpp MasterDevice.h \ - Command.cpp \ CommandAlias.cpp \ CommandConfig.cpp \ + Command.cpp \ CommandData.cpp \ CommandDebug.cpp \ CommandDomains.cpp \ @@ -52,11 +52,18 @@ ethercat_SOURCES = \ CommandSlaves.cpp \ CommandStates.cpp \ CommandUpload.cpp \ + CommandVersion.cpp \ CommandXml.cpp \ coe_datatypes.cpp \ sii_crc.cpp \ main.cpp -ethercat_CXXFLAGS = -I../master -Wall +REV = `if test -s $(srcdir)/../svnrevision; then \ + cat $(srcdir)/../svnrevision; \ + else \ + svnversion $(srcdir)/.. 2>/dev/null || echo "unknown"; \ + fi` + +ethercat_CXXFLAGS = -I../master -Wall -DSVNREV=$(REV) #------------------------------------------------------------------------------ diff --git a/tool/main.cpp b/tool/main.cpp index f0973468..b43e17de 100644 --- a/tool/main.cpp +++ b/tool/main.cpp @@ -16,15 +16,16 @@ using namespace std; #include "CommandData.h" #include "CommandDebug.h" #include "CommandDomains.h" +#include "CommandDownload.h" #include "CommandMaster.h" #include "CommandPdos.h" #include "CommandSdos.h" -#include "CommandDownload.h" -#include "CommandUpload.h" -#include "CommandSlaves.h" #include "CommandSiiRead.h" #include "CommandSiiWrite.h" +#include "CommandSlaves.h" #include "CommandStates.h" +#include "CommandUpload.h" +#include "CommandVersion.h" #include "CommandXml.h" /*****************************************************************************/ @@ -268,6 +269,7 @@ int main(int argc, char **argv) commandList.push_back(new CommandSlaves()); commandList.push_back(new CommandStates()); commandList.push_back(new CommandUpload()); + commandList.push_back(new CommandVersion()); commandList.push_back(new CommandXml()); getOptions(argc, argv); -- GitLab