MERGE trunk -r516:527 -> branches/stable-1.1 (jiffies, bugfixes, pdo defines) stable-1.1
authorFlorian Pose <fp@igh-essen.com>
Fri, 01 Sep 2006 12:35:41 +0000
branchstable-1.1
changeset 1719 42ed27ae6785
parent 1718 048c7310279c
child 1720 41bb29bf93e4
MERGE trunk -r516:527 -> branches/stable-1.1 (jiffies, bugfixes, pdo defines)
TODO
examples/mini/mini.c
include/ecdb.h
master/datagram.c
master/datagram.h
master/domain.c
master/domain.h
master/ethernet.c
master/ethernet.h
master/fsm.c
master/fsm.h
master/master.c
master/master.h
master/slave.c
script/install.sh
--- a/TODO	Wed Aug 09 15:14:29 2006 +0000
+++ b/TODO	Fri Sep 01 12:35:41 2006 +0000
@@ -10,9 +10,10 @@
 
 * Add Kobjects in constructors.
 
-* Read AL Status Code with AL Control Response.
+* Read AL Status Code with AL Control Response (if possible?)
 
 * Coupling of EoE handlers before configuring slaves.
+  (avoiding duplicate configuration)
 
 * SysFS interface
   - Add secondary slave address
@@ -24,12 +25,12 @@
 
 * Implement eepro100 driver
 
+* Progress bar in ecrt.
+
 -------------------------------------------------------------------------------
 
 Not-so-important things to do:
 
-* User space tool for configuration
-
 * Calculate bus topology
 
 * File access over EtherCAT (FoE)
--- a/examples/mini/mini.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/examples/mini/mini.c	Fri Sep 01 12:35:41 2006 +0000
@@ -63,8 +63,8 @@
 uint8_t k_stat;
 
 ec_pdo_reg_t domain1_pdos[] = {
-    {"1", Beckhoff_EL4132_Output1, &r_ana_out},
-    {"8", Beckhoff_EL5001_Value, NULL},
+    {"2", Beckhoff_EL4132_Output1, &r_ana_out},
+    {"3", Beckhoff_EL5001_Value, NULL},
     {}
 };
 
@@ -148,7 +148,7 @@
         goto out_release_master;
     }
 
-    if (!(slave = ecrt_master_get_slave(master, "8")))
+    if (!(slave = ecrt_master_get_slave(master, "3")))
         goto out_release_master;
 
     if (ecrt_slave_conf_sdo8(slave, 0x4061, 1, 0))
--- a/include/ecdb.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/include/ecdb.h	Fri Sep 01 12:35:41 2006 +0000
@@ -45,12 +45,35 @@
 
 /** \cond */
 
+#define Beckhoff_EL1004_Inputs 0x00000002, 0x03EC3052, 0x3101, 1
+
+#define Beckhoff_EL1014_Inputs 0x00000002, 0x03F63052, 0x3101, 1
+
+#define Beckhoff_EL2004_Outputs 0x00000002, 0x07D43052, 0x3001, 1
+
+#define Beckhoff_EL2032_Outputs 0x00000002, 0x07F03052, 0x3001, 1
+
+#define Beckhoff_EL3102_Status1 0x00000002, 0x0C1E3052, 0x3101, 1
+#define Beckhoff_EL3102_Input1 0x00000002, 0x0C1E3052, 0x3101, 2
+#define Beckhoff_EL3102_Status2 0x00000002, 0x0C1E3052, 0x3102, 1
+#define Beckhoff_EL3102_Input2 0x00000002, 0x0C1E3052, 0x3102, 2
+
+#define Beckhoff_EL3162_Status1 0x00000002, 0x0C5A3052, 0x3101, 1
+#define Beckhoff_EL3162_Input1 0x00000002, 0x0C5A3052, 0x3101, 2
+#define Beckhoff_EL3162_Status2 0x00000002, 0x0C5A3052, 0x3102, 1
+#define Beckhoff_EL3162_Input2 0x00000002, 0x0C5A3052, 0x3102, 2
+
+#define Beckhoff_EL4102_Output1 0x00000002, 0x10063052, 0x6411, 1
+#define Beckhoff_EL4102_Output2 0x00000002, 0x10063052, 0x6411, 2
+
 #define Beckhoff_EL4132_Output1 0x00000002, 0x10243052, 0x6411, 1
 #define Beckhoff_EL4132_Output2 0x00000002, 0x10243052, 0x6411, 2
 
 #define Beckhoff_EL5001_Status 0x00000002, 0x13893052, 0x3101, 1
 #define Beckhoff_EL5001_Value  0x00000002, 0x13893052, 0x3101, 2
 
+#define Beckhoff_EL5101_Value 0x00000002, 0x13ED3052, 0x6000, 2
+
 /** \endcond */
 
 /*****************************************************************************/
--- a/master/datagram.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/datagram.c	Fri Sep 01 12:35:41 2006 +0000
@@ -77,7 +77,7 @@
     datagram->index = 0x00;
     datagram->working_counter = 0x00;
     datagram->state = EC_DATAGRAM_INIT;
-    datagram->t_sent = 0;
+    datagram->cycles_sent = 0;
 }
 
 /*****************************************************************************/
--- a/master/datagram.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/datagram.h	Fri Sep 01 12:35:41 2006 +0000
@@ -74,10 +74,10 @@
 {
     EC_DATAGRAM_INIT, /**< new datagram */
     EC_DATAGRAM_QUEUED, /**< datagram queued by master */
-    EC_DATAGRAM_SENT, /**< datagram has been sent */
-    EC_DATAGRAM_RECEIVED, /**< datagram has been received */
-    EC_DATAGRAM_TIMED_OUT, /**< datagram timed out */
-    EC_DATAGRAM_ERROR /**< error while sending/receiving */
+    EC_DATAGRAM_SENT, /**< datagram has been sent and still in the queue */
+    EC_DATAGRAM_RECEIVED, /**< datagram has been received and dequeued */
+    EC_DATAGRAM_TIMED_OUT, /**< datagram timed out and was dequeued */
+    EC_DATAGRAM_ERROR /**< error while sending/receiving, datagram dequeued */
 }
 ec_datagram_state_t;
 
@@ -118,7 +118,7 @@
     uint8_t index; /**< datagram index (set by master) */
     uint16_t working_counter; /**< working counter */
     ec_datagram_state_t state; /**< datagram state */
-    cycles_t t_sent; /**< time, the datagrams was sent */
+    cycles_t cycles_sent; /**< time, the datagram was sent */
 }
 ec_datagram_t;
 
--- a/master/domain.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/domain.c	Fri Sep 01 12:35:41 2006 +0000
@@ -106,7 +106,7 @@
     domain->data_size = 0;
     domain->base_address = 0;
     domain->response_count = 0xFFFFFFFF;
-    domain->t_last = 0;
+    domain->notify_jiffies = 0;
     domain->working_counter_changes = 0;
 
     INIT_LIST_HEAD(&domain->data_regs);
@@ -193,7 +193,7 @@
     list_for_each_entry(other_pdo, &slave->sii_pdos, list) {
         if (other_pdo->sync_index != sync->index) continue;
 
-        list_for_each_entry(other_entry, &pdo->entries, list) {
+        list_for_each_entry(other_entry, &other_pdo->entries, list) {
             if (other_entry == entry) {
                 byte_offset = bit_offset / 8;
                 break;
@@ -513,7 +513,6 @@
 {
     unsigned int working_counter_sum;
     ec_datagram_t *datagram;
-    cycles_t t_now = get_cycles();
 
     working_counter_sum = 0;
     list_for_each_entry(datagram, &domain->datagrams, list) {
@@ -528,8 +527,8 @@
     }
 
     if (domain->working_counter_changes &&
-        (u32) (t_now - domain->t_last) / cpu_khz > 1000) {
-        domain->t_last = t_now;
+        jiffies - domain->notify_jiffies > HZ) {
+        domain->notify_jiffies = jiffies;
         if (domain->working_counter_changes == 1) {
             EC_INFO("Domain %i working counter change: %i\n", domain->index,
                     domain->response_count);
--- a/master/domain.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/domain.h	Fri Sep 01 12:35:41 2006 +0000
@@ -69,7 +69,7 @@
     struct list_head data_regs; /**< PDO data registrations */
     unsigned int working_counter_changes; /**< working counter changes
                                              since last notification */
-    cycles_t t_last; /**< time of last notification */
+    unsigned long notify_jiffies; /**< time of last notification */
 };
 
 /*****************************************************************************/
--- a/master/ethernet.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/ethernet.c	Fri Sep 01 12:35:41 2006 +0000
@@ -105,7 +105,7 @@
     eoe->tx_counter = 0;
     eoe->rx_rate = 0;
     eoe->tx_rate = 0;
-    eoe->t_last = 0;
+    eoe->rate_jiffies = 0;
 
     if (!(eoe->dev =
           alloc_netdev(sizeof(ec_eoe_t *), "eoe%d", ether_setup))) {
@@ -278,21 +278,18 @@
 
 void ec_eoe_run(ec_eoe_t *eoe /**< EoE handler */)
 {
-    cycles_t t_now;
-
     if (!eoe->opened) return;
 
     // call state function
     eoe->state(eoe);
 
     // update statistics
-    t_now = get_cycles();
-    if ((u32) (t_now - eoe->t_last) > cpu_khz * 1000) {
+    if (jiffies - eoe->rate_jiffies > HZ) {
         eoe->rx_rate = eoe->rx_counter * 8;
         eoe->tx_rate = eoe->tx_counter * 8;
         eoe->rx_counter = 0;
         eoe->tx_counter = 0;
-        eoe->t_last = t_now;
+        eoe->rate_jiffies = jiffies;
     }
 }
 
--- a/master/ethernet.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/ethernet.h	Fri Sep 01 12:35:41 2006 +0000
@@ -78,7 +78,7 @@
     struct net_device *dev; /**< net_device for virtual ethernet device */
     struct net_device_stats stats; /**< device statistics */
     unsigned int opened; /**< net_device is opened */
-    cycles_t t_last; /**< time of last rate output */
+    unsigned long rate_jiffies; /**< time of last rate output */
     struct sk_buff *rx_skb; /**< current rx socket buffer */
     off_t rx_skb_offset; /**< current write pointer in the socket buffer */
     size_t rx_skb_size; /**< size of the allocated socket buffer memory */
--- a/master/fsm.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/fsm.c	Fri Sep 01 12:35:41 2006 +0000
@@ -1779,7 +1779,7 @@
     ec_datagram_t *datagram = &fsm->datagram;
     ec_slave_t *slave = fsm->slave;
 
-    fsm->change_start = get_cycles();
+    fsm->change_jiffies = jiffies;
 
     // write new state to slave
     ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2);
@@ -1807,7 +1807,7 @@
     }
 
     if (datagram->working_counter != 1) {
-        if (get_cycles() - fsm->change_start >= (cycles_t) 100 * cpu_khz) {
+        if (jiffies - fsm->change_jiffies >= 3 * HZ) {
             fsm->change_state = ec_fsm_error;
             EC_ERR("Failed to set state 0x%02X on slave %i: Slave did not"
                    " respond.\n", fsm->change_new, fsm->slave->ring_position);
@@ -1821,7 +1821,7 @@
         return;
     }
 
-    fsm->change_start = get_cycles();
+    fsm->change_jiffies = jiffies;
 
     // read AL status from slave
     ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
@@ -1869,7 +1869,7 @@
         return;
     }
 
-    if (get_cycles() - fsm->change_start >= (cycles_t) 10 * cpu_khz) {
+    if (jiffies - fsm->change_jiffies >= 100 * HZ / 1000) { // 100ms
         // timeout while checking
         fsm->change_state = ec_fsm_error;
         EC_ERR("Timeout while setting state 0x%02X on slave %i.\n",
@@ -1978,7 +1978,7 @@
         return;
     }
 
-    fsm->change_start = get_cycles();
+    fsm->change_jiffies = jiffies;
 
     // read new AL status
     ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2);
@@ -2014,7 +2014,7 @@
         return;
     }
 
-    if (get_cycles() - fsm->change_start >= (cycles_t) 100 * cpu_khz) {
+    if (jiffies - fsm->change_jiffies >= 100 * HZ / 1000) { // 100ms
         // timeout while checking
         slave->current_state = EC_SLAVE_STATE_UNKNOWN;
         fsm->change_state = ec_fsm_error;
--- a/master/fsm.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/fsm.h	Fri Sep 01 12:35:41 2006 +0000
@@ -75,7 +75,7 @@
 
     void (*change_state)(ec_fsm_t *); /**< slave state change state function */
     ec_slave_state_t change_new; /**< input: new state */
-    cycles_t change_start; /**< change start */
+    unsigned long change_jiffies; /**< change timer */
 
     void (*coe_state)(ec_fsm_t *); /**< CoE state function */
     ec_sdo_data_t *sdodata; /**< input/output: SDO data object */
--- a/master/master.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/master.c	Fri Sep 01 12:35:41 2006 +0000
@@ -227,8 +227,8 @@
     // empty datagram queue
     list_for_each_entry_safe(datagram, next_c,
                              &master->datagram_queue, queue) {
+        datagram->state = EC_DATAGRAM_ERROR;
         list_del_init(&datagram->queue);
-        datagram->state = EC_DATAGRAM_ERROR;
     }
 
     // clear domains
@@ -242,11 +242,10 @@
     master->debug_level = 0;
 
     master->stats.timeouts = 0;
-    master->stats.delayed = 0;
     master->stats.corrupted = 0;
     master->stats.skipped = 0;
     master->stats.unmatched = 0;
-    master->stats.t_last = 0;
+    master->stats.output_jiffies = 0;
 
     master->mode = EC_MASTER_MODE_ORPHANED;
 
@@ -316,11 +315,11 @@
     size_t datagram_size;
     uint8_t *frame_data, *cur_data;
     void *follows_word;
-    cycles_t t_start, t_end;
+    cycles_t cycles_start, cycles_end;
     unsigned int frame_count, more_datagrams_waiting;
 
     frame_count = 0;
-    t_start = get_cycles();
+    cycles_start = get_cycles();
 
     if (unlikely(master->debug_level > 1))
         EC_DBG("ec_master_send_datagrams\n");
@@ -345,7 +344,7 @@
             }
 
             datagram->state = EC_DATAGRAM_SENT;
-            datagram->t_sent = t_start;
+            datagram->cycles_sent = cycles_start;
             datagram->index = master->datagram_index++;
 
             if (unlikely(master->debug_level > 1))
@@ -397,9 +396,10 @@
     while (more_datagrams_waiting);
 
     if (unlikely(master->debug_level > 1)) {
-        t_end = get_cycles();
+        cycles_end = get_cycles();
         EC_DBG("ec_master_send_datagrams sent %i frames in %ius.\n",
-               frame_count, (unsigned int) (t_end - t_start) * 1000 / cpu_khz);
+               frame_count,
+               (unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz);
     }
 }
 
@@ -476,7 +476,7 @@
             continue;
         }
 
-        // copy received data in the datagram memory
+        // copy received data into the datagram memory
         memcpy(datagram->data, cur_data, data_size);
         cur_data += data_size;
 
@@ -528,17 +528,13 @@
 
 void ec_master_output_stats(ec_master_t *master /**< EtherCAT master */)
 {
-    cycles_t t_now = get_cycles();
-
-    if (unlikely((u32) (t_now - master->stats.t_last) / cpu_khz > 1000)) {
+    if (unlikely(jiffies - master->stats.output_jiffies >= HZ)) {
+        master->stats.output_jiffies = jiffies;
+
         if (master->stats.timeouts) {
             EC_WARN("%i datagrams TIMED OUT!\n", master->stats.timeouts);
             master->stats.timeouts = 0;
         }
-        if (master->stats.delayed) {
-            EC_WARN("%i frame(s) DELAYED!\n", master->stats.delayed);
-            master->stats.delayed = 0;
-        }
         if (master->stats.corrupted) {
             EC_WARN("%i frame(s) CORRUPTED!\n", master->stats.corrupted);
             master->stats.corrupted = 0;
@@ -551,7 +547,6 @@
             EC_WARN("%i datagram(s) UNMATCHED!\n", master->stats.unmatched);
             master->stats.unmatched = 0;
         }
-        master->stats.t_last = t_now;
     }
 }
 
@@ -610,25 +605,25 @@
 void ec_master_idle_run(void *data /**< master pointer */)
 {
     ec_master_t *master = (ec_master_t *) data;
-    cycles_t start, end;
+    cycles_t cycles_start, cycles_end;
 
     // aquire master lock
     spin_lock_bh(&master->internal_lock);
 
-    start = get_cycles();
+    cycles_start = get_cycles();
     ecrt_master_receive(master);
 
     // execute master state machine
     ec_fsm_execute(&master->fsm);
 
     ecrt_master_send(master);
-    end = get_cycles();
+    cycles_end = get_cycles();
 
     // release master lock
     spin_unlock_bh(&master->internal_lock);
 
     master->idle_cycle_times[master->idle_cycle_time_pos]
-        = (u32) (end - start) * 1000 / cpu_khz;
+        = (u32) (cycles_end - cycles_start) * 1000 / cpu_khz;
     master->idle_cycle_time_pos++;
     master->idle_cycle_time_pos %= HZ;
 
@@ -958,7 +953,8 @@
     ec_master_t *master = (ec_master_t *) data;
     ec_eoe_t *eoe;
     unsigned int active = 0;
-    cycles_t start, end;
+    cycles_t cycles_start, cycles_end;
+    unsigned long restart_jiffies;
 
     list_for_each_entry(eoe, &master->eoe_handlers, list) {
         if (ec_eoe_active(eoe)) active++;
@@ -977,8 +973,8 @@
     else
         goto queue_timer;
 
-    // actual EoE stuff
-    start = get_cycles();
+    // actual EoE processing
+    cycles_start = get_cycles();
     ecrt_master_receive(master);
 
     list_for_each_entry(eoe, &master->eoe_handlers, list) {
@@ -986,7 +982,7 @@
     }
 
     ecrt_master_send(master);
-    end = get_cycles();
+    cycles_end = get_cycles();
 
     // release lock...
     if (master->mode == EC_MASTER_MODE_OPERATION) {
@@ -997,12 +993,14 @@
     }
 
     master->eoe_cycle_times[master->eoe_cycle_time_pos]
-        = (u32) (end - start) * 1000 / cpu_khz;
+        = (u32) (cycles_end - cycles_start) * 1000 / cpu_khz;
     master->eoe_cycle_time_pos++;
     master->eoe_cycle_time_pos %= HZ;
 
  queue_timer:
-    master->eoe_timer.expires += HZ / EC_EOE_FREQUENCY;
+    restart_jiffies = HZ / EC_EOE_FREQUENCY;
+    if (!restart_jiffies) restart_jiffies = 1;
+    master->eoe_timer.expires += restart_jiffies;
     add_timer(&master->eoe_timer);
 }
 
@@ -1047,7 +1045,7 @@
 void ec_master_measure_bus_time(ec_master_t *master)
 {
     ec_datagram_t datagram;
-    cycles_t t_start, t_end, t_timeout;
+    cycles_t cycles_start, cycles_end, cycles_timeout;
     uint32_t times[100], sum, min, max, i;
 
     ec_datagram_init(&datagram);
@@ -1058,7 +1056,7 @@
         return;
     }
 
-    t_timeout = (cycles_t) EC_IO_TIMEOUT * (cpu_khz / 1000);
+    cycles_timeout = (cycles_t) EC_IO_TIMEOUT * (cpu_khz / 1000);
 
     sum = 0;
     min = 0xFFFFFFFF;
@@ -1067,11 +1065,11 @@
     for (i = 0; i < 100; i++) {
         ec_master_queue_datagram(master, &datagram);
         ecrt_master_send(master);
-        t_start = get_cycles();
+        cycles_start = get_cycles();
 
         while (1) { // active waiting
             ec_device_call_isr(master->device);
-            t_end = get_cycles(); // take current time
+            cycles_end = get_cycles(); // take current time
 
             if (datagram.state == EC_DATAGRAM_RECEIVED) {
                 break;
@@ -1080,13 +1078,13 @@
                 EC_WARN("Failed to measure bus time.\n");
                 goto error;
             }
-            else if (t_end - t_start >= t_timeout) {
+            else if (cycles_end - cycles_start >= cycles_timeout) {
                 EC_WARN("Timeout while measuring bus time.\n");
                 goto error;
             }
         }
 
-        times[i] = (unsigned int) (t_end - t_start) * 1000 / cpu_khz;
+        times[i] = (unsigned int) (cycles_end - cycles_start) * 1000 / cpu_khz;
         sum += times[i];
         if (times[i] > max) max = times[i];
         if (times[i] < min) min = times[i];
@@ -1234,50 +1232,23 @@
 
 void ec_master_sync_io(ec_master_t *master /**< EtherCAT master */)
 {
-    ec_datagram_t *datagram, *n;
-    unsigned int datagrams_sent;
-    cycles_t t_start, t_end, t_timeout;
+    ec_datagram_t *datagram;
+    unsigned int datagrams_waiting;
 
     // send datagrams
     ecrt_master_send(master);
 
-    t_start = get_cycles(); // measure io time
-    t_timeout = (cycles_t) EC_IO_TIMEOUT * (cpu_khz / 1000);
-
     while (1) { // active waiting
-        ec_device_call_isr(master->device);
-
-        t_end = get_cycles(); // take current time
-        if (t_end - t_start >= t_timeout) break; // timeout!
-
-        datagrams_sent = 0;
-        list_for_each_entry_safe(datagram, n, &master->datagram_queue, queue) {
-            if (datagram->state == EC_DATAGRAM_RECEIVED)
-                list_del_init(&datagram->queue);
-            else if (datagram->state == EC_DATAGRAM_SENT)
-                datagrams_sent++;
-        }
-
-        if (!datagrams_sent) break;
-    }
-
-    // timeout; dequeue all datagrams
-    list_for_each_entry_safe(datagram, n, &master->datagram_queue, queue) {
-        switch (datagram->state) {
-            case EC_DATAGRAM_SENT:
-            case EC_DATAGRAM_QUEUED:
-                datagram->state = EC_DATAGRAM_TIMED_OUT;
-                master->stats.timeouts++;
-                ec_master_output_stats(master);
-                break;
-            case EC_DATAGRAM_RECEIVED:
-                master->stats.delayed++;
-                ec_master_output_stats(master);
-                break;
-            default:
-                break;
-        }
-        list_del_init(&datagram->queue);
+        ecrt_master_receive(master); // receive and dequeue datagrams
+
+        // count number of datagrams still waiting for response
+        datagrams_waiting = 0;
+        list_for_each_entry(datagram, &master->datagram_queue, queue) {
+            datagrams_waiting++;
+        }
+
+        // if there are no more datagrams waiting, abort loop.
+        if (!datagrams_waiting) break;
     }
 }
 
@@ -1318,24 +1289,19 @@
 void ecrt_master_receive(ec_master_t *master /**< EtherCAT master */)
 {
     ec_datagram_t *datagram, *next;
-    cycles_t t_received, t_timeout;
+    cycles_t cycles_received, cycles_timeout;
 
     ec_device_call_isr(master->device);
 
-    t_received = get_cycles();
-    t_timeout = EC_IO_TIMEOUT * cpu_khz / 1000;
-
-    // dequeue all received datagrams
-    list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue)
-        if (datagram->state == EC_DATAGRAM_RECEIVED)
-            list_del_init(&datagram->queue);
+    cycles_received = get_cycles();
+    cycles_timeout = EC_IO_TIMEOUT * cpu_khz / 1000;
 
     // dequeue all datagrams that timed out
     list_for_each_entry_safe(datagram, next, &master->datagram_queue, queue) {
         switch (datagram->state) {
             case EC_DATAGRAM_SENT:
             case EC_DATAGRAM_QUEUED:
-                if (t_received - datagram->t_sent > t_timeout) {
+                if (cycles_received - datagram->cycles_sent > cycles_timeout) {
                     list_del_init(&datagram->queue);
                     datagram->state = EC_DATAGRAM_TIMED_OUT;
                     master->stats.timeouts++;
@@ -1360,7 +1326,7 @@
 void ecrt_master_prepare(ec_master_t *master /**< EtherCAT master */)
 {
     ec_domain_t *domain;
-    cycles_t t_start, t_end, t_timeout;
+    cycles_t cycles_start, cycles_end, cycles_timeout;
 
     // queue datagrams of all domains
     list_for_each_entry(domain, &master->domains, list)
@@ -1368,13 +1334,13 @@
 
     ecrt_master_send(master);
 
-    t_start = get_cycles(); // take sending time
-    t_timeout = (cycles_t) EC_IO_TIMEOUT * (cpu_khz / 1000);
+    cycles_start = get_cycles(); // take sending time
+    cycles_timeout = (cycles_t) EC_IO_TIMEOUT * (cpu_khz / 1000);
 
     // active waiting
     while (1) {
-        t_end = get_cycles();
-        if (t_end - t_start >= t_timeout) break;
+        cycles_end = get_cycles();
+        if (cycles_end - cycles_start >= cycles_timeout) break;
     }
 }
 
--- a/master/master.h	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/master.h	Fri Sep 01 12:35:41 2006 +0000
@@ -72,13 +72,12 @@
 typedef struct
 {
     unsigned int timeouts; /**< datagram timeouts */
-    unsigned int delayed; /**< delayed datagrams */
     unsigned int corrupted; /**< corrupted frames */
     unsigned int skipped; /**< skipped datagrams (the ones that were
                              requeued when not yet received) */
     unsigned int unmatched; /**< unmatched datagrams (received, but not
                                queued any longer) */
-    cycles_t t_last; /**< time of last output */
+    unsigned long output_jiffies; /**< time of last output */
 }
 ec_stats_t;
 
--- a/master/slave.c	Wed Aug 09 15:14:29 2006 +0000
+++ b/master/slave.c	Fri Sep 01 12:35:41 2006 +0000
@@ -648,67 +648,6 @@
 
 /*****************************************************************************/
 
-#if 0
-
-/**
-   Outputs the values of the CRC faoult counters and resets them.
-   \return 0 in case of success, else < 0
-*/
-
-int ec_slave_check_crc(ec_slave_t *slave /**< EtherCAT slave */)
-{
-    ec_datagram_t *datagram;
-
-    datagram = &slave->master->simple_datagram;
-
-    if (ec_datagram_nprd(datagram, slave->station_address, 0x0300, 4))
-        return -1;
-    if (unlikely(ec_master_simple_io(slave->master, datagram))) {
-        EC_WARN("Reading CRC fault counters failed on slave %i!\n",
-                slave->ring_position);
-        return -1;
-    }
-
-    if (!EC_READ_U32(datagram->data)) return 0; // no CRC faults
-
-    if (EC_READ_U8(datagram->data))
-        EC_WARN("%3i RX-error%s on slave %i, channel A.\n",
-                EC_READ_U8(datagram->data),
-                EC_READ_U8(datagram->data) == 1 ? "" : "s",
-                slave->ring_position);
-    if (EC_READ_U8(datagram->data + 1))
-        EC_WARN("%3i invalid frame%s on slave %i, channel A.\n",
-                EC_READ_U8(datagram->data + 1),
-                EC_READ_U8(datagram->data + 1) == 1 ? "" : "s",
-                slave->ring_position);
-    if (EC_READ_U8(datagram->data + 2))
-        EC_WARN("%3i RX-error%s on slave %i, channel B.\n",
-                EC_READ_U8(datagram->data + 2),
-                EC_READ_U8(datagram->data + 2) == 1 ? "" : "s",
-                slave->ring_position);
-    if (EC_READ_U8(datagram->data + 3))
-        EC_WARN("%3i invalid frame%s on slave %i, channel B.\n",
-                EC_READ_U8(datagram->data + 3),
-                EC_READ_U8(datagram->data + 3) == 1 ? "" : "s",
-                slave->ring_position);
-
-    // reset CRC counters
-    if (ec_datagram_npwr(datagram, slave->station_address, 0x0300, 4))
-        return -1;
-    EC_WRITE_U32(datagram->data, 0x00000000);
-    if (unlikely(ec_master_simple_io(slave->master, datagram))) {
-        EC_WARN("Resetting CRC fault counters failed on slave %i!\n",
-                slave->ring_position);
-        return -1;
-    }
-
-    return 0;
-}
-
-#endif
-
-/*****************************************************************************/
-
 /**
    Schedules an EEPROM write operation.
    \return 0 in case of success, else < 0
--- a/script/install.sh	Wed Aug 09 15:14:29 2006 +0000
+++ b/script/install.sh	Fri Sep 01 12:35:41 2006 +0000
@@ -56,7 +56,7 @@
 # Update module dependencies
 
 echo "  Building module dependencies"
-depmod
+/sbin/depmod
 
 #------------------------------------------------------------------------------
 
@@ -89,9 +89,7 @@
 
 echo "  Installing tools"
 cp script/lsec.pl /usr/local/bin/lsec || exit 1
-chmod +x /usr/local/bin/ec_list || exit 1
-rm -f /usr/local/bin/ec_list || exit 1
-ln -s /usr/local/bin/lsec /usr/local/bin/ec_list || exit 1
+chmod +x /usr/local/bin/lsec || exit 1
 
 #------------------------------------------------------------------------------