--- a/master/master.c Thu Jan 26 15:52:01 2006 +0000
+++ b/master/master.c Fri Feb 03 10:46:33 2006 +0000
@@ -415,6 +415,7 @@
ec_slave_init(slave);
// Set ring position
+
slave->ring_position = -i;
slave->station_address = i + 1;
@@ -492,10 +493,10 @@
}
if (unlikely(!slave->type)) {
- printk(KERN_ERR "EtherCAT: Unknown slave device (vendor %X, code %X) at "
- " position %i.\n", slave->sii_vendor_id, slave->sii_product_code,
- i);
- return -1;
+ printk(KERN_WARNING "EtherCAT: Unknown slave device (vendor 0x%08X, code"
+ " 0x%08X) at position %i.\n", slave->sii_vendor_id,
+ slave->sii_product_code, i);
+ return 0;
}
}
@@ -615,9 +616,8 @@
}
if (unlikely(cmd.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not set state %02X - Slave %i (%s %s)"
- " did not respond!\n", state_and_ack, slave->ring_position * (-1),
- slave->type->vendor_name, slave->type->product_name);
+ printk(KERN_ERR "EtherCAT: Could not set state %02X - Slave %i did not"
+ " respond!\n", state_and_ack, slave->ring_position * (-1));
return -1;
}
@@ -635,14 +635,15 @@
}
if (unlikely(cmd.working_counter != 1)) {
- printk(KERN_ERR "EtherCAT: Could not check state %02X - Device did not"
- " respond!\n", state_and_ack);
+ printk(KERN_ERR "EtherCAT: Could not check state %02X - Device %i did"
+ " not respond!\n", state_and_ack, slave->ring_position * (-1));
return -1;
}
if (unlikely(cmd.data[0] & 0x10)) { // State change error
- printk(KERN_ERR "EtherCAT: Could not set state %02X - Device refused"
- " state change (code %02X)!\n", state_and_ack, cmd.data[0]);
+ printk(KERN_ERR "EtherCAT: Could not set state %02X - Device %i refused"
+ " state change (code %02X)!\n", state_and_ack,
+ slave->ring_position * (-1), cmd.data[0]);
return -1;
}
@@ -655,8 +656,9 @@
}
if (unlikely(!tries_left)) {
- printk(KERN_ERR "EtherCAT: Could not check state %02X - Timeout while"
- " checking!\n", state_and_ack);
+ printk(KERN_ERR "EtherCAT: Could not check state %02X of slave %i -"
+ " Timeout while checking!\n", state_and_ack,
+ slave->ring_position * (-1));
return -1;
}
@@ -767,6 +769,11 @@
return NULL;
}
+ if (!slave->type) {
+ printk(KERN_ERR "EtherCAT: Unknown slave at position %i!\n", bus_index);
+ return NULL;
+ }
+
type = slave->type;
if (strcmp(vendor_name, type->vendor_name) ||
@@ -873,11 +880,18 @@
for (i = 0; i < master->bus_slaves_count; i++)
{
slave = master->bus_slaves + i;
+
+ if (unlikely(ec_state_change(master, slave, EC_SLAVE_STATE_INIT) != 0))
+ return -1;
+
+ // Check if slave was registered...
+ if (!slave->registered) {
+ printk(KERN_INFO "EtherCAT: Slave %i was not registered.\n", i);
+ continue;
+ }
+
type = slave->type;
- if (unlikely(ec_state_change(master, slave, EC_SLAVE_STATE_INIT) != 0))
- return -1;
-
// Resetting FMMU's
memset(data, 0x00, 256);
@@ -911,14 +925,6 @@
}
}
- // Check if slave was registered...
-
- if (!slave->registered) {
- printk(KERN_INFO "EtherCAT: Slave %i (%s %s) was not registered.\n",
- i, type->vendor_name, type->product_name);
- continue;
- }
-
// Init Mailbox communication
if (type->features == EC_MAILBOX_SLAVE)
--- a/master/types.c Thu Jan 26 15:52:01 2006 +0000
+++ b/master/types.c Fri Feb 03 10:46:33 2006 +0000
@@ -15,7 +15,15 @@
/*****************************************************************************/
-/* Konfigurationen der Sync-Manager */
+/*
+ Konfigurationen der Sync-Manager
+
+ Byte 1-2: Physical Start Address
+ Byte 3-4: Data Length
+ Byte 5: Control Byte
+ Byte 6: Status Byte (read only)
+ Byte 7-8: Enable
+*/
unsigned char sm0_multi[] = {0x00, 0x18, 0xF6, 0x00, 0x26, 0x00, 0x01, 0x00};
unsigned char sm1_multi[] = {0xF6, 0x18, 0xF6, 0x00, 0x22, 0x00, 0x01, 0x00};
@@ -29,7 +37,22 @@
unsigned char sm2_41xx[] = {0x00, 0x10, 0x04, 0x00, 0x24, 0x00, 0x01, 0x00};
-/* Konfigurationen der Memory-Management-Units */
+unsigned char sm2_5001[] = {0x00, 0x10, 0x04, 0x00, 0x24, 0x00, 0x00, 0x00};
+unsigned char sm3_5001[] = {0x00, 0x11, 0x05, 0x00, 0x20, 0x00, 0x01, 0x00};
+
+/*
+ Konfigurationen der Memory-Management-Units
+
+ Byte 1-4: Logical Start Address (is set later)
+ Byte 5-6: Length
+ Byte 7: Logical start bit
+ Byte 8: Logical end bit
+ Byte 9-10: Physical start address
+ Byte 11: Physical start bit
+ Byte 12: Direction (1: in, 2: out)
+ Byte 13-14: Channel enable
+ Byte 15-16: Reserved
+*/
unsigned char fmmu0_1014[] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07,
0x00, 0x10, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
@@ -43,63 +66,66 @@
unsigned char fmmu0_41xx[] = {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07,
0x00, 0x10, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00};
+unsigned char fmmu0_5001[] = {0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x07,
+ 0x00, 0x11, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
+
/*****************************************************************************/
/* Klemmen-Objekte */
-ec_slave_type_t Beckhoff_EK1100[] =
-{{
- "Beckhoff", "EK1100", "Bus Coupler",
- EC_NOSYNC_SLAVE, NULL, NULL, NULL, NULL, NULL, 0
-}};
+ec_slave_type_t Beckhoff_EK1100 =
+{
+ "Beckhoff", "EK1100", "Bus Coupler",
+ EC_NOSYNC_SLAVE, NULL, NULL, NULL, NULL, NULL, 0
+};
-ec_slave_type_t Beckhoff_EK1110[] =
-{{
- "Beckhoff", "EK1110", "Extension terminal",
- EC_NOSYNC_SLAVE, NULL, NULL, NULL, NULL, NULL, 0
-}};
+ec_slave_type_t Beckhoff_EK1110 =
+{
+ "Beckhoff", "EK1110", "Extension terminal",
+ EC_NOSYNC_SLAVE, NULL, NULL, NULL, NULL, NULL, 0
+};
-ec_slave_type_t Beckhoff_EL1014[] =
-{{
- "Beckhoff", "EL1014", "4x Digital Input",
- EC_SIMPLE_SLAVE, sm0_1014, NULL, NULL, NULL, fmmu0_1014, 1
-}};
+ec_slave_type_t Beckhoff_EL1014 =
+{
+ "Beckhoff", "EL1014", "4x Digital Input",
+ EC_SIMPLE_SLAVE, sm0_1014, NULL, NULL, NULL, fmmu0_1014, 1
+};
-ec_slave_type_t Beckhoff_EL2004[] =
-{{
- "Beckhoff", "EL2004", "4x Digital Output",
- EC_SIMPLE_SLAVE, sm0_2004, NULL, NULL, NULL, fmmu0_2004, 1
-}};
+ec_slave_type_t Beckhoff_EL2004 =
+{
+ "Beckhoff", "EL2004", "4x Digital Output",
+ EC_SIMPLE_SLAVE, sm0_2004, NULL, NULL, NULL, fmmu0_2004, 1
+};
-ec_slave_type_t Beckhoff_EL3102[] =
-{{
- "Beckhoff", "EL3102", "2x Analog Input diff.",
- EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_31xx, sm3_31xx, fmmu0_31xx, 6
-}};
+ec_slave_type_t Beckhoff_EL3102 =
+{
+ "Beckhoff", "EL3102", "2x Analog Input diff.",
+ EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_31xx, sm3_31xx, fmmu0_31xx, 6
+};
-ec_slave_type_t Beckhoff_EL3162[] =
-{{
- "Beckhoff", "EL3162", "2x Analog Input",
- EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_31xx, sm3_31xx, fmmu0_31xx, 6
-}};
+ec_slave_type_t Beckhoff_EL3162 =
+{
+ "Beckhoff", "EL3162", "2x Analog Input",
+ EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_31xx, sm3_31xx, fmmu0_31xx, 6
+};
-ec_slave_type_t Beckhoff_EL4102[] =
-{{
- "Beckhoff", "EL4102", "2x Analog Output",
- EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_41xx, NULL, fmmu0_41xx, 4
-}};
+ec_slave_type_t Beckhoff_EL4102 =
+{
+ "Beckhoff", "EL4102", "2x Analog Output",
+ EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_41xx, NULL, fmmu0_41xx, 4
+};
-ec_slave_type_t Beckhoff_EL4132[] =
-{{
- "Beckhoff", "EL4132", "2x Analog Output diff.",
- EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_41xx, NULL, fmmu0_41xx, 4
-}};
+ec_slave_type_t Beckhoff_EL4132 =
+{
+ "Beckhoff", "EL4132", "2x Analog Output diff.",
+ EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_41xx, NULL, fmmu0_41xx, 4
+};
-ec_slave_type_t Beckhoff_EL5001[] =
-{{
- "Beckhoff", "EL5001", "SSI-Interface", // Noch nicht eingepflegt...
- EC_SIMPLE_SLAVE, NULL, NULL, NULL, NULL, NULL, 0
-}};
+ec_slave_type_t Beckhoff_EL5001 =
+{
+ "Beckhoff", "EL5001", "SSI-Interface",
+ EC_MAILBOX_SLAVE, sm0_multi, sm1_multi, sm2_5001, sm3_5001, fmmu0_5001, 5
+};
/*****************************************************************************/
@@ -113,19 +139,18 @@
ec_slave_ident_t slave_idents[] =
{
- {0x00000002, 0x03F63052, Beckhoff_EL1014},
- {0x00000002, 0x044C2C52, Beckhoff_EK1100},
- {0x00000002, 0x04562C52, Beckhoff_EK1110},
- {0x00000002, 0x07D43052, Beckhoff_EL2004},
- {0x00000002, 0x0C1E3052, Beckhoff_EL3102},
- {0x00000002, 0x0C5A3052, Beckhoff_EL3162},
- {0x00000002, 0x10063052, Beckhoff_EL4102},
- {0x00000002, 0x10243052, Beckhoff_EL4132},
- {0x00000002, 0x13893052, Beckhoff_EL5001}
+ {0x00000002, 0x03F63052, &Beckhoff_EL1014},
+ {0x00000002, 0x044C2C52, &Beckhoff_EK1100},
+ {0x00000002, 0x04562C52, &Beckhoff_EK1110},
+ {0x00000002, 0x07D43052, &Beckhoff_EL2004},
+ {0x00000002, 0x0C1E3052, &Beckhoff_EL3102},
+ {0x00000002, 0x0C5A3052, &Beckhoff_EL3162},
+ {0x00000002, 0x10063052, &Beckhoff_EL4102},
+ {0x00000002, 0x10243052, &Beckhoff_EL4132},
+ {0x00000002, 0x13893052, &Beckhoff_EL5001}
};
unsigned int slave_ident_count = sizeof(slave_idents)
/ sizeof(ec_slave_ident_t);
-
/*****************************************************************************/