add multi-master support to fakelib.
This commit is contained in:
parent
b5c7527990
commit
45e8b098d7
|
|
@ -74,7 +74,7 @@ mkdir -p $FAKE_EC_HOMEDIR
|
||||||
Now it's time to simply launch your application.
|
Now it's time to simply launch your application.
|
||||||
You will notice that the PDO configuration will be dumped at stderr.
|
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:
|
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
|
## How to emulate EtherCAT slaves
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ int ec_domain::activate(int domain_id)
|
||||||
slaves.insert(pdo.slave_address.getCombined());
|
slaves.insert(pdo.slave_address.getCombined());
|
||||||
void *rt_pdo = nullptr;
|
void *rt_pdo = nullptr;
|
||||||
char buf[512];
|
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))
|
if (fmt < 0 || fmt >= (int)sizeof(buf))
|
||||||
{
|
{
|
||||||
return -ENOBUFS;
|
return -ENOBUFS;
|
||||||
|
|
@ -384,7 +384,7 @@ ec_master_t *ecrt_request_master(
|
||||||
unsigned int master_index /**< Index of the master to request. */
|
unsigned int master_index /**< Index of the master to request. */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return new ec_master();
|
return new ec_master(master_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *getName()
|
static const char *getName()
|
||||||
|
|
@ -429,7 +429,7 @@ static std::vector<size_t> getPermutationVector(size_t count)
|
||||||
return ans;
|
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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -208,14 +208,16 @@ private:
|
||||||
std::list<ec_domain> domains;
|
std::list<ec_domain> domains;
|
||||||
std::map<ec_address, ec_slave_config> slaves;
|
std::map<ec_address, ec_slave_config> slaves;
|
||||||
std::unique_ptr<struct rtipc, RtIpcDeleter> rt_ipc;
|
std::unique_ptr<struct rtipc, RtIpcDeleter> rt_ipc;
|
||||||
|
int id_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ec_master();
|
explicit ec_master(int id);
|
||||||
|
|
||||||
int activate();
|
int activate();
|
||||||
ec_domain *createDomain();
|
ec_domain *createDomain();
|
||||||
|
|
||||||
int getNoSlaves() const { return slaves.size(); }
|
int getNoSlaves() const { return slaves.size(); }
|
||||||
|
int getId() const { return id_; }
|
||||||
|
|
||||||
ec_slave_config_t *slave_config(
|
ec_slave_config_t *slave_config(
|
||||||
uint16_t alias, /**< Slave alias. */
|
uint16_t alias, /**< Slave alias. */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue