diff --git a/master/cdev.c b/master/cdev.c index 0ca0e99a3f9210971c9cc6ab16af9c05e59a2bea..daf72206ed34710990c29df80843a759bf688053 100644 --- a/master/cdev.c +++ b/master/cdev.c @@ -285,7 +285,7 @@ int ec_cdev_ioctl_slave( data.product_code = slave->sii.product_code; data.revision_number = slave->sii.revision_number; data.serial_number = slave->sii.serial_number; - data.alias = slave->sii.alias; + data.alias = slave->effective_alias; data.boot_rx_mailbox_offset = slave->sii.boot_rx_mailbox_offset; data.boot_rx_mailbox_size = slave->sii.boot_rx_mailbox_size; data.boot_tx_mailbox_offset = slave->sii.boot_tx_mailbox_offset; diff --git a/master/ethernet.c b/master/ethernet.c index dc46a7ce233463138cb9d668953e46b4721ecb5c..0a545a65e93ae9db7096ec2efaa8954b0a54d59f 100644 --- a/master/ethernet.c +++ b/master/ethernet.c @@ -136,9 +136,9 @@ int ec_eoe_init( /* device name eoe<MASTER>[as]<SLAVE>, because networking scripts don't * like hyphens etc. in interface names. */ - if (slave->sii.alias) { + if (slave->effective_alias) { snprintf(name, EC_DATAGRAM_NAME_SIZE, - "eoe%ua%u", slave->master->index, slave->sii.alias); + "eoe%ua%u", slave->master->index, slave->effective_alias); } else { snprintf(name, EC_DATAGRAM_NAME_SIZE, "eoe%us%u", slave->master->index, slave->ring_position); diff --git a/master/fsm_master.c b/master/fsm_master.c index ca3976375f37bbb02686c1dadcc2b0ff753781e1..1bb24e15970ebc3c56968720b17585387d374876 100644 --- a/master/fsm_master.c +++ b/master/fsm_master.c @@ -877,6 +877,7 @@ void ec_fsm_master_state_write_sii( // alias was written slave->sii.alias = EC_READ_U16(request->words + 4); // TODO: read alias from register 0x0012 + slave->effective_alias = slave->sii.alias; } // TODO: Evaluate other SII contents! diff --git a/master/fsm_slave_scan.c b/master/fsm_slave_scan.c index 065149a00c69a2976edb29d185ae56d9b83a441e..d1600bfa7bacd8e4c7291d5f5e59c917a952fcea 100644 --- a/master/fsm_slave_scan.c +++ b/master/fsm_slave_scan.c @@ -609,6 +609,7 @@ void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *fsm /**< slave state slave->sii.alias = EC_READ_U16(slave->sii_words + 0x0004); + slave->effective_alias = slave->sii.alias; slave->sii.vendor_id = EC_READ_U32(slave->sii_words + 0x0008); slave->sii.product_code = @@ -738,9 +739,9 @@ void ec_fsm_slave_scan_enter_regalias( ec_datagram_t *datagram = fsm->datagram; ec_slave_t *slave = fsm->slave; - // read alias from register 0x0012 + // read alias from register if (slave->master->debug_level) - EC_DBG("Reading alias from register 0x0012 of slave %u.\n", + EC_DBG("Reading alias from register of slave %u.\n", slave->ring_position); ec_datagram_fprd(datagram, slave->station_address, 0x0012, 2); ec_datagram_zero(datagram); @@ -775,10 +776,10 @@ void ec_fsm_slave_scan_state_regalias( EC_WARN("Failed to read reg alias of slave %u.\n", fsm->slave->ring_position); } else { - slave->sii.alias = EC_READ_U16(datagram->data); + slave->effective_alias = EC_READ_U16(datagram->data); if (slave->master->debug_level) - EC_DBG("Alias of slave %u is %u.\n", - slave->ring_position,slave->sii.alias); + EC_DBG("Read alias %u from register of slave %u.\n", + slave->effective_alias, slave->ring_position); } if (slave->sii.mailbox_protocols & EC_MBOX_COE) { ec_fsm_slave_scan_enter_preop(fsm); diff --git a/master/master.c b/master/master.c index 7aa37b7789460d9890debc67010868ef17f3f934..16da35661e2d52316f6553e302d0ce0dc1a9e5c3 100644 --- a/master/master.c +++ b/master/master.c @@ -1526,7 +1526,7 @@ void ec_master_attach_slave_configs( if (alias) { \ for (; slave < master->slaves + master->slave_count; \ slave++) { \ - if (slave->sii.alias == alias) \ + if (slave->effective_alias == alias) \ break; \ } \ if (slave == master->slaves + master->slave_count) \ @@ -2262,7 +2262,7 @@ int ecrt_master_get_slave(ec_master_t *master, uint16_t slave_position, slave_info->product_code = slave->sii.product_code; slave_info->revision_number = slave->sii.revision_number; slave_info->serial_number = slave->sii.serial_number; - slave_info->alias = slave->sii.alias; + slave_info->alias = slave->effective_alias; slave_info->current_on_ebus = slave->sii.current_on_ebus; slave_info->al_state = slave->current_state; slave_info->error_flag = slave->error_flag; diff --git a/master/slave.c b/master/slave.c index 7e1462d7aa4abb58faf81511daa9c0120ddea211..90ab2eac93a7263d611fe49fa113c9968ae30b88 100644 --- a/master/slave.c +++ b/master/slave.c @@ -72,6 +72,7 @@ void ec_slave_init( slave->master = master; slave->ring_position = ring_position; slave->station_address = station_address; + slave->effective_alias = 0x0000; slave->config = NULL; slave->requested_state = EC_SLAVE_STATE_PREOP; diff --git a/master/slave.h b/master/slave.h index 563b1ec6e83b5bfdf2715bddbc24e688ecc6f23a..01476554ff2fe2b9797b3a898eee0048821506cb 100644 --- a/master/slave.h +++ b/master/slave.h @@ -116,6 +116,7 @@ struct ec_slave // addresses uint16_t ring_position; /**< Ring position. */ uint16_t station_address; /**< Configured station address. */ + uint16_t effective_alias; /**< Effective alias address. */ ec_slave_port_t ports[EC_MAX_PORTS]; /**< Ports. */