Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
authorFlorian Pose <fp@igh-essen.com>
Wed, 05 Apr 2006 08:23:40 +0000
changeset 152 9654f3cf588d
parent 151 1961b674466c
child 153 32446a24c322
Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
master/device.c
master/globals.h
master/module.c
--- a/master/device.c	Wed Apr 05 07:55:51 2006 +0000
+++ b/master/device.c	Wed Apr 05 08:23:40 2006 +0000
@@ -19,11 +19,6 @@
 
 /*****************************************************************************/
 
-void ec_data_print(const uint8_t *, size_t);
-void ec_data_print_diff(const uint8_t *, const uint8_t *, size_t);
-
-/*****************************************************************************/
-
 /**
    EtherCAT-Geräte-Konstuktor.
 
@@ -177,7 +172,7 @@
 
     if (unlikely(device->master->debug_level > 1)) {
         EC_DBG("sending frame:\n");
-        ec_data_print(device->tx_skb->data + ETH_HLEN, size);
+        ec_print_data(device->tx_skb->data + ETH_HLEN, size);
     }
 
     // Senden einleiten
@@ -195,54 +190,6 @@
     if (likely(device->isr)) device->isr(0, device->dev, NULL);
 }
 
-/*****************************************************************************/
-
-/**
-   Gibt Frame-Inhalte zwecks Debugging aus.
-*/
-
-void ec_data_print(const uint8_t *data /**< Daten */,
-                   size_t size /**< Anzahl Bytes */
-                   )
-{
-    size_t i;
-
-    EC_DBG("");
-    for (i = 0; i < size; i++) {
-        printk("%02X ", data[i]);
-        if ((i + 1) % 16 == 0) {
-            printk("\n");
-            EC_DBG("");
-        }
-    }
-    printk("\n");
-}
-
-/*****************************************************************************/
-
-/**
-   Gibt Frame-Inhalte zwecks Debugging aus, differentiell.
-*/
-
-void ec_data_print_diff(const uint8_t *d1, /**< Daten 1 */
-                        const uint8_t *d2, /**< Daten 2 */
-                        size_t size /** Anzahl Bytes */
-                        )
-{
-    size_t i;
-
-    EC_DBG("");
-    for (i = 0; i < size; i++) {
-        if (d1[i] == d2[i]) printk(".. ");
-        else printk("%02X ", d2[i]);
-        if ((i + 1) % 16 == 0) {
-            printk("\n");
-            EC_DBG("");
-        }
-    }
-    printk("\n");
-}
-
 /******************************************************************************
  *
  * Treiberschnittstelle
@@ -277,7 +224,7 @@
 {
     if (unlikely(device->master->debug_level > 1)) {
         EC_DBG("Received frame:\n");
-        ec_data_print_diff(device->tx_skb->data + ETH_HLEN, data, size);
+        ec_print_data_diff(device->tx_skb->data + ETH_HLEN, data, size);
     }
 
     ec_master_receive(device->master, data, size);
--- a/master/globals.h	Wed Apr 05 07:55:51 2006 +0000
+++ b/master/globals.h	Wed Apr 05 08:23:40 2006 +0000
@@ -11,6 +11,8 @@
 #ifndef _EC_GLOBALS_
 #define _EC_GLOBALS_
 
+#include <linux/types.h>
+
 /*****************************************************************************/
 
 // EtherCAT-Protokoll
@@ -30,6 +32,8 @@
                                                        bei einem Kommando pro
                                                        Frame */
 
+/*****************************************************************************/
+
 #define EC_INFO(fmt, args...) \
     printk(KERN_INFO "EtherCAT: " fmt, ##args)
 #define EC_ERR(fmt, args...) \
@@ -41,6 +45,11 @@
 
 /*****************************************************************************/
 
+extern void ec_print_data(const uint8_t *, size_t);
+extern void ec_print_data_diff(const uint8_t *, const uint8_t *, size_t);
+
+/*****************************************************************************/
+
 #endif
 
 /* Emacs-Konfiguration
--- a/master/module.c	Wed Apr 05 07:55:51 2006 +0000
+++ b/master/module.c	Wed Apr 05 08:23:40 2006 +0000
@@ -333,6 +333,52 @@
 
 /*****************************************************************************/
 
+/**
+   Gibt Frame-Inhalte zwecks Debugging aus.
+*/
+
+void ec_print_data(const uint8_t *data, size_t size)
+{
+    unsigned int i;
+
+    EC_DBG("");
+    for (i = 0; i < size; i++) {
+        printk("%02X ", data[i]);
+        if ((i + 1) % 16 == 0) {
+            printk("\n");
+            EC_DBG("");
+        }
+    }
+    printk("\n");
+}
+
+/*****************************************************************************/
+
+/**
+   Gibt Frame-Inhalte zwecks Debugging aus, differentiell.
+*/
+
+void ec_print_data_diff(const uint8_t *d1, /**< Daten 1 */
+                        const uint8_t *d2, /**< Daten 2 */
+                        size_t size /** Anzahl Bytes */
+                        )
+{
+    unsigned int i;
+
+    EC_DBG("");
+    for (i = 0; i < size; i++) {
+        if (d1[i] == d2[i]) printk(".. ");
+        else printk("%02X ", d2[i]);
+        if ((i + 1) % 16 == 0) {
+            printk("\n");
+            EC_DBG("");
+        }
+    }
+    printk("\n");
+}
+
+/*****************************************************************************/
+
 module_init(ec_init_module);
 module_exit(ec_cleanup_module);