author | Florian Pose <fp@igh-essen.com> |
Thu, 17 Jul 2008 11:51:22 +0000 | |
changeset 1113 | 4d720feb915d |
parent 1105 | 3552b4c46f10 |
permissions | -rw-r--r-- |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/***************************************************************************** |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
#ifndef __EC_MASTER_H__ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
#define __EC_MASTER_H__ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
#include <stdexcept> |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
11 |
#include <string> |
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
12 |
#include <vector> |
1105 | 13 |
#include <list> |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
using namespace std; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1001
diff
changeset
|
16 |
#include "../include/ecrt.h" |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
17 |
#include "../master/ioctl.h" |
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
18 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
/****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
class MasterException: |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
public runtime_error |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
public: |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
/** Constructor with std::string parameter. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
MasterException( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
const string &s /**< Message. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
): runtime_error(s) {} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** Constructor with const char pointer parameter. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
MasterException( |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
const char *s /**< Message. */ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
): runtime_error(s) {} |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
/****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
class Master |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
{ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
public: |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
Master(); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
~Master(); |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
972 | 44 |
void setIndex(unsigned int); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
46 |
enum Verbosity { |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
47 |
Quiet, |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
48 |
Normal, |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
49 |
Verbose |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
50 |
}; |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
51 |
void setVerbosity(Verbosity); |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
52 |
|
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
53 |
void writeAlias(int, bool, const vector<string> &); |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
54 |
void showConfigs(); |
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
55 |
void outputData(int); |
956
d9b9bc794d10
Implemented 'ethercat debug' command.
Florian Pose <fp@igh-essen.com>
parents:
950
diff
changeset
|
56 |
void setDebug(const vector<string> &); |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
57 |
void showDomains(int); |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
58 |
void showMaster(); |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
59 |
void listPdos(int); |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
60 |
void listSdos(int); |
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
61 |
void sdoDownload(int, const string &, const vector<string> &); |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
62 |
void sdoUpload(int, const string &, const vector<string> &); |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
63 |
void showSlaves(int); |
978 | 64 |
void siiRead(int); |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
65 |
void siiWrite(int, bool, const vector<string> &); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
66 |
void requestStates(int, const vector<string> &); |
938
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
936
diff
changeset
|
67 |
void generateXml(int); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
68 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
protected: |
972 | 70 |
enum Permissions {Read, ReadWrite}; |
71 |
void open(Permissions); |
|
72 |
void close(); |
|
73 |
||
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
74 |
void writeSlaveAlias(uint16_t, uint16_t); |
1105 | 75 |
typedef list<ec_ioctl_config_t> ConfigList; |
76 |
void showDetailedConfigs(const ConfigList &); |
|
77 |
void listConfigs(const ConfigList &); |
|
949
e424c0074c67
Implemented 'data' command.
Florian Pose <fp@igh-essen.com>
parents:
948
diff
changeset
|
78 |
void outputDomainData(unsigned int); |
1101
f8d13814af03
Break domain output data after 16 bytes.
Florian Pose <fp@igh-essen.com>
parents:
1099
diff
changeset
|
79 |
enum {BreakAfterBytes = 16}; |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
80 |
void showDomain(unsigned int); |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
81 |
void listSlavePdos(uint16_t, bool = false); |
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
82 |
void listSlaveSdos(uint16_t, bool = false); |
1065
d1d2aa556344
United 'ethercat slaves' and 'ethercat list' with a verbose flag.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
83 |
void listSlaves(int); |
989
816663ca9370
Slave information via 'ethercat slave'.
Florian Pose <fp@igh-essen.com>
parents:
982
diff
changeset
|
84 |
void showSlave(uint16_t); |
938
5b936e8e39fa
Added 'xml' command to generate a slave description file from a real
Florian Pose <fp@igh-essen.com>
parents:
936
diff
changeset
|
85 |
void generateSlaveXml(uint16_t); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
86 |
unsigned int slaveCount(); |
957
ed5ac2e83495
Replaced EC_IOCTL_SLAVE_COUNT with EC_IOCTL_MASTER; implemented
Florian Pose <fp@igh-essen.com>
parents:
956
diff
changeset
|
87 |
void getMaster(ec_ioctl_master_t *); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
88 |
void getConfig(ec_ioctl_config_t *, unsigned int); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1001
diff
changeset
|
89 |
void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1001
diff
changeset
|
90 |
uint16_t); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
91 |
void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int, |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1001
diff
changeset
|
92 |
uint8_t, uint16_t, uint8_t); |
990
4f223f3df05a
Bus configuration via 'ethercat config'.
Florian Pose <fp@igh-essen.com>
parents:
989
diff
changeset
|
93 |
void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int); |
948
1cfab7161491
Implemented domain command.
Florian Pose <fp@igh-essen.com>
parents:
938
diff
changeset
|
94 |
void getDomain(ec_ioctl_domain_t *, unsigned int); |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
95 |
void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
96 |
void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int, |
950
8b00e63fff90
'ethercat domain' shows domain contents and process data.
Florian Pose <fp@igh-essen.com>
parents:
949
diff
changeset
|
97 |
unsigned char *); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
98 |
void getSlave(ec_ioctl_slave_t *, uint16_t); |
1079
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
99 |
void getSync(ec_ioctl_slave_sync_t *, uint16_t, uint8_t); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
100 |
void getPdo(ec_ioctl_slave_sync_pdo_t *, uint16_t, uint8_t, uint8_t); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
101 |
void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t, |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
102 |
uint8_t, uint8_t); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
103 |
void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t); |
ef1266652c4d
Improved locking between ioctl()s and master state machine; separate
Florian Pose <fp@igh-essen.com>
parents:
1066
diff
changeset
|
104 |
void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t); |
960
36e460ffbb5e
Request slave state(s) with 'ethercat state'; removed sysfs state file.
Florian Pose <fp@igh-essen.com>
parents:
957
diff
changeset
|
105 |
void requestState(uint16_t, uint8_t); |
935
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
106 |
|
b954e9d91ea5
Added 'pdos' command to ethercat tool.
Florian Pose <fp@igh-essen.com>
parents:
922
diff
changeset
|
107 |
static string slaveState(uint8_t); |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
108 |
static void printRawData(const uint8_t *, unsigned int); |
980
c07dd38243ba
Implemented SII writing (including alias writing) via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
978
diff
changeset
|
109 |
static uint8_t calcSiiCrc(const uint8_t *, unsigned int); |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
private: |
974
5868944a6456
Implemented Sdo download via ethercat command.
Florian Pose <fp@igh-essen.com>
parents:
972
diff
changeset
|
112 |
enum {DefaultBufferSize = 1024}; |
968
b0e894257743
Implemented sdo_upload command.
Florian Pose <fp@igh-essen.com>
parents:
966
diff
changeset
|
113 |
|
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
unsigned int index; |
1099
eb8d16507d88
Made verbosity a master property; added -Wall flag to tools.
Florian Pose <fp@igh-essen.com>
parents:
1079
diff
changeset
|
115 |
Verbosity verbosity; |
922
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
int fd; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
}; |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
/****************************************************************************/ |
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
|
fede1d8f5b71
Added the new ethercat comman-line tool with lsec functionality.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
#endif |