tools/main.cpp
author Florian Pose <fp@igh-essen.com>
Wed, 04 Jun 2008 15:14:46 +0000
changeset 953 3ed51c088582
parent 949 e424c0074c67
child 956 d9b9bc794d10
permissions -rw-r--r--
Nicer usage.
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/*****************************************************************************
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 * $Id$
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 ****************************************************************************/
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
#include <getopt.h>
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
#include <iostream>
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
#include <string>
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
using namespace std;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#include "Master.h"
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
/*****************************************************************************/
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
#define DEFAULT_MASTER 0
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
#define DEFAULT_COMMAND "slaves"
936
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    19
#define DEFAULT_SLAVEPOSITION -1
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    20
#define DEFAULT_DOMAININDEX -1
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
static unsigned int masterIndex = DEFAULT_MASTER;
936
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    23
static int slavePosition = DEFAULT_SLAVEPOSITION;
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    24
static int domainIndex = DEFAULT_DOMAININDEX;
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
static string command = DEFAULT_COMMAND;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
/*****************************************************************************/
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
void printUsage()
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
{
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
    cerr
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
        << "Usage: ethercat <COMMAND> [OPTIONS]" << endl
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
		<< "Commands:" << endl
949
e424c0074c67 Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents: 948
diff changeset
    34
        << "  data               Output binary domain process data." << endl
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    35
        << "  domain             Show domain information." << endl
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
        << "  list (ls, slaves)  List all slaves (former 'lsec')." << endl
935
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
    37
        << "  pdos               List Pdo mapping of given slaves." << endl
938
5b936e8e39fa Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents: 936
diff changeset
    38
        << "  xml                Generate slave information xml." << endl
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
		<< "Global options:" << endl
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
        << "  --master  -m <master>  Index of the master to use. Default: "
953
3ed51c088582 Nicer usage.
Florian Pose <fp@igh-essen.com>
parents: 949
diff changeset
    41
		<< DEFAULT_MASTER << endl
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    42
        << "  --slave   -s <index>   Positive numerical ring position,"
936
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    43
        << endl
953
3ed51c088582 Nicer usage.
Florian Pose <fp@igh-essen.com>
parents: 949
diff changeset
    44
        << "                         or 'all' for all slaves (default)."
936
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    45
        << endl
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    46
        << "  --domain  -d <index>   Positive numerical index,"
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    47
        << endl
953
3ed51c088582 Nicer usage.
Florian Pose <fp@igh-essen.com>
parents: 949
diff changeset
    48
        << "                         or 'all' for all domains (default)."
3ed51c088582 Nicer usage.
Florian Pose <fp@igh-essen.com>
parents: 949
diff changeset
    49
        << endl
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
        << "  --help    -h           Show this help." << endl;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
}
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
/*****************************************************************************/
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
void getOptions(int argc, char **argv)
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
{
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
    int c, argCount, optionIndex, number;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
	char *remainder;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
    static struct option longOptions[] = {
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
        //name,    has_arg,           flag, val
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
        {"master", required_argument, NULL, 'm'},
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
        {"slave",  required_argument, NULL, 's'},
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    64
        {"domain", required_argument, NULL, 'd'},
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
        {"help",   no_argument,       NULL, 'h'},
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
        {}
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
    };
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
    do {
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    70
        c = getopt_long(argc, argv, "m:s:d:h", longOptions, &optionIndex);
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
        switch (c) {
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
            case 'm':
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    74
                number = strtoul(optarg, &remainder, 0);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
                if (remainder == optarg || *remainder || number < 0) {
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
                    cerr << "Invalid master number " << optarg << "!" << endl;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
                    printUsage();
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
                    exit(1);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
                }
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
				masterIndex = number;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
                break;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
            case 's':
936
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    84
                if (!strcmp(optarg, "all")) {
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    85
                    slavePosition = -1;
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    86
                } else {
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    87
                    number = strtoul(optarg, &remainder, 0);
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    88
                    if (remainder == optarg || *remainder
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    89
                            || number < 0 || number > 0xFFFF) {
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    90
                        cerr << "Invalid slave position "
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    91
                            << optarg << "!" << endl;
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    92
                        printUsage();
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    93
                        exit(1);
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    94
                    }
30fddfce8db6 Added multi-slave support.
Florian Pose <fp@igh-essen.com>
parents: 935
diff changeset
    95
                    slavePosition = number;
935
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
    96
                }
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    97
                break;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
    99
            case 'd':
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   100
                if (!strcmp(optarg, "all")) {
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   101
                    domainIndex = -1;
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   102
                } else {
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   103
                    number = strtoul(optarg, &remainder, 0);
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   104
                    if (remainder == optarg || *remainder || number < 0) {
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   105
                        cerr << "Invalid domain index "
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   106
							<< optarg << "!" << endl;
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   107
                        printUsage();
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   108
                        exit(1);
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   109
                    }
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   110
                    domainIndex = number;
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   111
                }
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   112
                break;
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   113
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   114
            case 'h':
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
            case '?':
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
                printUsage();
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
                exit(0);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   119
            default:
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   120
                break;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   121
        }
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
    }
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
    while (c != -1);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   125
	argCount = argc - optind;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   126
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   127
	if (!argCount) {
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   128
        cerr << "Please specify a command!" << endl;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   129
		printUsage();
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   130
        exit(1);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   131
	}
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   132
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   133
    command = argv[optind];
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   134
}
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   135
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   136
/****************************************************************************/
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   137
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   138
int main(int argc, char **argv)
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   139
{
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   140
    Master master;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   141
    
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   142
	getOptions(argc, argv);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
935
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   144
    try {
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   145
        master.open(masterIndex);
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
949
e424c0074c67 Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents: 948
diff changeset
   147
        if (command == "data") {
e424c0074c67 Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents: 948
diff changeset
   148
            master.outputData(domainIndex);
e424c0074c67 Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents: 948
diff changeset
   149
        } else if (command == "domain") {
948
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   150
            master.showDomains(domainIndex);
1cfab7161491 Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents: 938
diff changeset
   151
		} else if (command == "list" || command == "ls" || command == "slaves") {
935
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   152
            master.listSlaves();
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   153
        } else if (command == "pdos") {
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   154
            master.listPdos(slavePosition);
938
5b936e8e39fa Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents: 936
diff changeset
   155
        } else if (command == "xml") {
5b936e8e39fa Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents: 936
diff changeset
   156
            master.generateXml(slavePosition);
935
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   157
        } else {
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   158
            cerr << "Unknown command " << command << "!" << endl;
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   159
            printUsage();
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   160
            exit(1);
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   161
        }
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   162
    } catch (MasterException &e) {
b954e9d91ea5 Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents: 922
diff changeset
   163
        cerr << e.what() << endl;
922
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   164
        exit(1);
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   165
    }
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   166
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   167
	return 0;
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   168
}
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   169
fede1d8f5b71 Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   170
/****************************************************************************/