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.
This commit is contained in:
Bjarne von Horn 2025-03-11 19:07:47 +01:00
parent 5bbf53a376
commit 7036da66f4
1 changed files with 4 additions and 4 deletions

View File

@ -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)
{
}