author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 05 Oct 2018 18:01:39 +0200 | |
branch | stable-1.5 |
changeset 2721 | d3855a6b0a9f |
parent 2529 | c7e1f2616a9d |
permissions | -rw-r--r-- |
1142 | 1 |
/***************************************************************************** |
2 |
* |
|
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1142 | 27 |
* |
1880 | 28 |
* vim: expandtab |
29 |
* |
|
1142 | 30 |
****************************************************************************/ |
31 |
||
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
32 |
#include <map> |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
33 |
using namespace std; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
34 |
|
1142 | 35 |
#include "Command.h" |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
36 |
#include "MasterDevice.h" |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
37 |
#include "NumberListParser.h" |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
38 |
|
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
39 |
/*****************************************************************************/ |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
40 |
|
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
41 |
typedef map<uint16_t, ec_ioctl_config_t> AliasMap; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
42 |
typedef map<uint16_t, AliasMap> ConfigMap; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
43 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
44 |
/*****************************************************************************/ |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
45 |
|
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
46 |
class MasterIndexParser: |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
47 |
public NumberListParser |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
48 |
{ |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
49 |
protected: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
50 |
int getMax() { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
51 |
MasterDevice dev; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
52 |
dev.setIndex(0U); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
53 |
dev.open(MasterDevice::Read); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
54 |
return (int) dev.getMasterCount() - 1; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
55 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
56 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
57 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
58 |
/*****************************************************************************/ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
59 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
60 |
class SlaveAliasParser: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
61 |
public NumberListParser |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
62 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
63 |
public: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
64 |
SlaveAliasParser(ec_ioctl_master_t &master, MasterDevice &dev): |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
65 |
master(master), dev(dev) {} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
66 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
67 |
protected: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
68 |
int getMax() { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
69 |
unsigned int i; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
70 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
71 |
uint16_t maxAlias = 0; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
72 |
for (i = 0; i < master.slave_count; i++) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
73 |
ec_ioctl_slave_t slave; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
74 |
dev.getSlave(&slave, i); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
75 |
if (slave.alias > maxAlias) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
76 |
maxAlias = slave.alias; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
77 |
} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
78 |
} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
79 |
return maxAlias ? maxAlias : -1; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
80 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
81 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
82 |
private: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
83 |
ec_ioctl_master_t &master; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
84 |
MasterDevice &dev; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
85 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
86 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
87 |
/*****************************************************************************/ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
88 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
89 |
class ConfigAliasParser: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
90 |
public NumberListParser |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
91 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
92 |
public: |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
93 |
ConfigAliasParser(unsigned int maxAlias): |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
94 |
maxAlias(maxAlias) {} |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
95 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
96 |
protected: |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
97 |
int getMax() { return maxAlias; }; |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
98 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
99 |
private: |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
100 |
unsigned int maxAlias; |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
101 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
102 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
103 |
/*****************************************************************************/ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
104 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
105 |
class PositionParser: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
106 |
public NumberListParser |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
107 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
108 |
public: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
109 |
PositionParser(unsigned int count): |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
110 |
count(count) {} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
111 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
112 |
protected: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
113 |
int getMax() { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
114 |
return count - 1; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
115 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
116 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
117 |
private: |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
118 |
const unsigned int count; |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
119 |
}; |
1142 | 120 |
|
121 |
/*****************************************************************************/ |
|
122 |
||
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
123 |
class AliasPositionParser: |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
124 |
public NumberListParser |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
125 |
{ |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
126 |
public: |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
127 |
AliasPositionParser(const AliasMap &aliasMap): |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
128 |
aliasMap(aliasMap) {} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
129 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
130 |
protected: |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
131 |
int getMax() { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
132 |
AliasMap::const_iterator i; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
133 |
int maxPos = -1; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
134 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
135 |
for (i = aliasMap.begin(); i != aliasMap.end(); i++) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
136 |
if (i->first > maxPos) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
137 |
maxPos = i->first; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
138 |
} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
139 |
} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
140 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
141 |
return maxPos; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
142 |
}; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
143 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
144 |
private: |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
145 |
const AliasMap &aliasMap; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
146 |
}; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
147 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
148 |
/*****************************************************************************/ |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
149 |
|
1142 | 150 |
Command::Command(const string &name, const string &briefDesc): |
151 |
name(name), |
|
152 |
briefDesc(briefDesc), |
|
2529
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
153 |
verbosity(Normal), |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
154 |
emergency(false), |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
155 |
force(false) |
1142 | 156 |
{ |
157 |
} |
|
158 |
||
159 |
/*****************************************************************************/ |
|
160 |
||
161 |
Command::~Command() |
|
162 |
{ |
|
163 |
} |
|
164 |
||
165 |
/*****************************************************************************/ |
|
166 |
||
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
167 |
void Command::setMasters(const string &m) |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
168 |
{ |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
169 |
masters = m; |
1826
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
170 |
}; |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
171 |
|
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
172 |
/*****************************************************************************/ |
ec6223c3b7ec
Multi-master support for command-line tool. The --master option supports
Florian Pose <fp@igh-essen.com>
parents:
1804
diff
changeset
|
173 |
|
1142 | 174 |
void Command::setVerbosity(Verbosity v) |
175 |
{ |
|
1804 | 176 |
verbosity = v; |
1142 | 177 |
}; |
178 |
||
1151 | 179 |
/*****************************************************************************/ |
180 |
||
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
181 |
void Command::setAliases(const string &a) |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
182 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
183 |
aliases = a; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
184 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
185 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
186 |
/*****************************************************************************/ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
187 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
188 |
void Command::setPositions(const string &p) |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
189 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
190 |
positions = p; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
191 |
}; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
192 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
193 |
/*****************************************************************************/ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
194 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
195 |
void Command::setDomains(const string &d) |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
196 |
{ |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
197 |
domains = d; |
1166 | 198 |
}; |
199 |
||
200 |
/*****************************************************************************/ |
|
201 |
||
202 |
void Command::setDataType(const string &t) |
|
203 |
{ |
|
1804 | 204 |
dataType = t; |
1166 | 205 |
}; |
206 |
||
207 |
/*****************************************************************************/ |
|
208 |
||
2529
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
209 |
void Command::setEmergency(bool e) |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
210 |
{ |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
211 |
emergency = e; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
212 |
}; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
213 |
|
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
214 |
/*****************************************************************************/ |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
215 |
|
1166 | 216 |
void Command::setForce(bool f) |
217 |
{ |
|
1804 | 218 |
force = f; |
1166 | 219 |
}; |
220 |
||
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
221 |
/*****************************************************************************/ |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
222 |
|
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
223 |
void Command::setOutputFile(const string &f) |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
224 |
{ |
1804 | 225 |
outputFile = f; |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
226 |
}; |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1199
diff
changeset
|
227 |
|
2436
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
228 |
/*****************************************************************************/ |
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
229 |
|
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
230 |
void Command::setSkin(const string &s) |
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
231 |
{ |
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
232 |
skin = s; |
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
233 |
}; |
960cc1bb6b4a
EtherLab skin for 'ethercat pdos' command.
Florian Pose <fp@igh-essen.com>
parents:
2421
diff
changeset
|
234 |
|
1142 | 235 |
/****************************************************************************/ |
236 |
||
237 |
bool Command::matchesSubstr(const string &cmd) const |
|
238 |
{ |
|
239 |
return name.substr(0, cmd.length()) == cmd; |
|
240 |
} |
|
2421 | 241 |
|
1142 | 242 |
/****************************************************************************/ |
243 |
||
244 |
bool Command::matchesAbbrev(const string &abb) const |
|
245 |
{ |
|
246 |
unsigned int i; |
|
247 |
size_t pos = 0; |
|
248 |
||
249 |
for (i = 0; i < abb.length(); i++) { |
|
250 |
pos = name.find(abb[i], pos); |
|
251 |
if (pos == string::npos) |
|
252 |
return false; |
|
253 |
} |
|
254 |
||
255 |
return true; |
|
256 |
} |
|
2421 | 257 |
|
1142 | 258 |
/*****************************************************************************/ |
259 |
||
1144
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
260 |
string Command::numericInfo() |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
261 |
{ |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
262 |
stringstream str; |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
263 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
264 |
str << "Numerical values can be specified either with decimal (no" << endl |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
265 |
<< "prefix), octal (prefix '0') or hexadecimal (prefix '0x') base." |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
266 |
<< endl; |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
267 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
268 |
return str.str(); |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
269 |
} |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
270 |
|
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
271 |
/*****************************************************************************/ |
7dbfdd61812c
Bugfixes and improvements.
Florian Pose <fp@igh-essen.com>
parents:
1142
diff
changeset
|
272 |
|
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
273 |
void Command::throwInvalidUsageException(const stringstream &s) const |
1142 | 274 |
{ |
275 |
throw InvalidUsageException(s); |
|
276 |
} |
|
277 |
||
278 |
/*****************************************************************************/ |
|
279 |
||
1834
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
280 |
void Command::throwCommandException(const string &msg) const |
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
281 |
{ |
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
282 |
throw CommandException(msg); |
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
283 |
} |
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
284 |
|
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
285 |
/*****************************************************************************/ |
67fc217d7341
Overloaded throwCommandException().
Florian Pose <fp@igh-essen.com>
parents:
1826
diff
changeset
|
286 |
|
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
287 |
void Command::throwCommandException(const stringstream &s) const |
1142 | 288 |
{ |
289 |
throw CommandException(s); |
|
290 |
} |
|
291 |
||
1151 | 292 |
/*****************************************************************************/ |
293 |
||
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
294 |
void Command::throwSingleSlaveRequired(unsigned int size) const |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
295 |
{ |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
296 |
stringstream err; |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
297 |
|
1199 | 298 |
err << "The slave selection matches " << size << " slaves. '" |
1155
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
299 |
<< name << "' requires a single slave."; |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
300 |
|
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
301 |
throwInvalidUsageException(err); |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
302 |
} |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
303 |
|
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
304 |
/*****************************************************************************/ |
bd4e5b544473
Common message for single slave selections.
Florian Pose <fp@igh-essen.com>
parents:
1151
diff
changeset
|
305 |
|
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
306 |
Command::MasterIndexList Command::getMasterIndices() const |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
307 |
{ |
1880 | 308 |
MasterIndexList indices; |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
309 |
|
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
310 |
try { |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
311 |
MasterIndexParser p; |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
312 |
indices = p.parse(masters.c_str()); |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
313 |
} catch (MasterDeviceException &e) { |
1880 | 314 |
stringstream err; |
315 |
err << "Failed to obtain number of masters: " << e.what(); |
|
316 |
throwCommandException(err); |
|
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
317 |
} catch (runtime_error &e) { |
1880 | 318 |
stringstream err; |
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
319 |
err << "Invalid master argument '" << masters << "': " << e.what(); |
1880 | 320 |
throwInvalidUsageException(err); |
321 |
} |
|
322 |
||
323 |
return indices; |
|
1869
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
324 |
} |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
325 |
|
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
326 |
/*****************************************************************************/ |
14f634f5b613
Open master device as late as possible.
Florian Pose <fp@igh-essen.com>
parents:
1834
diff
changeset
|
327 |
|
1870
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
328 |
unsigned int Command::getSingleMasterIndex() const |
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
329 |
{ |
1880 | 330 |
MasterIndexList masterIndices = getMasterIndices(); |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
331 |
|
1870
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
332 |
if (masterIndices.size() != 1) { |
1880 | 333 |
stringstream err; |
1870
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
334 |
err << getName() << " requires to select a single master!"; |
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
335 |
throwInvalidUsageException(err); |
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
336 |
} |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
337 |
|
1880 | 338 |
return masterIndices.front(); |
1870
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
339 |
} |
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
340 |
|
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
341 |
/*****************************************************************************/ |
0cee1fb7f0fd
Added getSingleMasterIndex() for command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1869
diff
changeset
|
342 |
|
1151 | 343 |
Command::SlaveList Command::selectedSlaves(MasterDevice &m) |
344 |
{ |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
345 |
ec_ioctl_master_t master; |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
346 |
unsigned int i; |
1151 | 347 |
ec_ioctl_slave_t slave; |
348 |
SlaveList list; |
|
349 |
||
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
350 |
m.getMaster(&master); |
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
351 |
|
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
352 |
if (aliases == "-") { // no alias given |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
353 |
PositionParser pp(master.slave_count); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
354 |
NumberListParser::List posList = pp.parse(positions.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
355 |
NumberListParser::List::const_iterator pi; |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
356 |
|
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
357 |
for (pi = posList.begin(); pi != posList.end(); pi++) { |
2014
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
358 |
if (*pi < master.slave_count) { |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
359 |
m.getSlave(&slave, *pi); |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
360 |
list.push_back(slave); |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
361 |
} |
1151 | 362 |
} |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
363 |
} else { // aliases given |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
364 |
SlaveAliasParser ap(master, m); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
365 |
NumberListParser::List aliasList = ap.parse(aliases.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
366 |
NumberListParser::List::const_iterator ai; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
367 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
368 |
for (ai = aliasList.begin(); ai != aliasList.end(); ai++) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
369 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
370 |
// gather slaves with that alias (and following) |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
371 |
uint16_t lastAlias = 0; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
372 |
vector<ec_ioctl_slave_t> aliasSlaves; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
373 |
|
1160
f02ff486b313
Removed MasterDevice::slaveCount().
Florian Pose <fp@igh-essen.com>
parents:
1159
diff
changeset
|
374 |
for (i = 0; i < master.slave_count; i++) { |
1151 | 375 |
m.getSlave(&slave, i); |
376 |
if (slave.alias) { |
|
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
377 |
if (lastAlias && lastAlias == *ai && slave.alias != *ai) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
378 |
// ignore multiple ocurrences of the same alias to |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
379 |
// assure consistency for the position argument |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
380 |
break; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
381 |
} |
1151 | 382 |
lastAlias = slave.alias; |
383 |
} |
|
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
384 |
if (lastAlias == *ai) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
385 |
aliasSlaves.push_back(slave); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
386 |
} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
387 |
} |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
388 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
389 |
PositionParser pp(aliasSlaves.size()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
390 |
NumberListParser::List posList = pp.parse(positions.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
391 |
NumberListParser::List::const_iterator pi; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
392 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
393 |
for (pi = posList.begin(); pi != posList.end(); pi++) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
394 |
if (*pi < aliasSlaves.size()) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
395 |
list.push_back(aliasSlaves[*pi]); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
396 |
} |
1151 | 397 |
} |
398 |
} |
|
399 |
} |
|
400 |
||
401 |
return list; |
|
402 |
} |
|
403 |
||
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
404 |
/*****************************************************************************/ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
405 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
406 |
bool operator<( |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
407 |
const ec_ioctl_config_t &a, |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
408 |
const ec_ioctl_config_t &b |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
409 |
) |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
410 |
{ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
411 |
return a.alias < b.alias |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
412 |
|| (a.alias == b.alias && a.position < b.position); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
413 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
414 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
415 |
/*****************************************************************************/ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
416 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
417 |
Command::ConfigList Command::selectedConfigs(MasterDevice &m) |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
418 |
{ |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
419 |
unsigned int i; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
420 |
ec_ioctl_master_t master; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
421 |
ec_ioctl_config_t config; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
422 |
ConfigList list; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
423 |
stringstream err; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
424 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
425 |
m.getMaster(&master); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
426 |
|
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
427 |
if (aliases == "-" && positions == "-") { // shortcut |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
428 |
for (i = 0; i < master.config_count; i++) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
429 |
m.getConfig(&config, i); |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
430 |
list.push_back(config); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
431 |
} |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
432 |
} else { // take the long way home... |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
433 |
ConfigMap configs; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
434 |
uint16_t maxAlias = 0; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
435 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
436 |
// fill cascaded map structure with all configs |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
437 |
for (i = 0; i < master.config_count; i++) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
438 |
m.getConfig(&config, i); |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
439 |
AliasMap &aliasMap = configs[config.alias]; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
440 |
aliasMap[config.position] = config; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
441 |
if (config.alias > maxAlias) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
442 |
maxAlias = config.alias; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
443 |
} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
444 |
} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
445 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
446 |
ConfigAliasParser ap(maxAlias); |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
447 |
NumberListParser::List aliasList = ap.parse(aliases.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
448 |
NumberListParser::List::const_iterator ai; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
449 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
450 |
for (ai = aliasList.begin(); ai != aliasList.end(); ai++) { |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
451 |
|
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
452 |
ConfigMap::iterator ci = configs.find(*ai); |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
453 |
if (ci == configs.end()) { |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
454 |
continue; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
455 |
} |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
456 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
457 |
AliasMap &aliasMap = configs[*ai]; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
458 |
AliasPositionParser pp(aliasMap); |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
459 |
NumberListParser::List posList = pp.parse(positions.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
460 |
NumberListParser::List::const_iterator pi; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
461 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
462 |
for (pi = posList.begin(); pi != posList.end(); pi++) { |
2013
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
463 |
AliasMap::const_iterator ci; |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
464 |
|
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
465 |
ci = aliasMap.find(*pi); |
0aea9df5fa21
Fixed / improved config selection.
Florian Pose <fp@igh-essen.com>
parents:
2010
diff
changeset
|
466 |
if (ci != aliasMap.end()) { |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
467 |
list.push_back(ci->second); |
1156
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
468 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
469 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
470 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
471 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
472 |
|
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
473 |
list.sort(); |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
474 |
return list; |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
475 |
} |
ecaf2a896ea3
Implemented alias and position for configs.
Florian Pose <fp@igh-essen.com>
parents:
1155
diff
changeset
|
476 |
|
1142 | 477 |
/****************************************************************************/ |
1146
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
478 |
|
2453
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2436
diff
changeset
|
479 |
Command::DomainList Command::selectedDomains(MasterDevice &m, |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2436
diff
changeset
|
480 |
const ec_ioctl_master_t &io) |
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2436
diff
changeset
|
481 |
{ |
1804 | 482 |
DomainList list; |
1166 | 483 |
|
2453
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2436
diff
changeset
|
484 |
PositionParser pp(io.domain_count); |
2010
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
485 |
NumberListParser::List domList = pp.parse(domains.c_str()); |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
486 |
NumberListParser::List::const_iterator di; |
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
487 |
|
87de63b19e4c
Implemented ranges for slaves, configs and domains.
Florian Pose <fp@igh-essen.com>
parents:
1918
diff
changeset
|
488 |
for (di = domList.begin(); di != domList.end(); di++) { |
2453
d461b1f07296
Added configure option for redundancy (--with-devices).
Florian Pose <fp@igh-essen.com>
parents:
2436
diff
changeset
|
489 |
if (*di < io.domain_count) { |
2014
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
490 |
ec_ioctl_domain_t d; |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
491 |
m.getDomain(&d, *di); |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
492 |
list.push_back(d); |
1d2111370ad5
Be more tolerant when selecting slaves and domains.
Florian Pose <fp@igh-essen.com>
parents:
2013
diff
changeset
|
493 |
} |
1804 | 494 |
} |
495 |
||
496 |
return list; |
|
1166 | 497 |
} |
498 |
||
499 |
/****************************************************************************/ |
|
500 |
||
2529
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
501 |
int Command::emergencySlave() const |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
502 |
{ |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
503 |
unsigned int ret; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
504 |
|
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
505 |
stringstream str; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
506 |
str << positions; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
507 |
str >> ret; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
508 |
|
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
509 |
return ret; |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
510 |
} |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
511 |
|
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
512 |
/****************************************************************************/ |
c7e1f2616a9d
Implemented emergency register requests to analyze a broken bus.
Florian Pose <fp@igh-essen.com>
parents:
2453
diff
changeset
|
513 |
|
1146
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
514 |
string Command::alStateString(uint8_t state) |
f18d124d7fbc
Moved slaveState() to Command::alStateString().
Florian Pose <fp@igh-essen.com>
parents:
1144
diff
changeset
|
515 |
{ |
1918
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
516 |
string ret; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
517 |
|
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
518 |
switch (state & EC_SLAVE_STATE_MASK) { |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
519 |
case 1: ret = "INIT"; break; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
520 |
case 2: ret = "PREOP"; break; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
521 |
case 3: ret = "BOOT"; break; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
522 |
case 4: ret = "SAFEOP"; break; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
523 |
case 8: ret = "OP"; break; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
524 |
default: ret = "???"; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
525 |
} |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
526 |
|
2421 | 527 |
if (state & EC_SLAVE_STATE_ACK_ERR) { |
1918
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
528 |
ret += "+ERROR"; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
529 |
} |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
530 |
|
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
531 |
return ret; |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
532 |
} |
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
533 |
|
c58633eed20b
Fixed AL state display in command-line tool.
Florian Pose <fp@igh-essen.com>
parents:
1880
diff
changeset
|
534 |
/****************************************************************************/ |