author | Florian Pose <fp@igh-essen.com> |
Mon, 15 Jun 2009 12:33:48 +0000 | |
changeset 1468 | 0a804ddbaf93 |
parent 1388 | 3c886ec376f5 |
child 1485 | 5ddc3a455059 |
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 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
3 |
* $Id$ |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
4 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
5 |
* Copyright (C) 2006-2009 Florian Pose, Ingenieurgemeinschaft IgH |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
6 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
8 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
11 |
* published by the Free Software Foundation. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
12 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
16 |
* Public License for more details. |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
17 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
21 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1335
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
1122
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 |
|
1141 | 30 |
#ifndef __MASTER_DEVICE_H__ |
31 |
#define __MASTER_DEVICE_H__ |
|
1122
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 |
#include <stdexcept> |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
34 |
#include <sstream> |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
using namespace std; |
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 |
#include "../include/ecrt.h" |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "../master/ioctl.h" |
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 |
class MasterDeviceException: |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
public runtime_error |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
{ |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
45 |
friend class MasterDevice; |
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
46 |
|
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
47 |
protected: |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
48 |
/** Constructor with string parameter. */ |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
49 |
MasterDeviceException( |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
50 |
const string &s /**< Message. */ |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
51 |
): runtime_error(s) {} |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
52 |
|
1141 | 53 |
/** Constructor with stringstream parameter. */ |
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
54 |
MasterDeviceException( |
1136
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
55 |
const stringstream &s /**< Message. */ |
a0982873d655
Improved exceptions and commandName usage.
Florian Pose <fp@igh-essen.com>
parents:
1126
diff
changeset
|
56 |
): runtime_error(s.str()) {} |
1122
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 |
|
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
61 |
class MasterDeviceSdoAbortException: |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
62 |
public MasterDeviceException |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
63 |
{ |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
64 |
friend class MasterDevice; |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
65 |
|
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
66 |
public: |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
67 |
uint32_t abortCode; |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
68 |
|
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
69 |
protected: |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
70 |
/** Constructor with stringstream parameter. */ |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
71 |
MasterDeviceSdoAbortException(uint32_t code): |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1200
diff
changeset
|
72 |
MasterDeviceException("SDO transfer aborted.") { |
1184
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
73 |
abortCode = code; |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
74 |
}; |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
75 |
}; |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
76 |
|
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
77 |
/****************************************************************************/ |
75cd6681eb08
Introduced SdoCommand class to replace coe_datatypes.[ch]; added CoE abort codes in user space-
Florian Pose <fp@igh-essen.com>
parents:
1166
diff
changeset
|
78 |
|
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
class MasterDevice |
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 |
public: |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
MasterDevice(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
~MasterDevice(); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
void setIndex(unsigned int); |
1166 | 86 |
unsigned int getIndex() const; |
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 |
enum Permissions {Read, ReadWrite}; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
void open(Permissions); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
void close(); |
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 getMaster(ec_ioctl_master_t *); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
void getConfig(ec_ioctl_config_t *, unsigned int); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
uint16_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
uint8_t, uint16_t, uint8_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
void getDomain(ec_ioctl_domain_t *, unsigned int); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
unsigned char *); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
void getSlave(ec_ioctl_slave_t *, uint16_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
void getSync(ec_ioctl_slave_sync_t *, uint16_t, uint8_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
void getPdo(ec_ioctl_slave_sync_pdo_t *, uint16_t, uint8_t, uint8_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t, |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
uint8_t, uint8_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
void readSii(ec_ioctl_slave_sii_t *); |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
void writeSii(ec_ioctl_slave_sii_t *); |
1388
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
112 |
void readReg(ec_ioctl_slave_reg_t *); |
3c886ec376f5
Renamed phy_ commands to reg_.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
113 |
void writeReg(ec_ioctl_slave_reg_t *); |
1126
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
114 |
void setDebug(unsigned int); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
115 |
void sdoDownload(ec_ioctl_slave_sdo_download_t *); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
116 |
void sdoUpload(ec_ioctl_slave_sdo_upload_t *); |
b09fd81894cb
Moved every command into a separate file.
Florian Pose <fp@igh-essen.com>
parents:
1122
diff
changeset
|
117 |
void requestState(uint16_t, uint8_t); |
1335
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
118 |
void readFoe(ec_ioctl_slave_foe_t *); |
09c6fce1ae45
merge -c1616 branches/1.4-foe: Included FoE patch from Olav Zarges.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
119 |
void writeFoe(ec_ioctl_slave_foe_t *); |
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 |
private: |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
unsigned int index; |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
int fd; |
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 |
|
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
/****************************************************************************/ |
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
|
1166 | 128 |
inline unsigned int MasterDevice::getIndex() const |
129 |
{ |
|
130 |
return index; |
|
131 |
} |
|
132 |
||
133 |
/****************************************************************************/ |
|
134 |
||
1122
ee305a780a02
First step of moving to command list.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
#endif |