Added ec_master_find_slave_const().
This commit is contained in:
parent
05c4c09b64
commit
f10cc06840
|
|
@ -1023,6 +1023,29 @@ void ec_master_attach_slave_configs(
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/** Common implementation for ec_master_find_slave()
|
||||
* and ec_master_find_slave_const().
|
||||
*/
|
||||
#define EC_FIND_SLAVE \
|
||||
do { \
|
||||
if (alias) { \
|
||||
for (; slave < master->slaves + master->slave_count; \
|
||||
slave++) { \
|
||||
if (slave->sii.alias == alias) \
|
||||
break; \
|
||||
} \
|
||||
if (slave == master->slaves + master->slave_count) \
|
||||
return NULL; \
|
||||
} \
|
||||
\
|
||||
slave += position; \
|
||||
if (slave < master->slaves + master->slave_count) { \
|
||||
return slave; \
|
||||
} else { \
|
||||
return NULL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/** Finds a slave in the bus, given the alias and position.
|
||||
*/
|
||||
ec_slave_t *ec_master_find_slave(
|
||||
|
|
@ -1032,24 +1055,21 @@ ec_slave_t *ec_master_find_slave(
|
|||
)
|
||||
{
|
||||
ec_slave_t *slave = master->slaves;
|
||||
EC_FIND_SLAVE;
|
||||
}
|
||||
|
||||
if (alias) {
|
||||
// find slave with the given alias
|
||||
for (; slave < master->slaves + master->slave_count;
|
||||
slave++) {
|
||||
if (slave->sii.alias == alias)
|
||||
break;
|
||||
}
|
||||
if (slave == master->slaves + master->slave_count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
slave += position;
|
||||
if (slave < master->slaves + master->slave_count) {
|
||||
return slave;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
/** Finds a slave in the bus, given the alias and position.
|
||||
*
|
||||
* Const version.
|
||||
*/
|
||||
const ec_slave_t *ec_master_find_slave_const(
|
||||
const ec_master_t *master, /**< EtherCAT master. */
|
||||
uint16_t alias, /**< Slave alias. */
|
||||
uint16_t position /**< Slave position. */
|
||||
)
|
||||
{
|
||||
const ec_slave_t *slave = master->slaves;
|
||||
EC_FIND_SLAVE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -190,6 +190,8 @@ void ec_master_queue_datagram(ec_master_t *, ec_datagram_t *);
|
|||
// misc.
|
||||
void ec_master_attach_slave_configs(ec_master_t *);
|
||||
ec_slave_t *ec_master_find_slave(ec_master_t *, uint16_t, uint16_t);
|
||||
const ec_slave_t *ec_master_find_slave_const(const ec_master_t *, uint16_t,
|
||||
uint16_t);
|
||||
void ec_master_output_stats(ec_master_t *);
|
||||
#ifdef EC_EOE
|
||||
void ec_master_clear_eoe_handlers(ec_master_t *);
|
||||
|
|
|
|||
Loading…
Reference in New Issue