commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4111 - gnuradio/branches/developers/n4hy/ofdm/gnuradi


From: n4hy
Subject: [Commit-gnuradio] r4111 - gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general
Date: Sun, 17 Dec 2006 00:41:45 -0700 (MST)

Author: n4hy
Date: 2006-12-17 00:41:45 -0700 (Sun, 17 Dec 2006)
New Revision: 4111

Modified:
   
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
Log:
timing works, still needs frequency correction


Modified: 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
===================================================================
--- 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
     2006-12-17 05:51:54 UTC (rev 4110)
+++ 
gnuradio/branches/developers/n4hy/ofdm/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc
     2006-12-17 07:41:45 UTC (rev 4111)
@@ -49,6 +49,7 @@
   i_now = 0;
 }
 
+/*
 void
 gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int 
&ninput_items_required)
 {
@@ -71,7 +72,18 @@
   for (unsigned i = 0; i < ninputs; i++)
     ninput_items_required[i] = nreqd+1;
 }
+*/
 
+void
+gr_ofdm_sampler::forecast (int noutput_items, gr_vector_int 
&ninput_items_required)
+{
+  // FIXME need more if we want to produce more than 1
+  int nreqd  = d_fft_length + d_symbol_length + 1;
+  unsigned ninputs = ninput_items_required.size ();
+  for (unsigned i = 0; i < ninputs; i++)
+    ninput_items_required[i] = nreqd;
+}
+
 int
 gr_ofdm_sampler::general_work (int noutput_items,
                               gr_vector_int &ninput_items,
@@ -83,22 +95,66 @@
   gr_complex *iptr = (gr_complex *) input_items[0];
   gr_complex *optr = (gr_complex *) output_items[0];
 
+  int found=0;
+  float alpha = 0.01;
+
+  for(unsigned int i=0;i<d_symbol_length;i++)
+    d_avg = (alpha)*theta[i].real() + (1-alpha)*d_avg;
+    
+  unsigned int i=d_fft_length;
+
+  while(i<d_symbol_length+d_fft_length && (found==0)) {
+    if( (theta[i].real() > d_avg*0.10) &&
+       (theta[i].real() > theta[i+1].real()) ) {
+      fprintf(stderr,"Peak at %d, %f\n",i,theta[i].real());
+      found = 1;
+      for(unsigned int j=0;j<d_fft_length;j++) {
+       *optr++ = iptr[i-d_fft_length+j+1];
+      }
+    }
+    else {
+      i++;
+    }
+  }
+  consume_each(d_symbol_length);
+  return found;
+}
+
+  /*
+  for(unsigned int i=0;i<d_symbol_length;i++)
+    fprintf(stderr,"%d  %f\n",i,theta[i].real());
+  for(unsigned int i=0;i<d_fft_length;i++) {
+    *optr++ = iptr[i+d_delay];
+    */
+
+/*
+int
+gr_ofdm_sampler::general_work (int noutput_items,
+                              gr_vector_int &ninput_items,
+                              gr_vector_const_void_star &input_items,
+                              gr_vector_void_star &output_items)
+{
+  gr_complex *theta   = (gr_complex *) input_items[1];
+  gr_complex *epsilon = (gr_complex *) input_items[2];
+  gr_complex *iptr = (gr_complex *) input_items[0];
+  gr_complex *optr = (gr_complex *) output_items[0];
+
   bool found = false;
   unsigned int peak_index=0;
   unsigned int nproduced=0;
   unsigned int i = 0;
 
   fprintf(stderr, "enter\n");
-  /*
-  while(i < -(std::min(0, d_delay))) {
-    increment_loop((theta[i]).real());
-    i++;
-    glb_i++;
+
+// while(i < -(std::min(0, d_delay))) {
+//   increment_loop((theta[i]).real());
+//  i++;
+//  glb_i++;
   }
-  */
 
-  unsigned int lastindex = ninput_items[0] - std::max(0, d_delay) - 
d_symbol_length;
 
+unsigned int lastindex = ninput_items[0] - std::max(0, d_delay) - 
d_symbol_length;
+
   while(i < lastindex) {
     found = false;
     
@@ -140,6 +196,7 @@
   consume_each(i);
   return nproduced;
 }
+*/
 
 void gr_ofdm_sampler::increment_loop(float theta)
 {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]