Sch?nheitskorrekturen.
authorFlorian Pose <fp@igh-essen.com>
Thu, 05 Jan 2006 14:11:25 +0000
changeset 43 35120a61d55e
parent 42 a22a202d0f42
child 44 68d5b57cf038
Sch?nheitskorrekturen.
drivers/ec_master.c
rt/msr_jitter.c
rt/msr_jitter.h
rt/msr_module.c
rt/msr_param.h
--- a/drivers/ec_master.c	Thu Jan 05 13:39:39 2006 +0000
+++ b/drivers/ec_master.c	Thu Jan 05 14:11:25 2006 +0000
@@ -706,17 +706,16 @@
                          0x0120, 2, data);
 
   if (unlikely(EtherCAT_simple_send_receive(master, &cmd) != 0)) {
-    printk(KERN_ERR "EtherCAT: Could not set state %02X -"
-           " Unable to send!\n", state_and_ack);
-    return -2;
+    printk(KERN_ERR "EtherCAT: Could not set state %02X - Unable to send!\n",
+           state_and_ack);
+    return -1;
   }
 
   if (unlikely(cmd.working_counter != 1)) {
-    printk(KERN_ERR "EtherCAT: Could not set state %02X -"
-           " Device \"%s %s\" (%d) did not respond!\n",
-           state_and_ack, slave->desc->vendor_name,
-           slave->desc->product_name, slave->ring_position*(-1));
-    return -3;
+    printk(KERN_ERR "EtherCAT: Could not set state %02X - Device \"%s %s\""
+           " (%d) did not respond!\n", state_and_ack, slave->desc->vendor_name,
+           slave->desc->product_name, slave->ring_position * (-1));
+    return -1;
   }
 
   slave->requested_state = state_and_ack & 0x0F;
@@ -729,23 +728,21 @@
     EtherCAT_command_read(&cmd, slave->station_address, 0x0130, 2);
 
     if (unlikely(EtherCAT_simple_send_receive(master, &cmd) != 0)) {
-      printk(KERN_ERR "EtherCAT: Could not check"
-             " state %02X - Unable to send!\n", state_and_ack);
-      return -2;
+      printk(KERN_ERR "EtherCAT: Could not check state %02X - Unable to"
+             " send!\n", state_and_ack);
+      return -1;
     }
 
     if (unlikely(cmd.working_counter != 1)) {
-      printk(KERN_ERR "EtherCAT: Could not check"
-             " state %02X - Device did not respond!\n",
-             state_and_ack);
-      return -3;
+      printk(KERN_ERR "EtherCAT: Could not check state %02X - Device did not"
+             " respond!\n", state_and_ack);
+      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]);
-      return -4;
+      printk(KERN_ERR "EtherCAT: Could not set state %02X - Device refused"
+             " state change (code %02X)!\n", state_and_ack, cmd.data[0]);
+      return -1;
     }
 
     if (likely(cmd.data[0] == (state_and_ack & 0x0F))) {
@@ -757,9 +754,9 @@
   }
 
   if (unlikely(!tries_left)) {
-    printk(KERN_ERR "EtherCAT: Could not check state %02X -"
-           " Timeout while checking!\n", state_and_ack);
-    return -5;
+    printk(KERN_ERR "EtherCAT: Could not check state %02X - Timeout while"
+           " checking!\n", state_and_ack);
+    return -1;
   }
 
   slave->current_state = state_and_ack & 0x0F;
@@ -792,24 +789,21 @@
 
   desc = slave->desc;
 
-  if (unlikely(EtherCAT_state_change(master, slave,
-                                     ECAT_STATE_INIT) != 0))
+  if (unlikely(EtherCAT_state_change(master, slave, ECAT_STATE_INIT) != 0))
     return -1;
 
   // Resetting FMMU's
 
   memset(data, 0x00, 256);
 
-  EtherCAT_command_write(&cmd, slave->station_address,
-                         0x0600, 256, data);
+  EtherCAT_command_write(&cmd, slave->station_address, 0x0600, 256, data);
 
   if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
     return -1;
 
   if (unlikely(cmd.working_counter != 1)) {
-    printk(KERN_ERR "EtherCAT: Resetting FMMUs -"
-           " Slave %04X did not respond!\n",
-           slave->station_address);
+    printk(KERN_ERR "EtherCAT: Resetting FMMUs - Slave %04X did not"
+           " respond!\n", slave->station_address);
     return -1;
   }
 
@@ -819,16 +813,14 @@
   {
     memset(data, 0x00, 256);
 
-    EtherCAT_command_write(&cmd, slave->station_address,
-                           0x0800, 256, data);
+    EtherCAT_command_write(&cmd, slave->station_address, 0x0800, 256, data);
 
     if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
       return -1;
 
     if (unlikely(cmd.working_counter != 1)) {
-      printk(KERN_ERR "EtherCAT: Resetting SMs -"
-             " Slave %04X did not respond!\n",
-             slave->station_address);
+      printk(KERN_ERR "EtherCAT: Resetting SMs - Slave %04X did not"
+             " respond!\n", slave->station_address);
       return -1;
     }
   }
@@ -839,24 +831,23 @@
   {
     if (desc->sm0)
     {
-      EtherCAT_command_write(&cmd, slave->station_address,
-                             0x0800, 8, desc->sm0);
+      EtherCAT_command_write(&cmd, slave->station_address, 0x0800, 8,
+                             desc->sm0);
 
       if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
         return -1;
 
       if (unlikely(cmd.working_counter != 1)) {
-        printk(KERN_ERR "EtherCAT: Setting SM0 -"
-               " Slave %04X did not respond!\n",
-               slave->station_address);
+        printk(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not"
+               " respond!\n", slave->station_address);
         return -1;
       }
     }
 
     if (desc->sm1)
     {
-      EtherCAT_command_write(&cmd, slave->station_address,
-                             0x0808, 8, desc->sm1);
+      EtherCAT_command_write(&cmd, slave->station_address, 0x0808, 8,
+                             desc->sm1);
 
       if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
         return -1;
@@ -872,8 +863,7 @@
 
   // Change state to PREOP
 
-  if (unlikely(EtherCAT_state_change(master, slave,
-                                     ECAT_STATE_PREOP) != 0))
+  if (unlikely(EtherCAT_state_change(master, slave, ECAT_STATE_PREOP) != 0))
     return -1;
 
   // Set FMMU's
@@ -893,16 +883,14 @@
     fmmu[2] = (slave->logical_address & 0x00FF0000) >> 16;
     fmmu[3] = (slave->logical_address & 0xFF000000) >> 24;
 
-    EtherCAT_command_write(&cmd, slave->station_address,
-                           0x0600, 16, fmmu);
+    EtherCAT_command_write(&cmd, slave->station_address, 0x0600, 16, fmmu);
 
     if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
       return -1;
 
     if (unlikely(cmd.working_counter != 1)) {
-      printk(KERN_ERR "EtherCAT: Setting FMMU0 -"
-             " Slave %04X did not respond!\n",
-             slave->station_address);
+      printk(KERN_ERR "EtherCAT: Setting FMMU0 - Slave %04X did not"
+             " respond!\n", slave->station_address);
       return -1;
     }
   }
@@ -913,32 +901,30 @@
   {
     if (desc->sm0)
     {
-      EtherCAT_command_write(&cmd, slave->station_address,
-                             0x0800, 8, desc->sm0);
+      EtherCAT_command_write(&cmd, slave->station_address, 0x0800, 8,
+                             desc->sm0);
 
       if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
         return -1;
 
       if (unlikely(cmd.working_counter != 1)) {
-        printk(KERN_ERR "EtherCAT: Setting SM0 -"
-               " Slave %04X did not respond!\n",
-               slave->station_address);
+        printk(KERN_ERR "EtherCAT: Setting SM0 - Slave %04X did not"
+               " respond!\n", slave->station_address);
         return -1;
       }
     }
 
     if (desc->sm1)
     {
-      EtherCAT_command_write(&cmd, slave->station_address,
-                             0x0808, 8, desc->sm1);
+      EtherCAT_command_write(&cmd, slave->station_address, 0x0808, 8,
+                             desc->sm1);
 
       if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
         return -1;
 
       if (unlikely(cmd.working_counter != 1)) {
-        printk(KERN_ERR "EtherCAT: Setting SM1 -"
-               " Slave %04X did not respond!\n",
-               slave->station_address);
+        printk(KERN_ERR "EtherCAT: Setting SM1 - Slave %04X did not"
+               " respond!\n", slave->station_address);
         return -1;
       }
     }
@@ -946,15 +932,13 @@
 
   if (desc->sm2)
   {
-    EtherCAT_command_write(&cmd, slave->station_address,
-                           0x0810, 8, desc->sm2);
+    EtherCAT_command_write(&cmd, slave->station_address, 0x0810, 8, desc->sm2);
 
     if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
       return -1;
 
     if (unlikely(cmd.working_counter != 1)) {
-      printk(KERN_ERR "EtherCAT: Setting SM2 -"
-             " Slave %04X did not respond!\n",
+      printk(KERN_ERR "EtherCAT: Setting SM2 - Slave %04X did not respond!\n",
              slave->station_address);
       return -1;
     }
@@ -962,28 +946,24 @@
 
   if (desc->sm3)
   {
-    EtherCAT_command_write(&cmd, slave->station_address,
-                           0x0818, 8, desc->sm3);
+    EtherCAT_command_write(&cmd, slave->station_address, 0x0818, 8, desc->sm3);
 
     if (unlikely(EtherCAT_simple_send_receive(master, &cmd) < 0))
       return -1;
 
     if (unlikely(cmd.working_counter != 1)) {
-      printk(KERN_ERR "EtherCAT: Setting SM3 -"
-             " Slave %04X did not respond!\n",
+      printk(KERN_ERR "EtherCAT: Setting SM3 - Slave %04X did not respond!\n",
              slave->station_address);
       return -1;
     }
   }
 
   // Change state to SAVEOP
-  if (unlikely(EtherCAT_state_change(master, slave,
-                                     ECAT_STATE_SAVEOP) != 0))
+  if (unlikely(EtherCAT_state_change(master, slave, ECAT_STATE_SAVEOP) != 0))
     return -1;
 
   // Change state to OP
-  if (unlikely(EtherCAT_state_change(master, slave,
-                                     ECAT_STATE_OP) != 0))
+  if (unlikely(EtherCAT_state_change(master, slave, ECAT_STATE_OP) != 0))
     return -1;
 
   return 0;
--- a/rt/msr_jitter.c	Thu Jan 05 13:39:39 2006 +0000
+++ b/rt/msr_jitter.c	Thu Jan 05 14:11:25 2006 +0000
@@ -1,58 +1,20 @@
-/**************************************************************************************************
-*
-*                          msr_jitter.c
-*
-*           
-*           Autor: Wilhelm Hagemeister
-*
-*           (C) Copyright IgH 2002
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: hm@igh-essen.com
-*
-*
-*           $RCSfile: msr_adeos_latency.c,v $
-*           $Revision: 1.3 $
-*           $Author: hm $
-*           $Date: 2005/12/07 20:13:53 $
-*           $State: Exp $
-*
-*
-*           $Log: msr_adeos_latency.c,v $
-*           Revision 1.3  2005/12/07 20:13:53  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2005/12/07 15:56:13  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2005/12/07 08:43:40  hm
-*           Initial revision
-*
-*           Revision 1.5  2005/11/14 20:28:09  hm
-*           *** empty log message ***
-*
-*           Revision 1.4  2005/11/13 10:34:07  hm
-*           *** empty log message ***
-*
-*           Revision 1.3  2005/11/12 20:52:46  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2005/11/12 20:51:27  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2005/11/12 19:16:02  hm
-*           Initial revision
-*
-*           Revision 1.13  2005/06/17 11:35:13  hm
-*           *** empty log message ***
-*
-*
-*
-*
-**************************************************************************************************/
+/******************************************************************************
+ *
+ * msr_jitter.c
+ *
+ * Autor: Wilhelm Hagemeister
+ *
+ * (C) Copyright IgH 2002
+ * Ingenieurgemeinschaft IgH
+ * Heinz-Bäcker Str. 34
+ * D-45356 Essen
+ * Tel.: +49 201/61 99 31
+ * Fax.: +49 201/61 98 36
+ * E-mail: hm@igh-essen.com
+ *
+ * $Id$
+ *
+ *****************************************************************************/
 
 #ifndef __KERNEL__
 #  define __KERNEL__
@@ -71,27 +33,24 @@
 #include <msr_reg.h>
 #include "msr_jitter.h"
 
-/*--includes-------------------------------------------------------------------------------------*/
- 
+/*--includes-----------------------------------------------------------------*/
 
-/*--external functions---------------------------------------------------------------------------*/
+/*--external functions-------------------------------------------------------*/
 
-/*--external data--------------------------------------------------------------------------------*/
+/*--external data------------------------------------------------------------*/
 
-/*--public data----------------------------------------------------------------------------------*/
+/*--public data--------------------------------------------------------------*/
 
-/*--local data-----------------------------------------------------------------------------------*/
+/*--local data---------------------------------------------------------------*/
 
 #define NUMCLASSES 16
 
-static int jittime[NUMCLASSES]={0,1,2,5,10,20,50,100,200,500,1000,2000,5000,10000,20000,50000}; //in usec
+static int jittime[NUMCLASSES]={0,1,2,5,10,20,50,100,200,500,
+                                1000,2000,5000,10000,20000,50000}; //in usec
 static int jitcount[NUMCLASSES];
 static double jitpercent[NUMCLASSES];
-
 static unsigned int tcount = 1;
 
-
-
 static void msr_jit_read(void)
 {
     int i;
@@ -104,27 +63,28 @@
 
 void msr_jitter_init(void)
 {
-    msr_reg_int_list("/Taskinfo/Jitter/Classes","usec",&jittime[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
-    msr_reg_int_list("/Taskinfo/Jitter/Count","",&jitcount[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
-    msr_reg_dbl_list("/Taskinfo/Jitter/percent","%",&jitpercent[0],MSR_R,NUMCLASSES,NULL,NULL,&msr_jit_read);
+    msr_reg_int_list("/Taskinfo/Jitter/Classes","usec",
+                     &jittime[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
+    msr_reg_int_list("/Taskinfo/Jitter/Count","",
+                     &jitcount[0],MSR_R,NUMCLASSES,NULL,NULL,NULL);
+    msr_reg_dbl_list("/Taskinfo/Jitter/percent","%",
+                     &jitpercent[0],MSR_R,NUMCLASSES,NULL,NULL,&msr_jit_read);
 }
 
-/*
-***************************************************************************************************
-*
-* Function: msr_jitter_run
-*
-* Beschreibung: 
-*               
-*
-* Parameter: Zeiger auf msr_data
-*
-* Rückgabe: 
-*               
-* Status: exp
-*
-***************************************************************************************************
-*/
+/******************************************************************************
+ *
+ * Function: msr_jitter_run
+ *
+ * Beschreibung:
+ *
+ *
+ * Parameter: Zeiger auf msr_data
+ *
+ * Rückgabe:
+ *
+ * Status: exp
+ *
+ *****************************************************************************/
 
 void msr_jitter_run(unsigned int hz) {
 
@@ -140,9 +100,11 @@
 
     //Zeitabstand zwischen zwei Interrupts in usec
 
-    dt = ((unsigned long)(100000/HZ)*((unsigned long)(k-j)))/(current_cpu_data.loops_per_jiffy/10);
+    dt = ((unsigned long)(100000/HZ)*((unsigned long)(k-j)))
+        /(current_cpu_data.loops_per_jiffy/10);
 
-    jitter = (unsigned int)abs((int)dt-(int)1000000/hz); //jitter errechnet zum Sollabtastrate
+    jitter = (unsigned int)abs((int)dt-(int)1000000/hz);
+    //jitter errechnet zum Sollabtastrate
 
     //in die Klassen einsortieren
     if(!firstrun) { //das erste mal nicht einsortieren
@@ -165,20 +127,3 @@
 
 
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- a/rt/msr_jitter.h	Thu Jan 05 13:39:39 2006 +0000
+++ b/rt/msr_jitter.h	Thu Jan 05 14:11:25 2006 +0000
@@ -1,60 +1,22 @@
-/**************************************************************************************************
-*
-*                          msr_jitter.c
-*
-*           
-*           Autor: Wilhelm Hagemeister
-*
-*           (C) Copyright IgH 2002
-*           Ingenieurgemeinschaft IgH
-*           Heinz-Bäcker Str. 34
-*           D-45356 Essen
-*           Tel.: +49 201/61 99 31
-*           Fax.: +49 201/61 98 36
-*           E-mail: hm@igh-essen.com
-*
-*
-*           $RCSfile: msr_adeos_latency.c,v $
-*           $Revision: 1.3 $
-*           $Author: hm $
-*           $Date: 2005/12/07 20:13:53 $
-*           $State: Exp $
-*
-*
-*           $Log: msr_adeos_latency.c,v $
-*           Revision 1.3  2005/12/07 20:13:53  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2005/12/07 15:56:13  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2005/12/07 08:43:40  hm
-*           Initial revision
-*
-*           Revision 1.5  2005/11/14 20:28:09  hm
-*           *** empty log message ***
-*
-*           Revision 1.4  2005/11/13 10:34:07  hm
-*           *** empty log message ***
-*
-*           Revision 1.3  2005/11/12 20:52:46  hm
-*           *** empty log message ***
-*
-*           Revision 1.2  2005/11/12 20:51:27  hm
-*           *** empty log message ***
-*
-*           Revision 1.1  2005/11/12 19:16:02  hm
-*           Initial revision
-*
-*           Revision 1.13  2005/06/17 11:35:13  hm
-*           *** empty log message ***
-*
-*
-*
-*
-**************************************************************************************************/
+/******************************************************************************
+ *
+ * msr_jitter.c
+ *
+ * Autor: Wilhelm Hagemeister
+ *
+ * (C) Copyright IgH 2002
+ * Ingenieurgemeinschaft IgH
+ * Heinz-Bäcker Str. 34
+ * D-45356 Essen
+ * Tel.: +49 201/61 99 31
+ * Fax.: +49 201/61 98 36
+ * E-mail: hm@igh-essen.com
+ *
+ * $Id$
+ *
+ *****************************************************************************/
 
-/*--Schutz vor mehrfachem includieren------------------------------------------------------------*/
+/*--Schutz vor mehrfachem includieren----------------------------------------*/
 
 #ifndef _MSR_JITTER_H_
 #define _MSR_JITTER_H_
--- a/rt/msr_module.c	Thu Jan 05 13:39:39 2006 +0000
+++ b/rt/msr_module.c	Thu Jan 05 14:11:25 2006 +0000
@@ -399,6 +399,7 @@
 
     for (i = 0; i < ECAT_SLAVES_COUNT; i++) {
         if (EtherCAT_activate_slave(ecat_master, ecat_slaves + i) < 0) {
+            printk(KERN_ERR "EtherCAT: Could not activate slave %i!\n", i);
             goto out_release_master;
         }
     }
@@ -436,10 +437,10 @@
     ipipe_tune_timer(1000000000UL/HZ,0); //alten Timertakt wieder herstellen
     ipipe_unregister_domain(&this_domain);
 
-    printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n");
-
     if (ecat_master)
     {
+        printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n");
+
         printk(KERN_INFO "Deactivating slaves.\n");
 
         for (i = 0; i < ECAT_SLAVES_COUNT; i++) {
@@ -449,9 +450,9 @@
         }
 
         EtherCAT_release(ecat_master);
-    }
-
-    printk(KERN_INFO "=== EtherCAT environment stopped. ===\n");
+
+        printk(KERN_INFO "=== EtherCAT environment stopped. ===\n");
+    }
 
 #ifdef USE_MSR_LIB
     msr_rtlib_cleanup();
--- a/rt/msr_param.h	Thu Jan 05 13:39:39 2006 +0000
+++ b/rt/msr_param.h	Thu Jan 05 14:11:25 2006 +0000
@@ -1,7 +1,14 @@
+/******************************************************************************
+ *
+ * $Id$
+ *
+ *****************************************************************************/
+
 #ifndef _MSR_PARAM_H_
 #define _MSR_PARAM_H_
-#define  MSR_ABTASTFREQUENZ 10000   //FIXME nur für den Simulator, der virtuelle 10 Mal schneller läuft ....HZ  /* Abtastrate der Kan%/1€Œiso8859-15äle in [HZ]*/
+
+#define  MSR_ABTASTFREQUENZ 10000
 
 #endif
 
-
+/*****************************************************************************/