From c5a3b8a954b7e56206879962305c37a5393bc0c1 Mon Sep 17 00:00:00 2001
From: winckel <winckel@eurecom.fr>
Date: Wed, 4 Dec 2013 16:33:36 +0000
Subject: [PATCH] Modified timer log to use oaisim / lte-softmodem logging
 rather than fprintf when available. Moved itti initialization in oaisim to
 have log initialized just before.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4594 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 common/utils/itti/timer.c         | 13 ++++++++++---
 targets/SIMU/USER/oaisim.c        |  6 +-----
 targets/SIMU/USER/oaisim_config.c | 13 ++++++++++++-
 3 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/common/utils/itti/timer.c b/common/utils/itti/timer.c
index 009a47c188..faee3908fc 100644
--- a/common/utils/itti/timer.c
+++ b/common/utils/itti/timer.c
@@ -41,14 +41,19 @@
 #include "assertions.h"
 #include "intertask_interface.h"
 #include "timer.h"
-
+#include "log.h"
 #include "queue.h"
 
+#if defined (LOG_D) && defined (LOG_E)
+# define TMR_DEBUG(x, args...)  LOG_D(TMR, x, ##args)
+# define TMR_ERROR(x, args...)  LOG_E(TMR, x, ##args)
+#endif
+
 #ifndef TMR_DEBUG
-# define TMR_DEBUG(x, args...) do { fprintf(stdout, "[TMR][D]"x, ##args); } while(0)
+# define TMR_DEBUG(x, args...)  do { fprintf(stdout, "[TMR][D]"x, ##args); } while(0)
 #endif
 #ifndef TMR_ERROR
-# define TMR_ERROR(x, args...) do { fprintf(stdout, "[TMR][E]"x, ##args); } while(0)
+# define TMR_ERROR(x, args...)  do { fprintf(stdout, "[TMR][E]"x, ##args); } while(0)
 #endif
 
 int timer_handle_signal(siginfo_t *info);
@@ -204,6 +209,8 @@ int timer_setup(
     pthread_mutex_lock(&timer_desc.timer_list_mutex);
     STAILQ_INSERT_TAIL(&timer_desc.timer_queue, timer_p, entries);
     pthread_mutex_unlock(&timer_desc.timer_list_mutex);
+#else
+    return -1;
 #endif
 
     return 0;
diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c
index 0bc456bfe9..8da76d5052 100644
--- a/targets/SIMU/USER/oaisim.c
+++ b/targets/SIMU/USER/oaisim.c
@@ -74,7 +74,7 @@ char smbv_ip[16];
 #include "enb_app.h"
 
 #if defined(ENABLE_ITTI)
-# include "intertask_interface_init.h"
+# include "intertask_interface.h"
 # include "timer.h"
 # if defined(ENABLE_USE_MME)
 #   include "s1ap_eNB.h"
@@ -963,10 +963,6 @@ int main(int argc, char **argv) {
   // get command-line options
   get_simulation_options (argc, argv); //Command-line options
   
-#if defined(ENABLE_ITTI)
-  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file);
-#endif
-
   // Initialize VCD LOG module
   vcd_signal_dumper_init ("openair_dump.vcd");
 
diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c
index 005f9ef1e4..eafabf0875 100644
--- a/targets/SIMU/USER/oaisim_config.c
+++ b/targets/SIMU/USER/oaisim_config.c
@@ -14,6 +14,10 @@
 #include "UTIL/OTG/otg_vars.h"
 #include "oml.h"
 
+#if defined(ENABLE_ITTI)
+# include "intertask_interface_init.h"
+#endif
+
 mapping log_level_names[] =
 {
     {"emerg", LOG_EMERG},
@@ -381,6 +385,10 @@ void oaisim_config() {
  //initialize the log generator 
   logInit();
 
+#if defined(ENABLE_ITTI)
+  itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info, messages_definition_xml, oai_emulation.info.itti_dump_file);
+#endif
+
   // init ocg if enabled, otherwise take the params form the init_oai_emulation()
  //  and command line options given by the user
   if (oai_emulation.info.ocg_enabled == 1){ // activate OCG: xml-based scenario parser
@@ -1007,9 +1015,12 @@ int ocg_config_emu(){
   if (oai_emulation.emulation_config.emulation_time_ms != 0) {
     oai_emulation.info.n_frames  =  (int) oai_emulation.emulation_config.emulation_time_ms / 10; // configure the number of frame
     oai_emulation.info.n_frames_flag = 1;
+  }
+  if (oai_emulation.info.n_frames_flag) {
     LOG_I(OCG, "number of frames in emulation is set to %d\n", oai_emulation.info.n_frames);
-  } else
+  } else {
     LOG_I(OCG, "number of frames in emulation is set to infinity\n");
+  }
   
   oai_emulation.info.seed = (oai_emulation.emulation_config.seed.value == 0) ? oai_emulation.info.seed : oai_emulation.emulation_config.seed.value;
   LOG_I (OCG,"The seed value is set to %d \n", oai_emulation.info.seed );
-- 
GitLab