From f452d0dbd5728bded6316ceb0969b5d8ca1af4d4 Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Thu, 20 Apr 2006 14:34:58 +0000
Subject: [PATCH] Introduced version number define.

---
 devices/Makefile |   4 +-
 master/Makefile  |   4 +-
 master/globals.h |  54 +++++++++++++++++--------
 master/module.c  | 101 ++++++++++++++++++++++++-----------------------
 4 files changed, 96 insertions(+), 67 deletions(-)

diff --git a/devices/Makefile b/devices/Makefile
index 96002626..1288beee 100644
--- a/devices/Makefile
+++ b/devices/Makefile
@@ -17,7 +17,9 @@ obj-m := ec_8139too.o
 
 ec_8139too-objs := 8139too.o
 
-EXTRA_CFLAGS = -DEC_REV="$(shell svnversion $(src))" -DEC_USER="$(USER)"
+REV := $(shell svnversion $(src) 2>/dev/null)
+
+EXTRA_CFLAGS = -DEC_REV=$(REV) -DEC_USER=$(USER)
 
 #------------------------------------------------------------------------------
 
diff --git a/master/Makefile b/master/Makefile
index 682663b2..d3810942 100644
--- a/master/Makefile
+++ b/master/Makefile
@@ -18,7 +18,9 @@ obj-m := ec_master.o
 ec_master-objs := module.o master.o device.o slave.o command.o types.o \
 			domain.o mailbox.o canopen.o ethernet.o
 
-EXTRA_CFLAGS := -DSVNREV=$(shell svnversion $(src)) -DUSER=$(USER)
+REV := $(shell svnversion $(src) 2>/dev/null)
+
+EXTRA_CFLAGS := -DSVNREV=$(REV) -DUSER=$(USER)
 
 #------------------------------------------------------------------------------
 
diff --git a/master/globals.h b/master/globals.h
index 89601bb5..e718a80f 100644
--- a/master/globals.h
+++ b/master/globals.h
@@ -13,23 +13,45 @@
 
 #include <linux/types.h>
 
-/*****************************************************************************/
+/******************************************************************************
+ *  EtherCAT master
+ *****************************************************************************/
+
+#define EC_MASTER_VERSION_MAIN  1
+#define EC_MASTER_VERSION_SUB   0
+#define EC_MASTER_VERSION_EXTRA "trunk"
+
+/** maximum number of FMMUs per slave */
+#define EC_MAX_FMMUS 16
+
+/******************************************************************************
+ *  EtherCAT protocol
+ *****************************************************************************/
+
+/** maximum size of an EtherCAT frame (without header and CRC) */
+#define EC_MAX_FRAME_SIZE 1500
+
+/** ... minimum size */
+#define EC_MIN_FRAME_SIZE 46
+
+/** size of an EtherCAT frame header */
+#define EC_FRAME_HEADER_SIZE 2
+
+/** size of an EtherCAT command header */
+#define EC_COMMAND_HEADER_SIZE 10
+
+/** size of an EtherCAT command footer */
+#define EC_COMMAND_FOOTER_SIZE 2
+
+/** size of a sync manager configuration page */
+#define EC_SYNC_SIZE 8
+
+/** size of an FMMU configuration page */
+#define EC_FMMU_SIZE 16
 
-// EtherCAT-Protokoll
-#define EC_MAX_FRAME_SIZE 1500 /**< maximum size of an EtherCAT frame (without
-                                header and CRC) */
-#define EC_MIN_FRAME_SIZE 46 /** ... minimum size */
-#define EC_FRAME_HEADER_SIZE 2 /**< size of an EtherCAT frame header */
-#define EC_COMMAND_HEADER_SIZE 10 /**< size of an EtherCAT command header */
-#define EC_COMMAND_FOOTER_SIZE 2 /**< size of an EtherCAT command footer */
-#define EC_SYNC_SIZE 8 /**< size of a sync manager configuration page */
-#define EC_FMMU_SIZE 16 /**< size of an FMMU configuration page */
-#define EC_MAX_FMMUS 16 /**< maximum number of FMMUs per slave */
-#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE \
-                          - EC_FRAME_HEADER_SIZE \
-                          - EC_COMMAND_HEADER_SIZE \
-                          - EC_COMMAND_FOOTER_SIZE) /**< maximum data size of a
-                                                       single command */
+/** resulting maximum data size of a single command in a frame */
+#define EC_MAX_DATA_SIZE (EC_MAX_FRAME_SIZE - EC_FRAME_HEADER_SIZE \
+                          - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE)
 
 /*****************************************************************************/
 
diff --git a/master/module.c b/master/module.c
index 0fe646f2..ce8d28db 100644
--- a/master/module.c
+++ b/master/module.c
@@ -33,7 +33,10 @@ void __exit ec_cleanup_module(void);
 
 /*****************************************************************************/
 
-#define COMPILE_INFO "Revision " EC_STR(SVNREV) \
+#define COMPILE_INFO EC_STR(EC_MASTER_VERSION_MAIN) \
+                     "." EC_STR(EC_MASTER_VERSION_SUB) \
+                     " (" EC_MASTER_VERSION_EXTRA ")" \
+                     " - rev. " EC_STR(SVNREV) \
                      ", compiled by " EC_STR(USER) \
                      " at " __DATE__ " " __TIME__
 
@@ -149,6 +152,54 @@ ec_master_t *ec_find_master(unsigned int master_index /**< master index */)
     return NULL;
 }
 
+/*****************************************************************************/
+
+/**
+   Outputs frame contents for debugging purposes.
+*/
+
+void ec_print_data(const uint8_t *data, /**< pointer to data */
+                   size_t size /**< number of bytes to output */
+                   )
+{
+    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");
+}
+
+/*****************************************************************************/
+
+/**
+   Outputs frame contents and differences for debugging purposes.
+*/
+
+void ec_print_data_diff(const uint8_t *d1, /**< first data */
+                        const uint8_t *d2, /**< second data */
+                        size_t size /** number of bytes to output */
+                        )
+{
+    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");
+}
+
 /******************************************************************************
  *  Device interface
  *****************************************************************************/
@@ -354,54 +405,6 @@ void ecrt_release_master(ec_master_t *master /**< EtherCAT master */)
 
 /*****************************************************************************/
 
-/**
-   Outputs frame contents for debugging purposes.
-*/
-
-void ec_print_data(const uint8_t *data, /**< pointer to data */
-                   size_t size /**< number of bytes to output */
-                   )
-{
-    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");
-}
-
-/*****************************************************************************/
-
-/**
-   Outputs frame contents and differences for debugging purposes.
-*/
-
-void ec_print_data_diff(const uint8_t *d1, /**< first data */
-                        const uint8_t *d2, /**< second data */
-                        size_t size /** number of bytes to output */
-                        )
-{
-    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);
 
-- 
GitLab