author | Florian Pose <fp@igh-essen.com> |
Thu, 09 Oct 2008 13:23:07 +0000 | |
changeset 1253 | 8a081444a89a |
parent 1238 | 02711963a059 |
child 1327 | 4d179b06dd3c |
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> |
1222
7348d6abb6cb
Applied patch by Karsten Schwinne, adding a few header files necessary
Florian Pose <fp@igh-essen.com>
parents:
1200
diff
changeset
|
11 |
#include <string.h> |
1238 | 12 |
#include <unistd.h> |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
#include <sstream> |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
15 |
#include <iomanip> |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
using namespace std; |
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 |
#include "MasterDevice.h" |
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 |
/****************************************************************************/ |
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 |
MasterDevice::MasterDevice() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
index = 0; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
fd = -1; |
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 |
/****************************************************************************/ |
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 |
MasterDevice::~MasterDevice() |
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 |
close(); |
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 |
/****************************************************************************/ |
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 |
void MasterDevice::setIndex(unsigned int 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 |
index = i; |
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 |
/****************************************************************************/ |
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 |
void MasterDevice::open(Permissions perm) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
stringstream deviceName; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
48 |
if (fd == -1) { // not already open |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
49 |
deviceName << "/dev/EtherCAT" << index; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
50 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
51 |
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
|
52 |
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
|
53 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
54 |
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
|
55 |
<< strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
56 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
57 |
} |
1122
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 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
62 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
void MasterDevice::close() |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
{ |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
65 |
if (fd != -1) { |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
66 |
::close(fd); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
67 |
fd = -1; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
68 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
69 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
70 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
/****************************************************************************/ |
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 |
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
|
74 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
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
|
76 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
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
|
78 |
throw MasterDeviceException(err); |
1122
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 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
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
|
85 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
data->config_index = index; |
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 |
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
|
89 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
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
|
91 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
} |
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 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
void MasterDevice::getConfigPdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
ec_ioctl_config_pdo_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
uint8_t sync_index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
uint16_t pdo_pos |
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 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
data->sync_index = sync_index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
data->pdo_pos = pdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
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
|
109 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
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
|
111 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
void MasterDevice::getConfigPdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
ec_ioctl_config_pdo_entry_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
uint8_t sync_index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
uint16_t pdo_pos, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
uint8_t entry_pos |
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 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
data->sync_index = sync_index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
data->pdo_pos = pdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
data->entry_pos = entry_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
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
|
131 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
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
|
133 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
void MasterDevice::getConfigSdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
ec_ioctl_config_sdo_t *data, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
unsigned int index, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
unsigned int sdo_pos |
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 |
data->config_index = index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
data->sdo_pos = sdo_pos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
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
|
149 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
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
|
151 |
throw MasterDeviceException(err); |
1122
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 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
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
|
158 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
data->index = index; |
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 |
if (ioctl(fd, EC_IOCTL_DOMAIN, data)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
err << "Failed to get domain: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
err << "Domain " << index << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
168 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
|
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
174 |
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
|
175 |
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
|
176 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
data->domain_index = domainIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
data->data_size = dataSize; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
data->target = mem; |
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 |
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
|
182 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
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
|
184 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
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
|
191 |
{ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
slave->position = slaveIndex; |
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 |
if (ioctl(fd, EC_IOCTL_SLAVE, slave)) { |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
err << "Failed to get slave: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
err << "Slave " << slaveIndex << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
201 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
void MasterDevice::getFmmu( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
ec_ioctl_domain_fmmu_t *fmmu, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
unsigned int domainIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
unsigned int fmmuIndex |
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 |
fmmu->domain_index = domainIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
fmmu->fmmu_index = fmmuIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
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
|
217 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
218 |
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
|
219 |
throw MasterDeviceException(err); |
1122
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 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
void MasterDevice::getSync( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
ec_ioctl_slave_sync_t *sync, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
uint8_t syncIndex |
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 |
sync->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
sync->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
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
|
235 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
236 |
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
|
237 |
throw MasterDeviceException(err); |
1122
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 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
void MasterDevice::getPdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
ec_ioctl_slave_sync_pdo_t *pdo, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
uint8_t syncIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
uint8_t pdoPos |
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 |
pdo->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
pdo->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
pdo->pdo_pos = pdoPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
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
|
255 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
256 |
err << "Failed to get Pdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
257 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
void MasterDevice::getPdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
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
|
265 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
uint8_t syncIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
uint8_t pdoPos, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
uint8_t entryPos |
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 |
entry->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
entry->sync_index = syncIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
entry->pdo_pos = pdoPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
entry->entry_pos = entryPos; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
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
|
277 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
278 |
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
|
279 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
void MasterDevice::getSdo( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
ec_ioctl_slave_sdo_t *sdo, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
uint16_t sdoPosition |
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 |
sdo->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
sdo->sdo_position = sdoPosition; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
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
|
295 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
296 |
err << "Failed to get Sdo: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
297 |
throw MasterDeviceException(err); |
1122
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 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
void MasterDevice::getSdoEntry( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
304 |
ec_ioctl_slave_sdo_entry_t *entry, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
305 |
uint16_t slaveIndex, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
306 |
int sdoSpec, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
307 |
uint8_t entrySubindex |
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 |
entry->slave_position = slaveIndex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
311 |
entry->sdo_spec = sdoSpec; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
312 |
entry->sdo_entry_subindex = entrySubindex; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
313 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
314 |
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
|
315 |
stringstream err; |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
316 |
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
|
317 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
318 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
|
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
void MasterDevice::readSii( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
324 |
ec_ioctl_slave_sii_t *data |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
325 |
) |
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 |
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
|
328 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
err << "Failed to read SII: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
330 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
} |
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
void MasterDevice::writeSii( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
ec_ioctl_slave_sii_t *data |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
) |
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 |
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
|
341 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
err << "Failed to write SII: " << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
343 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
} |
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 |
|
1200 | 349 |
void MasterDevice::readPhy( |
350 |
ec_ioctl_slave_phy_t *data |
|
351 |
) |
|
352 |
{ |
|
353 |
if (ioctl(fd, EC_IOCTL_SLAVE_PHY_READ, data) < 0) { |
|
354 |
stringstream err; |
|
355 |
err << "Failed to read physical memory: " << strerror(errno); |
|
356 |
throw MasterDeviceException(err); |
|
357 |
} |
|
358 |
} |
|
359 |
||
360 |
/****************************************************************************/ |
|
361 |
||
362 |
void MasterDevice::writePhy( |
|
363 |
ec_ioctl_slave_phy_t *data |
|
364 |
) |
|
365 |
{ |
|
366 |
if (ioctl(fd, EC_IOCTL_SLAVE_PHY_WRITE, data) < 0) { |
|
367 |
stringstream err; |
|
368 |
err << "Failed to write physical memory: " << strerror(errno); |
|
369 |
throw MasterDeviceException(err); |
|
370 |
} |
|
371 |
} |
|
372 |
||
373 |
/****************************************************************************/ |
|
374 |
||
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
375 |
void MasterDevice::setDebug(unsigned int debugLevel) |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
376 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
377 |
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
|
378 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
379 |
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
|
380 |
throw MasterDeviceException(err); |
1126
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 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
386 |
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
|
387 |
{ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
388 |
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
|
389 |
stringstream err; |
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) { |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
391 |
throw MasterDeviceSdoAbortException(data->abort_code); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
392 |
} else { |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
393 |
err << "Failed to download Sdo: " << strerror(errno); |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
394 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
395 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
396 |
} |
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 |
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
|
402 |
{ |
1135 | 403 |
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
|
404 |
stringstream err; |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
405 |
if (errno == EIO && data->abort_code) { |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
406 |
throw MasterDeviceSdoAbortException(data->abort_code); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
407 |
} else { |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
408 |
err << "Failed to upload Sdo: " << strerror(errno); |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1160
diff
changeset
|
409 |
throw MasterDeviceException(err); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
410 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
411 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
412 |
} |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
413 |
|
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
414 |
/****************************************************************************/ |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
415 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
void MasterDevice::requestState( |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
uint16_t slavePosition, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
uint8_t state |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
) |
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 |
ec_ioctl_slave_state_t data; |
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 |
data.slave_position = slavePosition; |
1148
1762296870bd
Renamed state field to al_state.
Florian Pose <fp@igh-essen.com>
parents:
1136
diff
changeset
|
424 |
data.al_state = state; |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
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
|
427 |
stringstream err; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
err << "Failed to request slave state: "; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
if (errno == EINVAL) |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
err << "Slave " << slavePosition << " does not exist!"; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
else |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
err << strerror(errno); |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1135
diff
changeset
|
433 |
throw MasterDeviceException(err); |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
} |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
/*****************************************************************************/ |