diff --git a/fake_lib/README.md b/fake_lib/README.md index de104f2e..fc5d0805 100644 --- a/fake_lib/README.md +++ b/fake_lib/README.md @@ -74,7 +74,7 @@ mkdir -p $FAKE_EC_HOMEDIR Now it's time to simply launch your application. You will notice that the PDO configuration will be dumped at stderr. The path displayed is the path of the RtIPC variable in the following format: -`$FAKE_EC_PREFIX/$DOMAIN_ID/$ALIAS$POSITION/$PDO`. +`$FAKE_EC_PREFIX/$MASTER_ID/$DOMAIN_ID/$ALIAS$POSITION/$PDO`. ## How to emulate EtherCAT slaves diff --git a/fake_lib/fakeethercat.cpp b/fake_lib/fakeethercat.cpp index 331db186..97b78bb8 100644 --- a/fake_lib/fakeethercat.cpp +++ b/fake_lib/fakeethercat.cpp @@ -118,7 +118,7 @@ int ec_domain::activate(int domain_id) slaves.insert(pdo.slave_address.getCombined()); void *rt_pdo = nullptr; char buf[512]; - const auto fmt = snprintf(buf, sizeof(buf), "%s/%d/%08X/%04X", prefix, domain_id, pdo.slave_address.getCombined(), pdo.pdo_index); + const auto fmt = snprintf(buf, sizeof(buf), "%s/%d/%d/%08X/%04X", prefix, master->getId(), domain_id, pdo.slave_address.getCombined(), pdo.pdo_index); if (fmt < 0 || fmt >= (int)sizeof(buf)) { return -ENOBUFS; @@ -384,7 +384,7 @@ ec_master_t *ecrt_request_master( unsigned int master_index /**< Index of the master to request. */ ) { - return new ec_master(); + return new ec_master(master_index); } static const char *getName() @@ -429,7 +429,7 @@ static std::vector getPermutationVector(size_t count) return ans; } -ec_master::ec_master() : rt_ipc_dir(getRtIpcDir()), rt_ipc_name(getName()), rt_ipc(rtipc_create(rt_ipc_name.c_str(), rt_ipc_dir.c_str())) +ec_master::ec_master(int id) : rt_ipc_dir(getRtIpcDir()), rt_ipc_name(getName()), rt_ipc(rtipc_create(rt_ipc_name.c_str(), rt_ipc_dir.c_str())), id_(id) { } diff --git a/fake_lib/fakeethercat.h b/fake_lib/fakeethercat.h index 1a06dd59..71bd21dc 100644 --- a/fake_lib/fakeethercat.h +++ b/fake_lib/fakeethercat.h @@ -208,14 +208,16 @@ private: std::list domains; std::map slaves; std::unique_ptr rt_ipc; + int id_; public: - ec_master(); + explicit ec_master(int id); int activate(); ec_domain *createDomain(); int getNoSlaves() const { return slaves.size(); } + int getId() const { return id_; } ec_slave_config_t *slave_config( uint16_t alias, /**< Slave alias. */