tool/main.cpp
changeset 1335 09c6fce1ae45
parent 1222 7348d6abb6cb
child 1363 11c0b2caa253
equal deleted inserted replaced
1334:da3d22a27500 1335:09c6fce1ae45
    16 #include "CommandConfig.h"
    16 #include "CommandConfig.h"
    17 #include "CommandData.h"
    17 #include "CommandData.h"
    18 #include "CommandDebug.h"
    18 #include "CommandDebug.h"
    19 #include "CommandDomains.h"
    19 #include "CommandDomains.h"
    20 #include "CommandDownload.h"
    20 #include "CommandDownload.h"
       
    21 #include "CommandFoeRead.h"
       
    22 #include "CommandFoeWrite.h"
    21 #include "CommandMaster.h"
    23 #include "CommandMaster.h"
    22 #include "CommandPdos.h"
    24 #include "CommandPdos.h"
    23 #include "CommandPhyRead.h"
    25 #include "CommandPhyRead.h"
    24 #include "CommandPhyWrite.h"
    26 #include "CommandPhyWrite.h"
    25 #include "CommandSdos.h"
    27 #include "CommandSdos.h"
    49 int domainIndex = -1;
    51 int domainIndex = -1;
    50 string dataTypeStr;
    52 string dataTypeStr;
    51 Command::Verbosity verbosity = Command::Normal;
    53 Command::Verbosity verbosity = Command::Normal;
    52 bool force = false;
    54 bool force = false;
    53 bool helpRequested = false;
    55 bool helpRequested = false;
       
    56 string outputFile;
    54 
    57 
    55 /*****************************************************************************/
    58 /*****************************************************************************/
    56 
    59 
    57 string usage()
    60 string usage()
    58 {
    61 {
   101 {
   104 {
   102     int c, argCount;
   105     int c, argCount;
   103     stringstream str;
   106     stringstream str;
   104 
   107 
   105     static struct option longOptions[] = {
   108     static struct option longOptions[] = {
   106         //name,      has_arg,           flag, val
   109         //name,         has_arg,           flag, val
   107         {"master",   required_argument, NULL, 'm'},
   110         {"master",      required_argument, NULL, 'm'},
   108         {"alias",    required_argument, NULL, 'a'},
   111         {"alias",       required_argument, NULL, 'a'},
   109         {"position", required_argument, NULL, 'p'},
   112         {"position",    required_argument, NULL, 'p'},
   110         {"domain",   required_argument, NULL, 'd'},
   113         {"domain",      required_argument, NULL, 'd'},
   111         {"type",     required_argument, NULL, 't'},
   114         {"type",        required_argument, NULL, 't'},
   112         {"force",    no_argument,       NULL, 'f'},
   115         {"output-file", required_argument, NULL, 'o'},
   113         {"quiet",    no_argument,       NULL, 'q'},
   116         {"force",       no_argument,       NULL, 'f'},
   114         {"verbose",  no_argument,       NULL, 'v'},
   117         {"quiet",       no_argument,       NULL, 'q'},
   115         {"help",     no_argument,       NULL, 'h'},
   118         {"verbose",     no_argument,       NULL, 'v'},
       
   119         {"help",        no_argument,       NULL, 'h'},
   116         {}
   120         {}
   117     };
   121     };
   118 
   122 
   119     do {
   123     do {
   120         c = getopt_long(argc, argv, "m:a:p:d:t:fqvh", longOptions, NULL);
   124         c = getopt_long(argc, argv, "m:a:p:d:t:o:fqvh", longOptions, NULL);
   121 
   125 
   122         switch (c) {
   126         switch (c) {
   123             case 'm':
   127             case 'm':
   124                 str.clear();
   128                 str.clear();
   125                 str.str("");
   129                 str.str("");
   175 
   179 
   176             case 't':
   180             case 't':
   177                 dataTypeStr = optarg;
   181                 dataTypeStr = optarg;
   178                 break;
   182                 break;
   179 
   183 
       
   184             case 'o':
       
   185                 outputFile = optarg;
       
   186                 break;
       
   187 
   180             case 'f':
   188             case 'f':
   181                 force = true;
   189                 force = true;
   182                 break;
   190                 break;
   183 
   191 
   184             case 'q':
   192             case 'q':
   262     commandList.push_back(new CommandConfig());
   270     commandList.push_back(new CommandConfig());
   263     commandList.push_back(new CommandData());
   271     commandList.push_back(new CommandData());
   264     commandList.push_back(new CommandDebug());
   272     commandList.push_back(new CommandDebug());
   265     commandList.push_back(new CommandDomains());
   273     commandList.push_back(new CommandDomains());
   266     commandList.push_back(new CommandDownload());
   274     commandList.push_back(new CommandDownload());
       
   275     commandList.push_back(new CommandFoeRead());
       
   276     commandList.push_back(new CommandFoeWrite());
   267     commandList.push_back(new CommandMaster());
   277     commandList.push_back(new CommandMaster());
   268     commandList.push_back(new CommandPdos());
   278     commandList.push_back(new CommandPdos());
   269     commandList.push_back(new CommandPhyRead());
   279     commandList.push_back(new CommandPhyRead());
   270     commandList.push_back(new CommandPhyWrite());
   280     commandList.push_back(new CommandPhyWrite());
   271     commandList.push_back(new CommandSdos());
   281     commandList.push_back(new CommandSdos());
   290                     cmd->setVerbosity(verbosity);
   300                     cmd->setVerbosity(verbosity);
   291                     cmd->setAlias(slaveAlias);
   301                     cmd->setAlias(slaveAlias);
   292                     cmd->setPosition(slavePosition);
   302                     cmd->setPosition(slavePosition);
   293                     cmd->setDomain(domainIndex);
   303                     cmd->setDomain(domainIndex);
   294                     cmd->setDataType(dataTypeStr);
   304                     cmd->setDataType(dataTypeStr);
       
   305                     cmd->setOutputFile(outputFile);
   295                     cmd->setForce(force);
   306                     cmd->setForce(force);
   296                     cmd->execute(masterDev, commandArgs);
   307                     cmd->execute(masterDev, commandArgs);
   297                 } catch (InvalidUsageException &e) {
   308                 } catch (InvalidUsageException &e) {
   298                     cerr << e.what() << endl << endl;
   309                     cerr << e.what() << endl << endl;
   299                     cerr << binaryBaseName << " " << cmd->helpString();
   310                     cerr << binaryBaseName << " " << cmd->helpString();