From 8950c6ddd39894e974aa546a60561158e0fe205a Mon Sep 17 00:00:00 2001
From: Wang Tsu-Han <wangts@eurecom.fr>
Date: Fri, 17 Nov 2017 16:42:17 +0100
Subject: [PATCH] Bug fix for UDP loading

---
 common/utils/itti/intertask_interface.c | 7 +++++++
 targets/COMMON/create_tasks.c           | 8 +++++++-
 targets/RT/USER/lte-ru.c                | 4 ++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c
index 193b2c13fb..fc366f6057 100644
--- a/common/utils/itti/intertask_interface.c
+++ b/common/utils/itti/intertask_interface.c
@@ -99,6 +99,10 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS);
 # define ITTI_MEM_SIZE      (16 * 1024 * 1024)
 #endif
 
+#ifndef EMULATE_RF
+#define EMULATE_RF
+#endif
+
 typedef enum task_state_s {
   TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX,
 } task_state_t;
@@ -436,6 +440,8 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me
                  destination_task_id,
                  itti_get_task_name(destination_task_id));
     } else {
+      #ifdef EMULATE_RF
+      #else
       /* We cannot send a message if the task is not running */
       AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY,
                    "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n",
@@ -444,6 +450,7 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me
                    message_id,
                    destination_thread_id,
                    itti_desc.threads[destination_thread_id].task_state);
+      #endif
 
       /* Allocate new list element */
       new = (message_list_t *) itti_malloc (origin_task_id, destination_task_id, sizeof(struct message_list_s));
diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c
index ef3124ff24..65aed76742 100644
--- a/targets/COMMON/create_tasks.c
+++ b/targets/COMMON/create_tasks.c
@@ -40,6 +40,10 @@
 # endif
 # include "enb_app.h"
 
+#ifndef EMULATE_RF
+#define EMULATE_RF
+#endif
+
 int create_tasks(uint32_t enb_nb, uint32_t ue_nb)
 {
   itti_wait_ready(1);
@@ -71,11 +75,13 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb)
           LOG_E(S1AP, "Create task for S1AP failed\n");
           return -1;
         }
-
+        #ifdef EMULATE_RF
+        #else
         if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) {
           LOG_E(UDP_, "Create task for UDP failed\n");
           return -1;
         }
+        #endif
 
         if (itti_create_task (TASK_GTPV1_U, &gtpv1u_eNB_task, NULL) < 0) {
           LOG_E(GTPU, "Create task for GTPV1U failed\n");
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 8c139ae22f..922ff37c85 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -715,7 +715,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
   
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
  
-  proc->timestamp_rx = ts-ru->ts_offset;
+  proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset;
 
   if (rxs != fp->samples_per_tti)
     LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs);
@@ -728,7 +728,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) {
     if (proc->timestamp_rx - old_ts != fp->samples_per_tti) {
       //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset);
       ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti);
-      proc->timestamp_rx = ts-ru->ts_offset;
+      proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset;
     }
 
   }
-- 
GitLab