tools/main.cpp
changeset 1099 eb8d16507d88
parent 1066 7ece00bd6559
child 1118 9487162e4d4d
equal deleted inserted replaced
1098:ff5b1722581c 1099:eb8d16507d88
    20 static unsigned int masterIndex = DEFAULT_MASTER;
    20 static unsigned int masterIndex = DEFAULT_MASTER;
    21 static int slavePosition = -1;
    21 static int slavePosition = -1;
    22 static int domainIndex = -1;
    22 static int domainIndex = -1;
    23 static string command;
    23 static string command;
    24 vector<string> commandArgs;
    24 vector<string> commandArgs;
    25 static bool quiet = false;
    25 static Master::Verbosity verbosity = Master::Normal;
    26 static bool verbose = false;
       
    27 string dataTypeStr;
    26 string dataTypeStr;
    28 bool force = false;
    27 bool force = false;
    29 
    28 
    30 /*****************************************************************************/
    29 /*****************************************************************************/
    31 
    30 
   139             case 'f':
   138             case 'f':
   140                 force = true;
   139                 force = true;
   141                 break;
   140                 break;
   142 
   141 
   143             case 'q':
   142             case 'q':
   144                 quiet = true;
   143                 verbosity = Master::Quiet;
   145                 verbose = false;
       
   146                 break;
   144                 break;
   147 
   145 
   148             case 'v':
   146             case 'v':
   149                 verbose = true;
   147                 verbosity = Master::Verbose;
   150                 quiet = false;
       
   151                 break;
   148                 break;
   152 
   149 
   153             case 'h':
   150             case 'h':
   154             case '?':
   151             case '?':
   155                 printUsage();
   152                 printUsage();
   180 {
   177 {
   181     Master master;
   178     Master master;
   182     
   179     
   183 	getOptions(argc, argv);
   180 	getOptions(argc, argv);
   184 
   181 
       
   182     master.setIndex(masterIndex);
       
   183     master.setVerbosity(verbosity);
       
   184 
   185     try {
   185     try {
   186         master.setIndex(masterIndex);
       
   187 
       
   188         if (command == "alias") {
   186         if (command == "alias") {
   189             master.writeAlias(slavePosition, force, commandArgs);
   187             master.writeAlias(slavePosition, force, commandArgs);
   190         } else if (command == "config") {
   188         } else if (command == "config") {
   191             master.showConfigs(verbose);
   189             master.showConfigs();
   192         } else if (command == "data") {
   190         } else if (command == "data") {
   193             master.outputData(domainIndex);
   191             master.outputData(domainIndex);
   194         } else if (command == "debug") {
   192         } else if (command == "debug") {
   195             master.setDebug(commandArgs);
   193             master.setDebug(commandArgs);
   196         } else if (command == "domain") {
   194         } else if (command == "domain") {
   197             master.showDomains(domainIndex);
   195             master.showDomains(domainIndex);
   198 		} else if (command == "master") {
   196 		} else if (command == "master") {
   199             master.showMaster();
   197             master.showMaster();
   200         } else if (command == "pdos") {
   198         } else if (command == "pdos") {
   201             master.listPdos(slavePosition, quiet);
   199             master.listPdos(slavePosition);
   202         } else if (command == "sdos") {
   200         } else if (command == "sdos") {
   203             master.listSdos(slavePosition, quiet);
   201             master.listSdos(slavePosition);
   204         } else if (command == "sdo_download" || command == "sd") {
   202         } else if (command == "sdo_download" || command == "sd") {
   205             master.sdoDownload(slavePosition, dataTypeStr, commandArgs);
   203             master.sdoDownload(slavePosition, dataTypeStr, commandArgs);
   206         } else if (command == "sdo_upload" || command == "su") {
   204         } else if (command == "sdo_upload" || command == "su") {
   207             master.sdoUpload(slavePosition, dataTypeStr, commandArgs);
   205             master.sdoUpload(slavePosition, dataTypeStr, commandArgs);
   208 		} else if (command == "slave" || command == "slaves"
   206 		} else if (command == "slave" || command == "slaves"
   209                 || command == "list" || command == "ls") {
   207                 || command == "list" || command == "ls") {
   210             master.showSlaves(slavePosition, verbose);
   208             master.showSlaves(slavePosition);
   211         } else if (command == "sii_read" || command == "sr") {
   209         } else if (command == "sii_read" || command == "sr") {
   212             master.siiRead(slavePosition);
   210             master.siiRead(slavePosition);
   213         } else if (command == "sii_write" || command == "sw") {
   211         } else if (command == "sii_write" || command == "sw") {
   214             master.siiWrite(slavePosition, force, commandArgs);
   212             master.siiWrite(slavePosition, force, commandArgs);
   215         } else if (command == "state") {
   213         } else if (command == "state") {