Added ec_slave_validate()
This commit is contained in:
parent
25964ccc9a
commit
41a6b5bfee
|
|
@ -439,16 +439,9 @@ ec_slave_t *ecrt_domain_register_pdo(ec_domain_t *domain,
|
|||
|
||||
master = domain->master;
|
||||
|
||||
// translate address
|
||||
// translate address and validate slave
|
||||
if (!(slave = ecrt_master_get_slave(master, address))) return NULL;
|
||||
|
||||
if (vendor_id != slave->sii_vendor_id ||
|
||||
product_code != slave->sii_product_code) {
|
||||
EC_ERR("Invalid slave type at position %i - Requested: 0x%08X 0x%08X,"
|
||||
" found: 0x%08X 0x%08X\".\n", slave->ring_position, vendor_id,
|
||||
product_code, slave->sii_vendor_id, slave->sii_product_code);
|
||||
return NULL;
|
||||
}
|
||||
if (ec_slave_validate(slave, vendor_id, product_code)) return NULL;
|
||||
|
||||
if (!data_ptr) {
|
||||
// data_ptr is NULL => mark slave as "registered" (do not warn)
|
||||
|
|
|
|||
|
|
@ -903,6 +903,27 @@ int ec_slave_conf_sdo(ec_slave_t *slave, /**< EtherCAT slave */
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
\return 0 in case of success, else < 0
|
||||
*/
|
||||
|
||||
int ec_slave_validate(const ec_slave_t *slave, /**< EtherCAT slave */
|
||||
uint32_t vendor_id, /**< vendor ID */
|
||||
uint32_t product_code /**< product code */
|
||||
)
|
||||
{
|
||||
if (vendor_id != slave->sii_vendor_id ||
|
||||
product_code != slave->sii_product_code) {
|
||||
EC_ERR("Invalid slave type at position %i - Requested: 0x%08X 0x%08X,"
|
||||
" found: 0x%08X 0x%08X\".\n", slave->ring_position, vendor_id,
|
||||
product_code, slave->sii_vendor_id, slave->sii_product_code);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Realtime interface
|
||||
*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -271,6 +271,8 @@ uint16_t ec_slave_calc_sync_size(const ec_slave_t *,
|
|||
int ec_slave_is_coupler(const ec_slave_t *);
|
||||
int ec_slave_has_subbus(const ec_slave_t *);
|
||||
|
||||
int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue