From 7036da66f415b1b698ea0a147211914ba9932ddd Mon Sep 17 00:00:00 2001 From: Bjarne von Horn Date: Tue, 11 Mar 2025 19:07:47 +0100 Subject: [PATCH] Add EtherCAT Master id to rtipc directory. Currently, having multiple rtipc instances with the same cache directory in one application does not work. So we use one directory per master instance. --- fake_lib/fakeethercat.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fake_lib/fakeethercat.cpp b/fake_lib/fakeethercat.cpp index d7eb006a..80f769d1 100644 --- a/fake_lib/fakeethercat.cpp +++ b/fake_lib/fakeethercat.cpp @@ -420,16 +420,16 @@ static const char *getName() return "FakeEtherCAT"; } -static const char *getRtIpcDir() +static std::string getRtIpcDir(int idx) { if (const auto ans = getenv("FAKE_EC_HOMEDIR")) { - return ans; + return ans + std::string("/") + std::to_string(idx); } - return "/tmp/FakeEtherCAT"; + return "/tmp/FakeEtherCAT/" + std::to_string(idx); } -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) +ec_master::ec_master(int id) : rt_ipc_dir(getRtIpcDir(id)), rt_ipc_name(getName()), rt_ipc(rtipc_create(rt_ipc_name.c_str(), rt_ipc_dir.c_str())), id_(id) { }