|
1 /***************************************************************************** |
|
2 * |
|
3 * $Id$ |
|
4 * |
|
5 ****************************************************************************/ |
|
6 |
|
7 #ifndef __EC_MASTER_H__ |
|
8 #define __EC_MASTER_H__ |
|
9 |
|
10 #include <stdexcept> |
|
11 #include <string> |
|
12 #include <vector> |
|
13 #include <list> |
|
14 using namespace std; |
|
15 |
|
16 #include "../include/ecrt.h" |
|
17 #include "../master/ioctl.h" |
|
18 |
|
19 /****************************************************************************/ |
|
20 |
|
21 class MasterDeviceException: |
|
22 public runtime_error |
|
23 { |
|
24 public: |
|
25 /** Constructor with std::string parameter. */ |
|
26 MasterDeviceException( |
|
27 const string &s /**< Message. */ |
|
28 ): runtime_error(s) {} |
|
29 }; |
|
30 |
|
31 /****************************************************************************/ |
|
32 |
|
33 class MasterDevice |
|
34 { |
|
35 public: |
|
36 MasterDevice(); |
|
37 ~MasterDevice(); |
|
38 |
|
39 void setIndex(unsigned int); |
|
40 |
|
41 enum Permissions {Read, ReadWrite}; |
|
42 void open(Permissions); |
|
43 void close(); |
|
44 |
|
45 unsigned int slaveCount(); |
|
46 |
|
47 void getMaster(ec_ioctl_master_t *); |
|
48 void getConfig(ec_ioctl_config_t *, unsigned int); |
|
49 void getConfigPdo(ec_ioctl_config_pdo_t *, unsigned int, uint8_t, |
|
50 uint16_t); |
|
51 void getConfigPdoEntry(ec_ioctl_config_pdo_entry_t *, unsigned int, |
|
52 uint8_t, uint16_t, uint8_t); |
|
53 void getConfigSdo(ec_ioctl_config_sdo_t *, unsigned int, unsigned int); |
|
54 void getDomain(ec_ioctl_domain_t *, unsigned int); |
|
55 void getFmmu(ec_ioctl_domain_fmmu_t *, unsigned int, unsigned int); |
|
56 void getData(ec_ioctl_domain_data_t *, unsigned int, unsigned int, |
|
57 unsigned char *); |
|
58 void getSlave(ec_ioctl_slave_t *, uint16_t); |
|
59 void getSync(ec_ioctl_slave_sync_t *, uint16_t, uint8_t); |
|
60 void getPdo(ec_ioctl_slave_sync_pdo_t *, uint16_t, uint8_t, uint8_t); |
|
61 void getPdoEntry(ec_ioctl_slave_sync_pdo_entry_t *, uint16_t, uint8_t, |
|
62 uint8_t, uint8_t); |
|
63 void getSdo(ec_ioctl_slave_sdo_t *, uint16_t, uint16_t); |
|
64 void getSdoEntry(ec_ioctl_slave_sdo_entry_t *, uint16_t, int, uint8_t); |
|
65 void readSii(ec_ioctl_slave_sii_t *); |
|
66 void writeSii(ec_ioctl_slave_sii_t *); |
|
67 |
|
68 protected: |
|
69 #if 0 |
|
70 void outputDomainData(unsigned int); |
|
71 enum {BreakAfterBytes = 16}; |
|
72 void showDomain(unsigned int); |
|
73 void listSlavePdos(uint16_t, bool = false); |
|
74 void listSlaveSdos(uint16_t, bool = false); |
|
75 void listSlaves(int); |
|
76 void showSlave(uint16_t); |
|
77 void generateSlaveXml(uint16_t); |
|
78 void requestState(uint16_t, uint8_t); |
|
79 |
|
80 static string slaveState(uint8_t); |
|
81 static void printRawData(const uint8_t *, unsigned int); |
|
82 static uint8_t calcSiiCrc(const uint8_t *, unsigned int); |
|
83 #endif |
|
84 |
|
85 private: |
|
86 //enum {DefaultBufferSize = 1024}; |
|
87 |
|
88 unsigned int index; |
|
89 int fd; |
|
90 }; |
|
91 |
|
92 /****************************************************************************/ |
|
93 |
|
94 #endif |