Skip to content
Snippets Groups Projects
Commit 2862e758 authored by Florian Pose's avatar Florian Pose
Browse files

Broadcast MAC address accepts first device.

parent 7cb79e76
No related branches found
No related tags found
No related merge requests found
...@@ -13,7 +13,8 @@ Changes in version 1.3.0: ...@@ -13,7 +13,8 @@ Changes in version 1.3.0:
dynamically instead. dynamically instead.
* Added "main" and "backup" parameters to master module to hand over the * Added "main" and "backup" parameters to master module to hand over the
MAC addresses of the devices to wait for. This made the ec_device_index MAC addresses of the devices to wait for. This made the ec_device_index
parameter of the ethernet drivers obsolete. parameter of the ethernet drivers obsolete. The broadcast MAC address means,
that the master accepts the first device offered by any ethernet driver.
* Changed format of sysconfig file and accordingly adjusted functionality * Changed format of sysconfig file and accordingly adjusted functionality
of the init script to handle the above MAC address lists. of the init script to handle the above MAC address lists.
* Realtime interface changes: * Realtime interface changes:
......
...@@ -6,9 +6,6 @@ $Id$ ...@@ -6,9 +6,6 @@ $Id$
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
* Issues for release 1.3.0:
- Take broadcast MAC address to register the first ethernet device.
* Future features: * Future features:
- Interface/buffers for asynchronous domain IO. - Interface/buffers for asynchronous domain IO.
- Distributed clocks. - Distributed clocks.
......
...@@ -248,6 +248,19 @@ int ec_mac_is_zero(const uint8_t *mac) ...@@ -248,6 +248,19 @@ int ec_mac_is_zero(const uint8_t *mac)
/*****************************************************************************/ /*****************************************************************************/
int ec_mac_is_broadcast(const uint8_t *mac)
{
unsigned int i;
for (i = 0; i < ETH_ALEN; i++)
if (mac[i] != 0xff)
return 0;
return 1;
}
/*****************************************************************************/
static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty) static int ec_mac_parse(uint8_t *mac, const char *src, int allow_empty)
{ {
unsigned int i, value; unsigned int i, value;
...@@ -400,19 +413,19 @@ int ecdev_offer(struct net_device *net_dev, /**< net_device to offer */ ...@@ -400,19 +413,19 @@ int ecdev_offer(struct net_device *net_dev, /**< net_device to offer */
for (i = 0; i < master_count; i++) { for (i = 0; i < master_count; i++) {
master = &masters[i]; master = &masters[i];
if (ec_mac_equal(master->main_mac, net_dev->dev_addr)) {
ec_mac_print(master->main_mac, str); down(&master->device_sem);
if (master->main_device.dev) { // master already has a device
up(&master->device_sem);
continue;
}
if (ec_mac_equal(master->main_mac, net_dev->dev_addr)
|| ec_mac_is_broadcast(master->main_mac)) {
ec_mac_print(net_dev->dev_addr, str);
EC_INFO("Accepting device %s for master %u.\n", EC_INFO("Accepting device %s for master %u.\n",
str, master->index); str, master->index);
down(&master->device_sem);
if (master->main_device.dev) {
EC_ERR("Master %u already has a device attached.\n",
master->index);
up(&master->device_sem);
return -1;
}
ec_device_attach(&master->main_device, net_dev, poll, module); ec_device_attach(&master->main_device, net_dev, poll, module);
up(&master->device_sem); up(&master->device_sem);
...@@ -420,9 +433,13 @@ int ecdev_offer(struct net_device *net_dev, /**< net_device to offer */ ...@@ -420,9 +433,13 @@ int ecdev_offer(struct net_device *net_dev, /**< net_device to offer */
*ecdev = &master->main_device; // offer accepted *ecdev = &master->main_device; // offer accepted
return 0; // no error return 0; // no error
} }
else if (master->debug_level) { else {
ec_mac_print(master->main_mac, str); up(&master->device_sem);
EC_DBG("Master %u declined device %s.\n", master->index, str);
if (master->debug_level) {
ec_mac_print(net_dev->dev_addr, str);
EC_DBG("Master %u declined device %s.\n", master->index, str);
}
} }
} }
...@@ -446,8 +463,7 @@ void ecdev_withdraw(ec_device_t *device /**< EtherCAT device */) ...@@ -446,8 +463,7 @@ void ecdev_withdraw(ec_device_t *device /**< EtherCAT device */)
ec_master_t *master = device->master; ec_master_t *master = device->master;
char str[20]; char str[20];
ec_mac_print(master->main_mac, str); ec_mac_print(device->dev->dev_addr, str);
EC_INFO("Master %u releasing main device %s.\n", master->index, str); EC_INFO("Master %u releasing main device %s.\n", master->index, str);
down(&master->device_sem); down(&master->device_sem);
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
# Specify the MAC address (hexadecimal with colons) of the Ethernet device to # Specify the MAC address (hexadecimal with colons) of the Ethernet device to
# use. Example: "00:00:08:44:ab:66" # use. Example: "00:00:08:44:ab:66"
# #
# The broadcast address "ff:ff:ff:ff:ff:ff" has a special meaning: It tells
# the master to accept the first device offered by any ethernet driver.
#
# The MASTER<X>_DEVICE variables also determine, how many masters will be # The MASTER<X>_DEVICE variables also determine, how many masters will be
# created: A non-empty variable MASTER0_DEVICE will create one master, adding # created: A non-empty variable MASTER0_DEVICE will create one master, adding
# a non-empty variable MASTER1_DEVICE will create a second master, and so on. # a non-empty variable MASTER1_DEVICE will create a second master, and so on.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment