Better calc. of coupler address; coupler address in SysFS; better output of ec_list
This commit is contained in:
parent
269419fc07
commit
ad6b1732d6
|
|
@ -455,7 +455,8 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
|
|||
unsigned int i;
|
||||
ec_command_t *command;
|
||||
ec_eoe_t *eoe;
|
||||
uint16_t buscoupler_index, index_after_buscoupler;
|
||||
uint16_t coupler_index, coupler_subindex;
|
||||
uint16_t reverse_coupler_index, current_coupler_index;
|
||||
|
||||
if (!list_empty(&master->slaves)) {
|
||||
EC_ERR("Slave scan already done!\n");
|
||||
|
|
@ -490,8 +491,10 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
|
|||
list_add_tail(&slave->list, &master->slaves);
|
||||
}
|
||||
|
||||
buscoupler_index = 0xFFFF;
|
||||
index_after_buscoupler = 0;
|
||||
coupler_index = 0;
|
||||
reverse_coupler_index = 0xFFFF;
|
||||
current_coupler_index = 0x3FFF;
|
||||
coupler_subindex = 0;
|
||||
|
||||
// For every slave on the bus
|
||||
list_for_each_entry(slave, &master->slaves, list) {
|
||||
|
|
@ -520,20 +523,22 @@ int ec_master_bus_scan(ec_master_t *master /**< EtherCAT-Master */)
|
|||
ident++;
|
||||
}
|
||||
|
||||
if (!slave->type)
|
||||
if (!slave->type) {
|
||||
EC_WARN("Unknown slave device (vendor 0x%08X, code 0x%08X) at"
|
||||
" position %i.\n", slave->sii_vendor_id,
|
||||
slave->sii_product_code, i);
|
||||
else {
|
||||
if (slave->type->special == EC_TYPE_BUS_COUPLER) {
|
||||
buscoupler_index++;
|
||||
index_after_buscoupler = 0;
|
||||
}
|
||||
}
|
||||
else if (slave->type->special == EC_TYPE_BUS_COUPLER) {
|
||||
if (slave->sii_alias)
|
||||
current_coupler_index = reverse_coupler_index--;
|
||||
else
|
||||
current_coupler_index = coupler_index++;
|
||||
coupler_subindex = 0;
|
||||
}
|
||||
|
||||
slave->buscoupler_index = buscoupler_index;
|
||||
slave->index_after_buscoupler = index_after_buscoupler;
|
||||
index_after_buscoupler++;
|
||||
slave->coupler_index = current_coupler_index;
|
||||
slave->coupler_subindex = coupler_subindex;
|
||||
coupler_subindex++;
|
||||
|
||||
// Does the slave support EoE?
|
||||
if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
|
||||
|
|
@ -679,10 +684,15 @@ ec_slave_t *ecrt_master_get_slave(const ec_master_t *master, /**< Master */
|
|||
}
|
||||
|
||||
if (alias_requested) {
|
||||
if (!alias_slave->type ||
|
||||
alias_slave->type->special != EC_TYPE_BUS_COUPLER) {
|
||||
EC_ERR("Slave address \"%s\": Alias slave must be bus coupler"
|
||||
" in colon mode.\n", address);
|
||||
return NULL;
|
||||
}
|
||||
list_for_each_entry(slave, &master->slaves, list) {
|
||||
if (slave->buscoupler_index == alias_slave->buscoupler_index
|
||||
&& alias_slave->index_after_buscoupler == 0
|
||||
&& slave->index_after_buscoupler == second)
|
||||
if (slave->coupler_index == alias_slave->coupler_index
|
||||
&& slave->coupler_subindex == second)
|
||||
return slave;
|
||||
}
|
||||
EC_ERR("Slave address \"%s\" - Bus coupler %i has no %lu. slave"
|
||||
|
|
@ -692,8 +702,8 @@ ec_slave_t *ecrt_master_get_slave(const ec_master_t *master, /**< Master */
|
|||
}
|
||||
else {
|
||||
list_for_each_entry(slave, &master->slaves, list) {
|
||||
if (slave->buscoupler_index == first
|
||||
&& slave->index_after_buscoupler == second) return slave;
|
||||
if (slave->coupler_index == first
|
||||
&& slave->coupler_subindex == second) return slave;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ ssize_t ec_show_slave_attribute(struct kobject *, struct attribute *, char *);
|
|||
/*****************************************************************************/
|
||||
|
||||
EC_SYSFS_READ_ATTR(ring_position);
|
||||
EC_SYSFS_READ_ATTR(station_address);
|
||||
EC_SYSFS_READ_ATTR(coupler_address);
|
||||
EC_SYSFS_READ_ATTR(vendor_name);
|
||||
EC_SYSFS_READ_ATTR(product_name);
|
||||
EC_SYSFS_READ_ATTR(product_desc);
|
||||
|
|
@ -37,7 +37,7 @@ EC_SYSFS_READ_ATTR(type);
|
|||
|
||||
static struct attribute *def_attrs[] = {
|
||||
&attr_ring_position,
|
||||
&attr_station_address,
|
||||
&attr_coupler_address,
|
||||
&attr_vendor_name,
|
||||
&attr_product_name,
|
||||
&attr_product_desc,
|
||||
|
|
@ -89,8 +89,8 @@ int ec_slave_init(ec_slave_t *slave, /**< EtherCAT-Slave */
|
|||
}
|
||||
|
||||
slave->master = master;
|
||||
slave->buscoupler_index = 0;
|
||||
slave->index_after_buscoupler = 0xFFFF;
|
||||
slave->coupler_index = 0;
|
||||
slave->coupler_subindex = 0xFFFF;
|
||||
slave->base_type = 0;
|
||||
slave->base_revision = 0;
|
||||
slave->base_build = 0;
|
||||
|
|
@ -1211,8 +1211,9 @@ ssize_t ec_show_slave_attribute(struct kobject *kobj, /**< KObject */
|
|||
if (attr == &attr_ring_position) {
|
||||
return sprintf(buffer, "%i\n", slave->ring_position);
|
||||
}
|
||||
else if (attr == &attr_station_address) {
|
||||
return sprintf(buffer, "%i\n", slave->station_address);
|
||||
else if (attr == &attr_coupler_address) {
|
||||
return sprintf(buffer, "%i:%i\n", slave->coupler_index,
|
||||
slave->coupler_subindex);
|
||||
}
|
||||
else if (attr == &attr_vendor_name) {
|
||||
if (slave->type)
|
||||
|
|
|
|||
|
|
@ -196,8 +196,8 @@ struct ec_slave
|
|||
// Addresses
|
||||
uint16_t ring_position; /**< Position des Slaves im Bus */
|
||||
uint16_t station_address; /**< Konfigurierte Slave-Adresse */
|
||||
uint16_t buscoupler_index; /**< Letzter Buskoppler */
|
||||
uint16_t index_after_buscoupler; /**< Index hinter letztem Buskoppler */
|
||||
uint16_t coupler_index; /**< Letzter Buskoppler */
|
||||
uint16_t coupler_subindex; /**< Index hinter letztem Buskoppler */
|
||||
|
||||
// Base data
|
||||
uint8_t base_type; /**< Slave-Typ */
|
||||
|
|
|
|||
17
rt/msr_rt.c
17
rt/msr_rt.c
|
|
@ -62,8 +62,8 @@ uint32_t k_ssi;
|
|||
uint32_t k_ssi_st;
|
||||
|
||||
ec_field_init_t domain1_fields[] = {
|
||||
{&r_ssi, "5", "Beckhoff", "EL5001", "InputValue", 0},
|
||||
{&r_ssi_st, "5", "Beckhoff", "EL5001", "Status", 0},
|
||||
{&r_ssi, "0:3", "Beckhoff", "EL5001", "InputValue", 0},
|
||||
{&r_ssi_st, "0:3", "Beckhoff", "EL5001", "Status", 0},
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ int __init init_rt_module(void)
|
|||
#endif
|
||||
|
||||
#if 1
|
||||
if (!(slave = ecrt_master_get_slave(master, "5"))) {
|
||||
if (!(slave = ecrt_master_get_slave(master, "0:3"))) {
|
||||
printk(KERN_ERR "Failed to get slave!\n");
|
||||
goto out_deactivate;
|
||||
}
|
||||
|
|
@ -205,6 +205,17 @@ int __init init_rt_module(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
if (!(slave = ecrt_master_get_slave(master, "1:0"))) {
|
||||
printk(KERN_ERR "Failed to get slave!\n");
|
||||
goto out_deactivate;
|
||||
}
|
||||
if (ecrt_slave_write_alias(slave, 0x5678)) {
|
||||
printk(KERN_ERR "Failed to write alias!\n");
|
||||
goto out_deactivate;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ASYNC
|
||||
// Einmal senden und warten...
|
||||
ecrt_master_prepare_async_io(master);
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ sub query_slaves
|
|||
my $vendor_name;
|
||||
my @slaves;
|
||||
my $slave;
|
||||
my $abs;
|
||||
|
||||
unless (opendir $dirhandle, $master_dir) {
|
||||
print "Failed to open directory \"$master_dir\".\n";
|
||||
|
|
@ -55,8 +56,8 @@ sub query_slaves
|
|||
$slave = {};
|
||||
$slave->{'ring_position'} =
|
||||
&read_integer("$slave_dir/ring_position");
|
||||
$slave->{'station_address'} =
|
||||
&read_integer("$slave_dir/station_address");
|
||||
$slave->{'coupler_address'} =
|
||||
&read_string("$slave_dir/coupler_address");
|
||||
$slave->{'vendor_name'} =
|
||||
&read_string("$slave_dir/vendor_name");
|
||||
$slave->{'product_name'} =
|
||||
|
|
@ -72,31 +73,17 @@ sub query_slaves
|
|||
|
||||
@slaves = sort { $a->{'ring_position'} <=> $b->{'ring_position'} } @slaves;
|
||||
|
||||
my $coupler_index = -1;
|
||||
my $slave_index = 0;
|
||||
my $abs;
|
||||
my $rel;
|
||||
print "EtherCAT bus listing for master $master_index:\n";
|
||||
for $slave (@slaves) {
|
||||
if ($slave->{'type'} eq "coupler") {
|
||||
print "--------------------------------------------------------\n";
|
||||
$coupler_index++;
|
||||
$slave_index = 0;
|
||||
}
|
||||
|
||||
$abs = sprintf "%i", $slave->{'ring_position'};
|
||||
$rel = sprintf "%i:%i", $coupler_index, $slave_index;
|
||||
printf("%4s %6s %-15s %-15s %-15s\n", $abs, $rel,
|
||||
$slave->{'vendor_name'}, $slave->{'product_name'},
|
||||
$slave->{'product_desc'});
|
||||
|
||||
if ($slave->{'type'} eq "coupler") {
|
||||
print "--------------------------------------------------------\n";
|
||||
}
|
||||
|
||||
$slave_index++;
|
||||
printf(" %3s %8s %-12s %-10s %s\n", $abs,
|
||||
$slave->{'coupler_address'}, $slave->{'vendor_name'},
|
||||
$slave->{'product_name'}, $slave->{'product_desc'});
|
||||
}
|
||||
print "--------------------------------------------------------\n";
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Reference in New Issue