From d7b40aa9160e86738b3853342f79e89a94424b6c Mon Sep 17 00:00:00 2001
From: Sven Robertz <sven@cs.lth.se>
Date: Wed, 14 Dec 2011 14:29:58 +0100
Subject: [PATCH] cleaned up debug output

---
 lib/c/ThrottleDrv/throttle_drv.c  | 20 ++++++++++++++++----
 lib/c/labcomm.c                   |  1 -
 lib/c/labcomm_thr_reader_writer.c |  2 --
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/c/ThrottleDrv/throttle_drv.c b/lib/c/ThrottleDrv/throttle_drv.c
index b081eef..2c34cee 100644
--- a/lib/c/ThrottleDrv/throttle_drv.c
+++ b/lib/c/ThrottleDrv/throttle_drv.c
@@ -133,7 +133,9 @@ struct thr_chn_t* thr_open_chn(const unsigned char* dst_adr, unsigned char chn_i
          tmp_chn->freq = freq;
          tmp_chn->funct = funct;
       }
+#ifdef DEBUG
       printf("thr_open_chn: callback = %x\n", tmp_chn->funct);
+#endif
 
    }
 
@@ -277,7 +279,9 @@ int thr_receive(struct thr_chn_t* thr_chn, unsigned char* data, void* param)
                }
                else
                {
-                  printf("Message Index %d on %d. Actual Index %d\n", THR_MSG_FRAG_NUM(thr_msg), THR_MSG_FRAG_TOT_NUM(thr_msg), frag_index);
+#ifdef DEBUG
+                  printf("thr_receive: Message Index %d on %d. Actual Index %d\n", THR_MSG_FRAG_NUM(thr_msg), THR_MSG_FRAG_TOT_NUM(thr_msg), frag_index);
+#endif
                   if (frag_index == THR_MSG_FRAG_NUM(thr_msg)) /* The fragment is the one expected ? */
                   {
                      /* Rebuild the original data linking the payloads of each fragment */
@@ -292,7 +296,7 @@ int thr_receive(struct thr_chn_t* thr_chn, unsigned char* data, void* param)
                   }
                   else
                   {
-                     printf("Fragment mismatch: Fragment discarded.\n");
+                     printf("thr_receive: Fragment mismatch: Fragment discarded.\n");
                      frag_index = 1;
                      p_data = data;
                   }
@@ -308,10 +312,14 @@ int thr_receive(struct thr_chn_t* thr_chn, unsigned char* data, void* param)
          }
          else
          {
-            printf("Number of byte receive %d\n",ret);
+#ifdef DEBUG
+            printf("thr_receive: Number of byte receive %d\n",ret);
+#endif
             thr_chn->msg_length = ret;
             memcpy(thr_chn->p_msg, data, ret); /* copy the msg into the thr structure */
-            printf("calling %x\n", thr_chn->funct);
+#ifdef DEBUG
+            printf("thr_receive: calling %x\n", thr_chn->funct);
+#endif
             (thr_chn->funct)(param);
             free(thr_chn->p_msg);
             thr_chn->p_msg = NULL;
@@ -374,9 +382,13 @@ int thr_read(struct thr_chn_t* thr_chn, unsigned char* data, int length)
       if (length > thr_chn->msg_length)
       {
          length = thr_chn->msg_length;
+#ifdef DEBUG
          printf("thr_read: truncating length to %d\n", length);
+#endif
       }
+#ifdef DEBUG
       printf("thr_read: calling memcpy(%x, %x, %d\n", data, thr_chn->p_msg, length);
+#endif
       memcpy(data, thr_chn->p_msg, length); /* copy the msg into the thr structure */
       ret = length;
       thr_chn->msg_length = 0;
diff --git a/lib/c/labcomm.c b/lib/c/labcomm.c
index 13aff96..34ce50b 100644
--- a/lib/c/labcomm.c
+++ b/lib/c/labcomm.c
@@ -418,7 +418,6 @@ int labcomm_decoder_decode_one(labcomm_decoder_t *d)
   int result = -1;
   if (d && d->do_decode_one)
   {
-    printf("labcomm decode 1\n");
     result = d->do_decode_one(d);
   }
   else
diff --git a/lib/c/labcomm_thr_reader_writer.c b/lib/c/labcomm_thr_reader_writer.c
index 4ba0147..10cedee 100644
--- a/lib/c/labcomm_thr_reader_writer.c
+++ b/lib/c/labcomm_thr_reader_writer.c
@@ -33,7 +33,6 @@ int labcomm_thr_reader(labcomm_reader_t *r, labcomm_reader_action_t action)
     case labcomm_reader_start:
     case labcomm_reader_continue:
     {
-       printf("labcomm_reader_start or continue...\n");
       if (r->pos < r->count)
       {
         result = r->count - r->pos;
@@ -42,7 +41,6 @@ int labcomm_thr_reader(labcomm_reader_t *r, labcomm_reader_action_t action)
       {
         int err;
         r->pos = 0;
-        printf("labcomm_thr_reader_writer. calling thr_read: %x, %x, %d\n", ctx, r->data, r->data_size);
         err = thr_read(ctx, r->data, r->data_size);
         if (err <= 0)
         {
-- 
GitLab