author | Florian Pose <fp@igh-essen.com> |
Thu, 24 Jul 2008 13:29:13 +0000 | |
changeset 1143 | 09ee878d7214 |
parent 1136 | a0982873d655 |
child 1148 | 1762296870bd |
permissions | -rw-r--r-- |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
#include <sys/stat.h> |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
#include <fcntl.h> |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
#include <errno.h> |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
#include <sys/ioctl.h> |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
#include <sstream> |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
13 |
#include <iomanip> |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
using namespace std; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
#include "MasterDevice.h" |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
MasterDevice::MasterDevice() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
index = 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
fd = -1; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
MasterDevice::~MasterDevice() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
close(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
void MasterDevice::setIndex(unsigned int i) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
index = i; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
void MasterDevice::open(Permissions perm) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
stringstream deviceName; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
46 |
if (fd == -1) { // not already open |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
47 |
deviceName << "/dev/EtherCAT" << index; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
48 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
49 |
if ((fd = ::open(deviceName.str().c_str(), |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
50 |
perm == ReadWrite ? O_RDWR : O_RDONLY)) == -1) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
51 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
52 |
err << "Failed to open master device " << deviceName.str() << ": " |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
53 |
<< strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
54 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
55 |
} |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
60 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
61 |
void MasterDevice::close() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
{ |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
63 |
if (fd != -1) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
64 |
::close(fd); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
65 |
fd = -1; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
66 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
67 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
68 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
unsigned int MasterDevice::slaveCount() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
ec_ioctl_master_t data; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
getMaster(&data); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
76 |
return data.slave_count; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
void MasterDevice::getMaster(ec_ioctl_master_t *data) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
if (ioctl(fd, EC_IOCTL_MASTER, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
err << "Failed to get master information: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
86 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
void MasterDevice::getConfig(ec_ioctl_config_t *data, unsigned int index) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
if (ioctl(fd, EC_IOCTL_CONFIG, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
err << "Failed to get slave configuration: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
99 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
void MasterDevice::getConfigPdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
ec_ioctl_config_pdo_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
uint8_t sync_index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
uint16_t pdo_pos |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
data->sync_index = sync_index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
data->pdo_pos = pdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
if (ioctl(fd, EC_IOCTL_CONFIG_PDO, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
err << "Failed to get slave config Pdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
119 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
void MasterDevice::getConfigPdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
ec_ioctl_config_pdo_entry_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
uint8_t sync_index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
uint16_t pdo_pos, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
uint8_t entry_pos |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
data->sync_index = sync_index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
data->pdo_pos = pdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
data->entry_pos = entry_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
if (ioctl(fd, EC_IOCTL_CONFIG_PDO_ENTRY, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
err << "Failed to get slave config Pdo entry: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
141 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
void MasterDevice::getConfigSdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
ec_ioctl_config_sdo_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
unsigned int sdo_pos |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
data->sdo_pos = sdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
if (ioctl(fd, EC_IOCTL_CONFIG_SDO, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
err << "Failed to get slave config Sdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
159 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
void MasterDevice::getDomain(ec_ioctl_domain_t *data, unsigned int index) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
data->index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
if (ioctl(fd, EC_IOCTL_DOMAIN, data)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
err << "Failed to get domain: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
err << "Domain " << index << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
176 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
|
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
182 |
void MasterDevice::getData(ec_ioctl_domain_data_t *data, |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
183 |
unsigned int domainIndex, unsigned int dataSize, unsigned char *mem) |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
data->domain_index = domainIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
data->data_size = dataSize; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
data->target = mem; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
if (ioctl(fd, EC_IOCTL_DOMAIN_DATA, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
err << "Failed to get domain data: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
192 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
void MasterDevice::getSlave(ec_ioctl_slave_t *slave, uint16_t slaveIndex) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
slave->position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
if (ioctl(fd, EC_IOCTL_SLAVE, slave)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
err << "Failed to get slave: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
err << "Slave " << slaveIndex << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
209 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
void MasterDevice::getFmmu( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
ec_ioctl_domain_fmmu_t *fmmu, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
unsigned int domainIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
unsigned int fmmuIndex |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
fmmu->domain_index = domainIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
fmmu->fmmu_index = fmmuIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
if (ioctl(fd, EC_IOCTL_DOMAIN_FMMU, fmmu)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
226 |
err << "Failed to get domain FMMU: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
227 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
void MasterDevice::getSync( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
ec_ioctl_slave_sync_t *sync, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
uint8_t syncIndex |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
sync->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
sync->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC, sync)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
244 |
err << "Failed to get sync manager: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
245 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
void MasterDevice::getPdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
ec_ioctl_slave_sync_pdo_t *pdo, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
uint8_t syncIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
uint8_t pdoPos |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
pdo->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
pdo->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
pdo->pdo_pos = pdoPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO, pdo)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
264 |
err << "Failed to get Pdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
265 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
void MasterDevice::getPdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
ec_ioctl_slave_sync_pdo_entry_t *entry, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
uint8_t syncIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
uint8_t pdoPos, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
uint8_t entryPos |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
entry->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
entry->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
entry->pdo_pos = pdoPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
entry->entry_pos = entryPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
if (ioctl(fd, EC_IOCTL_SLAVE_SYNC_PDO_ENTRY, entry)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
286 |
err << "Failed to get Pdo entry: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
287 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
void MasterDevice::getSdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
ec_ioctl_slave_sdo_t *sdo, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
uint16_t sdoPosition |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
299 |
sdo->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
sdo->sdo_position = sdoPosition; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
if (ioctl(fd, EC_IOCTL_SLAVE_SDO, sdo)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
304 |
err << "Failed to get Sdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
305 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
308 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
309 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
310 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
void MasterDevice::getSdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
ec_ioctl_slave_sdo_entry_t *entry, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
313 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
314 |
int sdoSpec, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
315 |
uint8_t entrySubindex |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
316 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
317 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
318 |
entry->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
entry->sdo_spec = sdoSpec; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
entry->sdo_entry_subindex = entrySubindex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
321 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
if (ioctl(fd, EC_IOCTL_SLAVE_SDO_ENTRY, entry)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
324 |
err << "Failed to get Sdo entry: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
325 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
326 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
void MasterDevice::readSii( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
ec_ioctl_slave_sii_t *data |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
if (ioctl(fd, EC_IOCTL_SLAVE_SII_READ, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
err << "Failed to read SII: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
338 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
void MasterDevice::writeSii( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
ec_ioctl_slave_sii_t *data |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
348 |
if (ioctl(fd, EC_IOCTL_SLAVE_SII_WRITE, data) < 0) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
349 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
err << "Failed to write SII: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
351 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
353 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
|
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
357 |
void MasterDevice::setDebug(unsigned int debugLevel) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
358 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
359 |
if (ioctl(fd, EC_IOCTL_MASTER_DEBUG, debugLevel) < 0) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
360 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
361 |
err << "Failed to set debug level: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
362 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
363 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
364 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
365 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
366 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
367 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
368 |
void MasterDevice::sdoDownload(ec_ioctl_slave_sdo_download_t *data) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
369 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
370 |
if (ioctl(fd, EC_IOCTL_SLAVE_SDO_DOWNLOAD, data) < 0) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
371 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
372 |
err << "Failed to download Sdo: "; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
373 |
if (errno == EIO && data->abort_code) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
374 |
err << "Abort code 0x" << hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
375 |
<< setw(8) << data->abort_code; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
376 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
377 |
err << strerror(errno); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
378 |
} |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
379 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
380 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
381 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
382 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
383 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
384 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
385 |
void MasterDevice::sdoUpload(ec_ioctl_slave_sdo_upload_t *data) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
386 |
{ |
1135 | 387 |
if (ioctl(fd, EC_IOCTL_SLAVE_SDO_UPLOAD, data) < 0) { |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
388 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
389 |
err << "Failed to upload Sdo: "; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
390 |
if (errno == EIO && data->abort_code) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
391 |
err << "Abort code 0x" << hex << setfill('0') |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
392 |
<< setw(8) << data->abort_code; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
393 |
} else { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
394 |
err << strerror(errno); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
395 |
} |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
396 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
397 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
398 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
399 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
400 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
401 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
402 |
void MasterDevice::requestState( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
uint16_t slavePosition, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
404 |
uint8_t state |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
407 |
ec_ioctl_slave_state_t data; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
data.slave_position = slavePosition; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
data.requested_state = state; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
411 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
412 |
if (ioctl(fd, EC_IOCTL_SLAVE_STATE, &data)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
413 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
err << "Failed to request slave state: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
err << "Slave " << slavePosition << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
419 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
421 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
/*****************************************************************************/ |