Motion Master
Loading...
Searching...
No Matches
soem.h
Go to the documentation of this file.
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5#include <functional>
6#include <map>
7#include <memory>
8#include <mutex>
9#include <sstream>
10#include <string>
11#include <type_traits>
12#include <unordered_map>
13#include <utility>
14#include <variant>
15#include <vector>
16
17#include <tl/expected.hpp>
18
19#include "base.h"
20#include "ethercat.h"
21#include "loguru.h"
22
23namespace mm::comm::soem {
24
25// 3-second SDO read/write timeout — long enough for devices with slower mailbox
26// implementations.
27inline constexpr int kSdoTimeoutUs = 3'000'000;
28
29// 10-second FoE write timeout — covers large firmware files over slow links.
30inline constexpr int kFoeTimeoutUs = 10'000'000;
31
32// 2-second FoE read timeout. Reads are small and a healthy device answers each
33// mailbox cycle within milliseconds, so a much shorter timeout than writes is
34// safe. Keeping it short bounds the cost of recovering from a transient/wedged
35// mailbox: a non-responsive read fails quickly and is retried (with a mailbox
36// drain) instead of stalling for the full write timeout on every attempt.
37inline constexpr int kFoeReadTimeoutUs = 2'000'000;
38
39// 10-second timeout for a file removal ("fs-remove=<name>" issued as an FoE
40// read). Removing a file erases flash, which can take several seconds — much
41// longer than reading one back.
42inline constexpr int kFoeRemoveTimeoutUs = 10'000'000;
43
44// 30-second timeout for removing the ESI file. It is large and its erase takes
45// considerably longer than other files (measured at ~17 s on a SOMANET drive).
46inline constexpr int kFoeRemoveEsiTimeoutUs = 30'000'000;
47
67std::recursive_mutex& controlPlaneMutex();
68
89std::string drainMailboxErrors(ecx_contextt* context);
90
116int drainMailbox(ecx_contextt* context, uint16_t slave);
117
129std::map<std::string, std::string> mapMacAddressesToInterfaces();
130
141 bool loaded = false;
146 std::vector<std::string> devices;
147
150 [[nodiscard]] bool isConfiguredFor(const std::string& macAddress) const;
151};
152
164 const std::string& moduleDirectory = "/sys/module/ec_master");
165
181inline std::string uiConfigWithDefaultPdoMapping = R"(
182{
183 "pdoMapping": {
184 "rx": {
185 "0x1600": [
186 "0x60400010",
187 "0x60600008",
188 "0x60710010",
189 "0x607a0020",
190 "0x60ff0020",
191 "0x60b20010",
192 "0x27010020"
193 ],
194 "0x1601": [
195 "0x60fe0120",
196 "0x60fe0220"
197 ],
198 "0x1602": [
199 "0x27030020",
200 "0x60b10020",
201 "0x20120120"
202 ]
203 },
204 "tx": {
205 "0x1a00": [
206 "0x60410010",
207 "0x60610008",
208 "0x60640020",
209 "0x606c0020",
210 "0x60770010",
211 "0x60f40020",
212 "0x21110220",
213 "0x21130220"
214 ],
215 "0x1a01": [
216 "0x24010010",
217 "0x24020010",
218 "0x24030010",
219 "0x24040010",
220 "0x27020020"
221 ],
222 "0x1a02": [
223 "0x60fd0020"
224 ],
225 "0x1a03": [
226 "0x27040020",
227 "0x20f00020",
228 "0x60fc0020",
229 "0x606b0020",
230 "0x60740010",
231 "0x60790020"
232 ]
233 }
234 }
235})";
236
263int setPdoMappingFromUiConfig(ecx_contextt* context, uint16 slave);
264
282void checkPdoMapping(ecx_contextt* context, uint16 slave);
283
303uint16_t getSlaveState(ecx_contextt* context, uint16_t slave,
304 int timeoutUs = EC_TIMEOUTRET);
305
325bool isSlaveAnswering(ecx_contextt* context, uint16_t slave);
326
350
353 uint16_t value = 0;
355 uint16_t expected = 0;
356
358 [[nodiscard]] std::string describe() const;
359};
360
372 ecx_contextt* context, uint16_t slave, int timeoutUs = EC_TIMEOUTRET);
373
393std::string convertSlaveStateToString(int state);
394
417void updateMailboxSyncManagersOnNextState(ecx_contextt* context, uint16_t slave,
418 int targetState);
419
434
456bool resetMailboxCounter(ecx_contextt* context, uint16_t slave);
457
473void configureDetectedSmmModule(ecx_contextt* context, uint16_t slave);
474
512void transitionSlaves(ecx_contextt* context,
513 const std::vector<uint16_t>& positions,
514 uint16_t requiredState, uint16_t targetState,
515 const char* targetName,
516 std::chrono::steady_clock::duration timeout,
517 std::chrono::steady_clock::duration resendInterval =
518 std::chrono::seconds(2),
519 std::function<void()> tick = nullptr,
520 std::function<bool()> shouldAbort = nullptr);
521
534bool setSlaveState(
535 ecx_contextt* context, uint16_t slave, uint16_t targetState,
536 std::chrono::steady_clock::duration timeout = std::chrono::seconds(5));
537
571std::vector<uint8_t> readSii(ecx_contextt* context, uint16 position);
572
584mm::comm::base::PdoMappings readPdoMappings(ecx_contextt* context,
585 uint16_t slave);
586
602 const std::vector<mm::comm::base::PdoMappingEntry>& entries);
603
615void logIoMap(uint8_t* ioMap, size_t totalBytes);
616
631struct Fieldbus {
632 ecx_contextt context;
633 std::string iface;
634 uint8 group;
636
637 /* Used by the context */
638 uint8 map[4096];
639 ecx_portt port;
640 ec_slavet slavelist[EC_MAXSLAVE];
642 ec_groupt grouplist[EC_MAXGROUP];
643 uint8 esibuf[EC_MAXEEPBUF];
644 uint32 esimap[EC_MAXEEPBITMAP];
645 ec_eringt elist;
646 ec_idxstackT idxstack;
647 boolean ecaterror;
648 int64 DCtime;
649 ec_SMcommtypet SMcommtype[EC_MAX_MAPT];
650 ec_PDOassignt PDOassign[EC_MAX_MAPT];
651 ec_PDOdesct PDOdesc[EC_MAX_MAPT];
652 ec_eepromSMt eepSM;
653 ec_eepromFMMUt eepFMMU;
654};
655
670 uint16_t readLength;
671
678 uint16_t readOffset;
679
691
698 uint16_t writeLength;
699
706 uint16_t writeOffset;
707};
708
710 supportedProtocols, writeLength, writeOffset)
711
712
719struct SlaveInfoSyncManager {
728 uint32_t flags;
729
736 uint16_t length;
737
743 uint16_t startAddress;
744
755 uint8_t type;
756};
757
758NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SlaveInfoSyncManager, flags, length,
759 startAddress, type)
760
761
768struct SlaveInfoFmmu {
774 uint8_t active;
775
782 uint8_t logicalEndBit;
783
790 uint8_t logicalStartBit;
791
797 uint32_t logicalStartAddress;
798
804 uint16_t logicalLength;
805
812 uint8_t physicalStartBit;
813
819 uint16_t physicalStartAddress;
820
827 uint8_t type;
828};
829
830NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SlaveInfoFmmu, active, logicalEndBit,
831 logicalStartBit, logicalStartAddress,
832 logicalLength, physicalStartBit,
833 physicalStartAddress, type)
834
835
841struct SlaveInfo {
848 uint16_t alStatusCode;
849
856 uint16_t aliasAddress;
857
863 std::vector<SlaveInfoFmmu> fmmus;
864
871 SlaveInfoMailbox mailbox;
872
880 uint32_t productCode;
881
887 uint32_t position;
888
896 uint32_t revisionNumber;
897
904 std::vector<SlaveInfoSyncManager> syncManagers;
905
911 std::string name;
912
921 uint32_t vendorId;
922};
923
924NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SlaveInfo, alStatusCode, aliasAddress, fmmus,
925 mailbox, productCode, position,
926 revisionNumber, syncManagers, name, vendorId)
927
928
940SlaveInfo getSlaveInfo(ecx_contextt* context, uint16 position);
941
958void logSlaveInfo(ecx_contextt* context, uint16 position);
959
977void initFieldbus(std::unique_ptr<Fieldbus>& fieldbus,
978 const std::string& iface);
979
984class Slave {
985 public:
996 explicit Slave(ecx_contextt& context, uint16_t position);
997
1006 uint16_t position() const;
1007
1016 uint32_t vendorId() const;
1017
1026 uint32_t productCode() const;
1027
1036 uint32_t revisionNumber() const;
1037
1043 int getState() const;
1044
1064 bool setState(int targetState, int timeoutMs = 0, int intervalMs = 100);
1065
1087 tl::expected<void, std::string> loadParameters(bool readValues = false);
1088
1101 void logParameters() const;
1102
1119
1136
1143 void clearParameters();
1144
1153 std::unordered_map<mm::comm::base::Parameter::Address,
1155 parametersMap();
1156
1169 mm::comm::base::Parameter& findParameter(uint16_t index, uint8_t subindex);
1170
1198 template <typename T = std::vector<uint8_t>>
1199 T upload(uint16_t index, uint8_t subindex, bool refresh = true) {
1200 std::lock_guard<std::recursive_mutex> lock(controlPlaneMutex());
1201
1202 // Check if the device is in a valid state for uploading
1203 auto state = context_.slavelist[position_].state;
1204 if (state == EC_STATE_INIT || state == EC_STATE_BOOT) {
1205 throw std::runtime_error(
1206 "To upload object dictionary entries, the device must be in the (2) "
1207 "PRE-OPERATIONAL, (4) SAFE-OPERATIONAL, or (8) OPERATIONAL state. "
1208 "The current state is " +
1209 convertSlaveStateToString(state) + ".");
1210 }
1211
1212 // Find the previously loaded parameter
1213 auto& parameter = findParameter(index, subindex);
1214
1215 // Refresh data if needed (SDO read)
1216 if (refresh) {
1217 const std::unique_ptr<std::uint8_t[]> data =
1218 std::make_unique<std::uint8_t[]>(parameter.byteLength);
1219 auto wkc =
1220 ecx_SDOread(&context_, position_, parameter.index, parameter.subindex,
1221 false, &parameter.byteLength, data.get(), kSdoTimeoutUs);
1222 if (wkc <= 0) {
1223 LOG_F(ERROR, "Device %d: SDO read failed for %#04x:%02x! WKC: %d",
1224 position_, parameter.index, parameter.subindex, wkc);
1225 auto id = mm::comm::base::makeParameterId(parameter.index,
1226 parameter.subindex);
1227 throw std::runtime_error("Device " + std::to_string(position_) +
1228 ": SDO read failed for " + id +
1229 "! WKC: " + std::to_string(wkc));
1230 } else {
1231 std::vector<uint8_t> receivedData(data.get(),
1232 data.get() + parameter.byteLength);
1233 if (!parameter.trySetValue(receivedData)) {
1234 LOG_F(ERROR,
1235 "Device %d: Failed to set the value of parameter %#04x:%02x!",
1236 position_, parameter.index, parameter.subindex);
1237 }
1238 }
1239 }
1240
1241 // Return the appropriate type
1242 if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
1243 return parameter.data; // parameter.data should be std::vector<uint8_t>
1244 } else {
1245 // Otherwise, try to get the value as the requested type T
1246 auto value = parameter.getValue();
1247 if (auto ptr = std::get_if<T>(&value)) {
1248 return *ptr;
1249 } else {
1250 throw std::bad_variant_access(); // Type mismatch
1251 }
1252 }
1253 }
1254
1279 template <typename T = std::vector<uint8_t>>
1280 bool download(uint16_t index, uint8_t subindex, const T& value) {
1281 std::lock_guard<std::recursive_mutex> lock(controlPlaneMutex());
1282
1283 // Check if device is in valid state for download
1284 auto state = context_.slavelist[position_].state;
1285 if (state == EC_STATE_INIT || state == EC_STATE_BOOT) {
1286 throw std::runtime_error(
1287 "To download object dictionary entries, the device must be in the "
1288 "(2) PRE-OPERATIONAL, (4) SAFE-OPERATIONAL, or (8) OPERATIONAL "
1289 "state. The current state is " +
1290 convertSlaveStateToString(state) + ".");
1291 }
1292
1293 auto& parameter = findParameter(index, subindex);
1294
1295 // Convert value to raw byte data
1296 std::vector<uint8_t> data;
1297 if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
1298 data = value;
1299 } else {
1300 // Set the value in the parameter model
1301 if (!parameter.trySetValue(value)) {
1302 LOG_F(ERROR,
1303 "Device %d: Failed to set the value of parameter %#04x:%02x!",
1304 position_, parameter.index, parameter.subindex);
1305 return false;
1306 }
1307 data = parameter.data; // Use the parameter's byte representation
1308 }
1309
1310 // Check if data size matches the expected parameter size
1311 if (data.size() != parameter.byteLength) {
1312 LOG_F(ERROR, "Data size mismatch: expected %d, got %zu",
1313 parameter.byteLength, data.size());
1314 throw std::runtime_error("Data size does not match the parameter size!");
1315 }
1316
1317 // Perform the SDO write
1318 auto wkc =
1319 ecx_SDOwrite(&context_, position_, parameter.index, parameter.subindex,
1320 false, parameter.byteLength, data.data(), kSdoTimeoutUs);
1321
1322 // Check write result
1323 if (wkc <= 0) {
1324 LOG_F(ERROR, "Device %d: SDO write failed for %#04x:%02x! WKC: %d",
1325 position_, parameter.index, parameter.subindex, wkc);
1326 return false;
1327 }
1328
1329 return true;
1330 }
1331
1341
1350 void updatePdoMappings();
1351
1363 void logPdoMappings() const;
1364
1370 mm::comm::base::PdoMappings& getPdoMappings();
1371
1394 void updateOutputs();
1395
1417 void updateParametersFromInputs();
1418
1444 tl::expected<std::vector<uint8_t>, std::string> readFile(
1445 const std::string& filename,
1446 size_t maxFileSize = 1 * 1024 * 1024, // 1 MB default max file size
1447 int retries = 5,
1448 std::chrono::steady_clock::duration retryWait =
1449 std::chrono::milliseconds(100));
1450
1464 tl::expected<std::vector<std::uint8_t>, std::string> readSdo(
1465 uint16_t index, uint8_t subindex);
1466
1480 tl::expected<ec_ODlistt, std::string> readODList(
1481 int retries = 5, std::chrono::steady_clock::duration retryWait =
1482 std::chrono::milliseconds(100));
1483
1502 tl::expected<void, std::string> readODDescription(
1503 uint16_t item, ec_ODlistt& odList, int retries = 5,
1504 std::chrono::steady_clock::duration retryWait =
1505 std::chrono::milliseconds(100));
1506
1523 tl::expected<ec_OElistt, std::string> readOE(
1524 uint16_t item, ec_ODlistt& odList, int retries = 5,
1525 std::chrono::steady_clock::duration retryWait =
1526 std::chrono::milliseconds(100));
1527
1528 private:
1529 ecx_contextt& context_;
1530 const uint16_t position_;
1533 std::unordered_map<mm::comm::base::Parameter::Address,
1535 parametersMap_;
1538 pdoMappings_;
1539};
1540
1541class Master {
1542 public:
1549 explicit Master();
1550
1561 explicit Master(const std::string& iface);
1562
1614 void init(const std::string& iface);
1615
1626 void deinit();
1627
1634 ~Master();
1635
1645 Fieldbus& getFieldbus() const;
1646
1655 std::string getInterfaceName() const;
1656
1665 size_t getIoMapSize() const;
1666
1729 tl::expected<int, std::string> initSlaves();
1730
1742 const std::vector<std::unique_ptr<Slave>>& slaves() const;
1743
1753 inline int expectedWkc() const {
1754 return fieldbus_->context.grouplist[fieldbus_->group].outputsWKC * 2 +
1755 fieldbus_->context.grouplist[fieldbus_->group].inputsWKC;
1756 }
1757
1767 int roundtrip();
1768
1798
1809 bool start();
1810
1811 private:
1825 std::unique_ptr<Fieldbus> fieldbus_;
1826
1838 std::vector<std::unique_ptr<Slave>> slaves_;
1839};
1840}; // namespace mm::comm::soem
Represents a device parameter identified by index and subindex.
Definition base.h:529
std::pair< uint16_t, uint8_t > Address
Alias for a pair of uint16_t and uint8_t representing a parameter address.
Definition base.h:539
int roundtrip()
Performs a complete send/receive process data cycle on the fieldbus.
Definition soem.cc:1981
Master()
Default constructor for the Master class.
Definition soem.cc:1898
const std::vector< std::unique_ptr< Slave > > & slaves() const
Returns a reference to the list of slaves.
Definition soem.cc:1977
tl::expected< int, std::string > initSlaves()
Initializes the slave devices on the EtherCAT network.
Definition soem.cc:1950
void exchangeProcessDataAndUpdateParameters()
Exchanges process data with slaves and updates parameters based on the response.
Definition soem.cc:1986
size_t getIoMapSize() const
Returns the total size of the I/O map for the current group.
Definition soem.cc:1945
Fieldbus & getFieldbus() const
Returns a reference to the Fieldbus instance.
Definition soem.cc:1941
void init(const std::string &iface)
Initializes the fieldbus using the specified network interface.
Definition soem.cc:1905
std::string getInterfaceName() const
Retrieves the interface name used by the fieldbus.
Definition soem.cc:1943
void deinit()
Deinitializes the fieldbus and releases associated resources.
Definition soem.cc:1923
bool start()
Initializes and starts the fieldbus master.
Definition soem.cc:2009
~Master()
Destructor for the Master class.
Definition soem.cc:1939
int expectedWkc() const
Calculates the expected working counter (WKC) for the current fieldbus group.
Definition soem.h:1753
uint32_t productCode() const
Gets the Product Code of the slave device.
Definition soem.cc:1350
uint32_t vendorId() const
Gets the Vendor ID of the slave device.
Definition soem.cc:1346
std::unordered_map< mm::comm::base::Parameter::Address, mm::comm::base::Parameter > & parametersMap()
Returns a reference to the internal parameters map.
Definition soem.cc:1664
mm::comm::base::Parameter & findParameter(uint16_t index, uint8_t subindex)
Finds and returns a reference to a Parameter in the parameters map.
Definition soem.cc:1668
uint32_t revisionNumber() const
Gets the Revision Number of the slave device.
Definition soem.cc:1354
T upload(uint16_t index, uint8_t subindex, bool refresh=true)
Uploads a parameter value from the device's object dictionary.
Definition soem.h:1199
tl::expected< void, std::string > loadParameters(bool readValues=false)
Loads the parameters (object dictionary entries) from the EtherCAT slave device.
Definition soem.cc:1476
void clearParameters()
Clears all loaded object dictionary parameters.
Definition soem.cc:1660
void logTxPdoMappedParameters()
Logs all mapped TxPDO parameters with their current values.
Definition soem.cc:1645
Slave(ecx_contextt &context, uint16_t position)
Constructs a Slave object with a given context and position.
Definition soem.cc:1341
void logRxPdoMappedParameters()
Logs all mapped RxPDO parameters with their current values.
Definition soem.cc:1630
bool setState(int targetState, int timeoutMs=0, int intervalMs=100)
Attempts to set the slave to the specified EtherCAT state and optionally waits until it is reached.
Definition soem.cc:1360
void logParameters() const
Logs all loaded object dictionary parameters.
Definition soem.cc:1624
int getState() const
Reads the current state of the slave directly from the device.
Definition soem.cc:1358
uint16_t position() const
Gets the position of the slave.
Definition soem.cc:1344
bool download(uint16_t index, uint8_t subindex, const T &value)
Downloads a value to the specified object dictionary entry via SDO.
Definition soem.h:1280
uint8_t type
Definition co_dictionary.h:1
const char ** name
Definition co_dictionary.h:7
uint8_t * value
Definition co_dictionary.h:9
uint16_t index
Definition co_dictionary.h:0
std::string makeParameterId(int index, int subindex)
Formats the given index and subindex into a parameter identifier string.
Definition base.h:1657
Definition soem.cc:44
constexpr int kFoeReadTimeoutUs
Definition soem.h:37
IghMasterModule readIghMasterModule(const std::string &moduleDirectory)
Reads the IgH EtherCAT Master kernel module's state from sysfs.
Definition soem.cc:269
mm::comm::base::PdoMappings readPdoMappings(ecx_contextt *context, uint16_t slave)
Read and parse all mapped PDO entries for a given slave.
Definition soem.cc:1239
constexpr int kFoeTimeoutUs
Definition soem.h:30
void logPdoMappingEntries(const std::vector< mm::comm::base::PdoMappingEntry > &entries)
Logs PDO mapping entries grouped by PDO index.
Definition soem.cc:1310
uint16_t getSlaveState(ecx_contextt *context, uint16_t slave, int timeoutUs)
Reads the current state of a specific EtherCAT slave directly from the device via an FPRD datagram.
Definition soem.cc:728
std::string convertSlaveStateToString(int state)
Converts a numeric EtherCAT state value into a human-readable string.
Definition soem.cc:806
void resetBootMailboxTracking()
Clears the internal record of which slaves hold BOOT-sized mailbox sync managers.
Definition soem.cc:844
constexpr int kSdoTimeoutUs
Definition soem.h:27
std::string drainMailboxErrors(ecx_contextt *context)
Empties SOEM's error list and describes the first entry found.
Definition soem.cc:57
void transitionSlaves(ecx_contextt *context, const std::vector< uint16_t > &positions, uint16_t requiredState, uint16_t targetState, const char *targetName, std::chrono::steady_clock::duration timeout, std::chrono::steady_clock::duration resendInterval, std::function< void()> tick, std::function< bool()> shouldAbort)
Transitions multiple EtherCAT slaves to a target state using a single-threaded fire-then-poll pattern...
Definition soem.cc:887
std::string uiConfigWithDefaultPdoMapping
Default UI configuration used for PDO mapping.
Definition soem.h:181
void initFieldbus(std::unique_ptr< Fieldbus > &fieldbus, const std::string &iface)
Initializes a Fieldbus instance for EtherCAT communication.
Definition soem.cc:1865
void updateMailboxSyncManagersOnNextState(ecx_contextt *context, uint16_t slave, int targetState)
Updates the mailbox and sync manager (SM) configurations for an EtherCAT slave when transitioning to ...
Definition soem.cc:1021
bool isSlaveAnswering(ecx_contextt *context, uint16_t slave)
Tells whether a slave still answers at its configured station address.
Definition soem.cc:743
void logIoMap(uint8_t *ioMap, size_t totalBytes)
Logs the I/O map as a formatted hexadecimal string.
Definition soem.cc:1331
void checkPdoMapping(ecx_contextt *context, uint16 slave)
Diagnoses and prints the PDO mapping for a given slave.
Definition soem.cc:644
void configureDetectedSmmModule(ecx_contextt *context, uint16_t slave)
Reads the detected SMM module ID from the slave device and configures the module identification objec...
Definition soem.cc:1151
constexpr int kFoeRemoveTimeoutUs
Definition soem.h:42
int drainMailbox(ecx_contextt *context, uint16_t slave)
Discards whatever is sitting in a slave's read mailbox.
Definition soem.cc:103
std::map< std::string, std::string > mapMacAddressesToInterfaces()
Maps MAC addresses to their corresponding network interface names.
Definition soem.cc:137
int setPdoMappingFromUiConfig(ecx_contextt *context, uint16 slave)
Sets PDO mapping for a specified EtherCAT slave using UI configuration.
Definition soem.cc:446
uint16 position
Definition soem.h:940
void logSlaveInfo(ecx_contextt *context, uint16 position)
Logs detailed information about a specific EtherCAT slave in JSON format.
Definition soem.cc:353
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SlaveInfoMailbox, readLength, readOffset, supportedProtocols, writeLength, writeOffset) struct SlaveInfoSyncManager
Information about a slave's Sync Manager (SM) configuration.
Definition soem.h:709
StationAddressReading readStationAddressByPosition(ecx_contextt *context, uint16_t slave, int timeoutUs)
Reads a slave's station address register (0x0010) by the slave's position on the bus.
Definition soem.cc:781
std::recursive_mutex & controlPlaneMutex()
The single mutex that serialises every control-plane transaction.
Definition soem.cc:52
constexpr int kFoeRemoveEsiTimeoutUs
Definition soem.h:46
SlaveInfo getSlaveInfo(ecx_contextt *context, uint16 position)
Definition soem.cc:301
std::vector< uint8_t > readSii(ecx_contextt *context, uint16 position)
Read the complete Slave Information Interface (SII) EEPROM from an EtherCAT slave device.
Definition soem.cc:1196
bool resetMailboxCounter(ecx_contextt *context, uint16_t slave)
Makes the slave forget the counter of the last mailbox request.
Definition soem.cc:849
bool setSlaveState(ecx_contextt *context, uint16_t slave, uint16_t targetState, std::chrono::steady_clock::duration timeout)
Transitions a single EtherCAT slave to targetState.
Definition soem.cc:1013
Specialization of std::hash for std::pair<uint16_t, uint8_t>.
Definition util.h:612
Represents the mapped PDO entries for a slave device.
Definition base.h:171
Structure representing the Fieldbus configuration and context for EtherCAT communication.
Definition soem.h:631
boolean ecaterror
Definition soem.h:647
ec_idxstackT idxstack
Definition soem.h:646
ec_eepromFMMUt eepFMMU
Definition soem.h:653
ec_groupt grouplist[EC_MAXGROUP]
Definition soem.h:642
std::string iface
Definition soem.h:633
uint8 group
Definition soem.h:634
int slavecount
Definition soem.h:641
uint8 esibuf[EC_MAXEEPBUF]
Definition soem.h:643
uint32 esimap[EC_MAXEEPBITMAP]
Definition soem.h:644
int64 DCtime
Definition soem.h:648
ec_eepromSMt eepSM
Definition soem.h:652
ec_PDOassignt PDOassign[EC_MAX_MAPT]
Definition soem.h:650
uint8 map[4096]
Definition soem.h:638
ecx_contextt context
Definition soem.h:632
int roundtripTime
Definition soem.h:635
ec_PDOdesct PDOdesc[EC_MAX_MAPT]
Definition soem.h:651
ecx_portt port
Definition soem.h:639
ec_slavet slavelist[EC_MAXSLAVE]
Definition soem.h:640
ec_SMcommtypet SMcommtype[EC_MAX_MAPT]
Definition soem.h:649
ec_eringt elist
Definition soem.h:645
The IgH EtherCAT Master kernel module, as the running kernel reports it.
Definition soem.h:139
bool isConfiguredFor(const std::string &macAddress) const
Definition soem.cc:258
std::vector< std::string > devices
Definition soem.h:146
bool loaded
Whether the ec_master module is loaded.
Definition soem.h:141
Information about a slave's mailbox configuration.
Definition soem.h:663
uint16_t writeOffset
Offset of the mailbox write area within the slave's memory.
Definition soem.h:706
uint16_t supportedProtocols
Supported mailbox protocols as a bitmask.
Definition soem.h:690
uint16_t readOffset
Offset of the mailbox read area within the slave's memory.
Definition soem.h:678
uint16_t readLength
Length of the mailbox read area (in bytes).
Definition soem.h:670
uint16_t writeLength
Length of the mailbox write area (in bytes).
Definition soem.h:698
What a slave's station address register holds, read by the slave's position on the bus.
Definition soem.h:334
@ kIntact
The register holds the configured address. The address is intact.
Definition soem.h:348
Kind kind
Definition soem.h:351
uint16_t expected
The station address ec_config_init() gave the slave.
Definition soem.h:355
std::string describe() const
One sentence for the log that says what the reading means.
Definition soem.cc:756
uint16_t value
The value read from the register. 0 when kind is kNoAnswer.
Definition soem.h:353