ESI.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package ArmarX
19 * @author Stefan Reither( stefan.reither at kit dot edu)
20 * @date 2021
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24
25#pragma once
26
27#include <bitset>
28#include <cstdint>
29#include <optional>
30#include <vector>
31
33{
34
35 constexpr std::uint16_t ESI_Header_StartAdress = 0x0000;
36 constexpr std::uint16_t ESI_Header_EndAdress = 0x0040;
37
38 /**
39 * @class ESIHandler
40 * @ingroup Library-ethercat
41 * @brief Brief description of class ESIHandler.
42 *
43 * Detailed description of class ESIHandler.
44 */
46 {
47 protected:
48 // 2 Byte access, data at end address not included in blob
49 std::optional<std::vector<std::byte>> readESIBinaryBlob(std::uint16_t slaveIndex,
50 std::uint16_t startAddress,
51 std::uint16_t endAddress) const;
52
53 private:
54 std::vector<std::byte> readFromEEPROM(std::uint16_t slaveIndex,
55 std::uint16_t startAddress,
56 std::uint16_t endAddress,
57 bool has64BitPackets) const;
58 };
59
60 // TODO
61 // ------------------------------------------
62 // Following code has been copied from etherkitten and should be replaced by the original
63 // project code once etherkitten has been made a dependecy of armarx
64 // ------------------------------------------
65
66 struct ESIHeader
67 {
68 std::uint16_t pdiControl;
69 std::uint16_t pdiConfiguration;
70 std::uint16_t syncImpulseLen;
71 std::uint16_t pdiConfiguration2;
72 std::uint16_t stationAlias;
73 std::uint16_t checkSum;
74 std::uint32_t vendorID;
75 std::uint32_t productCode;
76 std::uint32_t revisionNumber;
77 std::uint32_t serialNumber;
86 std::uint16_t mailboxProtocol;
87 std::uint16_t eepromSize;
88 std::uint16_t version;
89 };
90
92 {
93 AOE = 0x1,
94 EOE = 0x2,
95 COE = 0x4,
96 FOE = 0x8,
97 SOE = 0x10,
98 VOE = 0x20,
99 };
100
101 using ESIStrings = std::vector<std::string>;
102
104 {
105 std::uint8_t groupIdx;
106 std::uint8_t imgIdx;
107 std::uint8_t orderIdx;
108 std::uint8_t nameIdx;
109 std::uint8_t coEDetails;
110 std::uint8_t foEDetails;
111 std::uint8_t eoEDetails;
112 std::uint8_t soEChannels;
113 std::uint8_t dS402Channels;
114 std::uint8_t sysmanClass;
115 std::uint8_t flags;
116 std::int16_t currentOnEBus;
117 std::uint16_t physicalPort;
119 std::bitset<3> identALStatus;
121 };
122
123 using ESIFMMU = std::vector<std::uint8_t>;
124
126 {
127 std::uint16_t physicalStartAddress;
128 std::uint16_t length;
129 std::uint8_t controlRegister;
130 std::uint8_t statusRegister;
131 std::uint8_t enableSynchManager;
132 std::uint8_t syncManagerType;
133 };
134
135 using ESISyncM = std::vector<ESISyncMElement>;
136
138 {
139 std::uint16_t index;
140 std::uint8_t subIndex;
141 std::uint8_t nameIdx;
142 std::uint8_t dataType;
143 std::uint8_t bitLength;
144 std::uint16_t flags;
145 };
146
148 {
149 std::uint16_t pdoIndex;
150 std::uint8_t entryCount;
151 std::uint8_t syncManager;
152 std::uint8_t synchronization;
153 std::uint8_t nameIdx;
154 std::uint16_t flags;
155 std::vector<ESIPDOEntry> entries;
156 };
157
158 using ESITxPDO = std::vector<ESIPDOObject>;
159 using ESIRxPDO = std::vector<ESIPDOObject>;
160
161 /*!
162 * \brief Holds ESI data that can be read from slaves via SII.
163 *
164 * For details regarding contents and structure, see ETG1000.6.
165 */
176
178 {
179 public:
180 ESIHeader parseHeader(const std::vector<std::byte>& esiBinary);
181
182 std::vector<std::string> parseStrings(const std::vector<std::byte>& esiBinary,
183 std::uint16_t wordOffset);
184
185 ESIGeneral parseGeneral(const std::vector<std::byte>& esiBinary, std::uint16_t wordOffset);
186
187 ESIFMMU parseFMMU(const std::vector<std::byte>& esiBinary,
188 std::uint16_t wordOffset,
189 std::uint16_t len);
190
191 ESISyncM parseSyncM(const std::vector<std::byte>& esiBinary,
192 std::uint16_t wordOffset,
193 std::uint16_t len);
194
195 std::vector<ESIPDOObject> parsePDOs(const std::vector<std::byte>& esiBinary,
196 std::uint16_t wordOffset,
197 std::uint16_t len);
198
199 /*!
200 * \brief Parse a standard-conformant binary in SII format to an ESI structure.
201 *
202 * See ETG1000.6 for the SII specification.
203 * \param esiBinary the binary SII to parse
204 * \return the parsed ESI data structure
205 * \exception ParseException iff esiBinary is not standard-conformant
206 */
207 ESIData parseESI(const std::vector<std::byte>& esiBinary);
208 };
209
210} // namespace armarx::control::ethercat
Brief description of class ESIHandler.
Definition ESI.h:46
std::optional< std::vector< std::byte > > readESIBinaryBlob(std::uint16_t slaveIndex, std::uint16_t startAddress, std::uint16_t endAddress) const
Definition ESI.cpp:16
std::vector< std::string > parseStrings(const std::vector< std::byte > &esiBinary, std::uint16_t wordOffset)
Definition ESI.cpp:215
ESIFMMU parseFMMU(const std::vector< std::byte > &esiBinary, std::uint16_t wordOffset, std::uint16_t len)
Definition ESI.cpp:259
ESIGeneral parseGeneral(const std::vector< std::byte > &esiBinary, std::uint16_t wordOffset)
Definition ESI.cpp:237
std::vector< ESIPDOObject > parsePDOs(const std::vector< std::byte > &esiBinary, std::uint16_t wordOffset, std::uint16_t len)
Definition ESI.cpp:299
ESIHeader parseHeader(const std::vector< std::byte > &esiBinary)
Definition ESI.cpp:187
ESIData parseESI(const std::vector< std::byte > &esiBinary)
Parse a standard-conformant binary in SII format to an ESI structure.
Definition ESI.cpp:130
ESISyncM parseSyncM(const std::vector< std::byte > &esiBinary, std::uint16_t wordOffset, std::uint16_t len)
Definition ESI.cpp:274
std::vector< ESIPDOObject > ESIRxPDO
Definition ESI.h:159
std::vector< std::string > ESIStrings
Definition ESI.h:101
constexpr std::uint16_t ESI_Header_EndAdress
Definition ESI.h:36
std::vector< ESIPDOObject > ESITxPDO
Definition ESI.h:158
constexpr std::uint16_t ESI_Header_StartAdress
Definition ESI.h:35
std::vector< ESISyncMElement > ESISyncM
Definition ESI.h:135
std::vector< std::uint8_t > ESIFMMU
Definition ESI.h:123
Holds ESI data that can be read from slaves via SII.
Definition ESI.h:167
std::optional< ESIGeneral > general
Definition ESI.h:170
std::uint16_t physicalMemoryAddress
Definition ESI.h:118
std::bitset< 3 > identALStatus
Definition ESI.h:119
std::bitset< 4 > identPhysicalMemoryAddress
Definition ESI.h:120
std::uint16_t bootstrapReceiveMailboxOffset
Definition ESI.h:78
std::uint16_t standardReceiveMailboxSize
Definition ESI.h:83
std::uint16_t standardReceiveMailboxOffset
Definition ESI.h:82
std::uint16_t standardSendMailboxSize
Definition ESI.h:85
std::uint16_t pdiConfiguration2
Definition ESI.h:71
std::uint16_t standardSendMailboxOffset
Definition ESI.h:84
std::uint16_t bootstrapReceiveMailboxSize
Definition ESI.h:79
std::uint16_t bootstrapSendMailboxSize
Definition ESI.h:81
std::uint16_t bootstrapSendMailboxOffset
Definition ESI.h:80
std::vector< ESIPDOEntry > entries
Definition ESI.h:155