reading the lo back and storing it
authorJosh Blum <josh@joshknows.com>
Sat, 26 Sep 2009 02:04:35 +0000 (19:04 -0700)
committerJosh Blum <josh@joshknows.com>
Sat, 26 Sep 2009 02:04:35 +0000 (19:04 -0700)
gr-vrt/src/vrt_quadradio_source_32fc.h
gr-vrt/src/vrt_source_32fc.cc
gr-vrt/src/vrt_source_32fc.h

index 69384ca31dbed794cb11a91e3d667557fcef78ea..4589908f1e451aeeecb703fc6c3019c913b12c6a 100644 (file)
@@ -112,6 +112,9 @@ public:
   bool set_cal_freq(double freq);
   bool set_beamforming(std::vector<gr_complex> gains);
   bool set_cal_enb(bool enb);
+  
+  double get_cal_freq(void){return d_actual_cal_freq;}
+  double get_lo_freq(void){return d_actual_lo_freq;}
 };
 
 
index 9164ab9d8fb14b5bc4a455ff573d476aac82fadc..551ea98212615be739d8d51c483bdcc025f1bfae 100644 (file)
@@ -46,7 +46,8 @@ class rx_32fc_handler : public vrt::rx_packet_handler
   int                               *d_oo;             // output index
   std::vector< std::complex<float> > &d_remainder;
   missing_pkt_checker               &d_checker;
-  
+  all_context_t d_if_context;
+  size_t d_if_context_n32_bit_words;
 
 public:
 
@@ -54,13 +55,16 @@ public:
                  int *oo, std::vector< std::complex<float> > &remainder,
                  missing_pkt_checker &checker)
     : d_noutput_items(noutput_items), d_out(out),
-      d_oo(oo), d_remainder(remainder), d_checker(checker) {}
+      d_oo(oo), d_remainder(remainder), d_checker(checker),
+      d_if_context_n32_bit_words(0) {}
 
   ~rx_32fc_handler();
 
   bool operator()(const uint32_t *payload,
                  size_t n32_bit_words,
                  const vrt::expanded_header *hdr);
+  all_context_t* get_if_context(void){
+    return d_if_context_n32_bit_words? &d_if_context : NULL;};
 };
 
 rx_32fc_handler::~rx_32fc_handler()
@@ -100,15 +104,10 @@ rx_32fc_handler::operator()(const uint32_t *payload,
   else if (hdr->if_context_p()){
     // print the IF-Context packet
     fprintf(stderr, "\nIF-Context:\n");
-    for (size_t i = 0; i < n32_bit_words; i++)
-      fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i]));
-    // copy the context into struct so we cant reference bad memory
-    // print the components of the struct, prove that it works!
-    all_context_t if_context;
-    memcpy(&if_context, payload, sizeof(uint32_t)*n32_bit_words);//FIXME
-    fprintf(stderr, "\nIF-Context-Components:\n");
-    if_context.beamformer.rf_ref_freq = ntohll(if_context.beamformer.rf_ref_freq);
-    fprintf(stderr, "Ref Freq %f Hz\n", vrt_freq_to_double(if_context.beamformer.rf_ref_freq));
+    //for (size_t i = 0; i < n32_bit_words; i++)
+    //  fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i]));
+    memcpy(&d_if_context, payload, sizeof(uint32_t)*n32_bit_words);
+    d_if_context_n32_bit_words = n32_bit_words;
     return true;
   }
   else {
@@ -169,5 +168,11 @@ vrt_source_32fc::work(int noutput_items,
     return -1; // say we're done
   }
 
+  //we have a context packet, grab its useful information...
+  //remember that things are in network byte order!
+  if (h.get_if_context()){
+    d_actual_lo_freq = vrt_freq_to_double(ntohll(h.get_if_context()->beamformer.rf_ref_freq));
+  }
+
   return oo;
 }
index 7ca3e5fe25b7368f506627ef31b4d00c42705e04..96e9cac427528c57af779acd5154c854977ce00c 100644 (file)
@@ -33,6 +33,8 @@ protected:
 
   std::vector< std::complex<float> >   d_remainder;
   missing_pkt_checker                  d_checker;
+  double d_actual_lo_freq;
+  double d_actual_cal_freq;
 
 public:
   ~vrt_source_32fc();
@@ -42,7 +44,6 @@ public:
           gr_vector_void_star &output_items);
 
   void reset() { d_remainder.clear(); }
-
 };
 
 #endif /* INCLUDED_VRT_SOURCE_32FC_H */