commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10487 - gnuradio/branches/releases/3.2/gr-msdd6000/sr


From: jcorgan
Subject: [Commit-gnuradio] r10487 - gnuradio/branches/releases/3.2/gr-msdd6000/src
Date: Mon, 23 Feb 2009 15:39:25 -0700 (MST)

Author: jcorgan
Date: 2009-02-23 15:39:24 -0700 (Mon, 23 Feb 2009)
New Revision: 10487

Removed:
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_base.cc
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_base.h
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_c.cc
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_c.h
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_s.cc
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_s.h
Modified:
   gnuradio/branches/releases/3.2/gr-msdd6000/src/Makefile.am
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd.i
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd6000.cc
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.cc
   gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.h
Log:
Merged r10430:10432 from trunk into release 3.2 branch

Modified: gnuradio/branches/releases/3.2/gr-msdd6000/src/Makefile.am
===================================================================
--- gnuradio/branches/releases/3.2/gr-msdd6000/src/Makefile.am  2009-02-23 
22:36:16 UTC (rev 10486)
+++ gnuradio/branches/releases/3.2/gr-msdd6000/src/Makefile.am  2009-02-23 
22:39:24 UTC (rev 10487)
@@ -67,10 +67,7 @@
 # These are the source files that go into the shared library
 _msdd_la_SOURCES =                     \
        msdd.cc                 \
-       msdd_source_base.cc     \
-       msdd_source_c.cc        \
        msdd_source_simple.cc   \
-       msdd_source_s.cc        \
        msdd6000.cc
 
 # magic flag
@@ -91,10 +88,7 @@
 
 # These headers get installed in ${prefix}/include/gnuradio
 grinclude_HEADERS =                    \
-       msdd_source_base.h              \
-       msdd_source_c.h                 \
        msdd_source_simple.h                    \
-       msdd_source_s.h         \
        msdd_buffer_copy_behaviors.h \
        msdd6000.h
 

Modified: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd.i
===================================================================
--- gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd.i       2009-02-23 
22:36:16 UTC (rev 10486)
+++ gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd.i       2009-02-23 
22:39:24 UTC (rev 10487)
@@ -23,227 +23,10 @@
 %include "gnuradio.i"  // the common stuff
 
 %{
-#include "msdd_source_s.h"
-#include "msdd_source_c.h"
 #include "msdd_source_simple.h"
 %}
 
-// ================================================================
-//                        abstract classes
-// ================================================================
 
-// ----------------------------------------------------------------
-
-class msdd_source_base : public gr_sync_block {
-
- protected:
-  msdd_source_base (const std::string &name,
-      gr_io_signature_sptr output_signature,
-      int which_board,
-      msdd_source_base::msdd_command_type_t opp_mode,
-      const char *src, 
-      unsigned short port_src
-         ) throw (std::runtime_error);
-
-  /*!
-   * \brief number of bytes in a low-level sample
-   */
-  unsigned int sizeof_basic_sample() const;
-
-  /*!
-   * \brief convert between native msdd format and output item format
-   *
-   * \param output_items[out]   stream(s) of output items
-   * \param output_index[in]    starting index in output_items
-   * \param output_items_available[in]  number of empty items available at 
item[index]
-   * \param output_items_produced[out]  number of items produced by copy
-   * \param msdd_buffer[in]   source buffer
-   * \param msdd_buffer_length[in]  number of bytes available in \p msdd_buffer
-   * \param bytes_read[out]   number of bytes read from \p msdd_buffer
-   *
-   * The copy must consume all bytes available.  That is, \p bytes_read must 
equal
-   * \p msdd_buffer_length.
-   */
-  virtual void copy_from_msdd_buffer (gr_vector_void_star &output_items,
-              int output_index,
-              int output_items_available,
-              int &output_items_produced,
-              const void *msdd_buffer,
-              int msdd_buffer_length,
-              int &bytes_read) = 0;
-  
-  int readsock(int sockfd, unsigned char* buf, int nbytes);
-
-  
-  void* make_request_packet(unsigned int& size, unsigned int number_samples);
-  
- public:
-  //! magic value used on alternate register read interfaces
-  static const int READ_FAILED = -99999;
-
-  ~msdd_source_base ();
-
-  int work (int noutput_items,
-      gr_vector_const_void_star &input_items,
-      gr_vector_void_star &output_items);
-
-  bool start();
-  bool stop();
-
-  /*!
-   * \brief Set Programmable Gain Amplifier (PGA)
-   *
-   * \param which      which D/A [0,3]
-   * \param gain_in_db gain value (linear in dB)
-   *
-   * gain is rounded to closest setting supported by hardware.
-   * Note that DAC 0 and DAC 1 share a gain setting as do DAC 2 and DAC 3.
-   * Setting DAC 0 affects DAC 1 and vice versa.  Same with DAC 2 and DAC 3.
-   *
-   * \returns true iff sucessful.
-   *
-   * \sa pga_min(), pga_max(), pga_db_per_step()
-   */
-  bool set_pga (int which, double gain_in_db);
-
-  /*!
-   * \brief Return programmable gain amplifier gain in dB.
-   *
-   * \param which      which D/A [0,3]
-   */
-  double pga (int which) const;
-
-  /*!
-   * \brief Return minimum legal PGA gain in dB.
-   */
-  double pga_min () const;
-
-  /*!
-   * \brief Return maximum legal PGA gain in dB.
-   */
-  double pga_max () const;
-
-  /*!
-   * \brief Return hardware step size of PGA (linear in dB).
-   */
-  double pga_db_per_step () const;
-
-  /*!
-   * \brief open a socket specified by the port and ip address info
-   *
-   * Opens a socket, binds to the address, and waits for a connection
-   * over UDP. If any of these fail, the fuction retuns the error and exits.
-   */
-  bool open();
-
-  /*!
-   * \brief Close current socket.
-   *
-   * Shuts down read/write on the socket
-   */
-  bool close();
-  
-  /*!
-   * \brief Set decimator rate.  \p rate must be EVEN and in [8, 256].
-   *
-   * The final complex sample rate across the USB is
-   *   adc_freq () / decim_rate ()
-   */
-  bool set_decim_rate (unsigned int rate);
-
-  /*!
-   * \brief set the center frequency of the digital down converter.
-   *
-   * \p channel must be 0.  \p freq is the center frequency in Hz.
-   * It must be in the range [-FIXME, FIXME].  The frequency specified is
-   * quantized.  Use rx_freq to retrieve the actual value used.
-   */
-  bool set_rx_freq (int channel, double freq);
-
-  void set_verbose (bool verbose);
-
-  // ACCESSORS
-
-  unsigned int decim_rate () const;
-  double rx_freq (int channel) const;
-  int noverruns () const { return d_noverruns; }
-
-  /*!
-   * \brief return the msdd's serial number.
-   *
-   * \returns non-zero length string iff successful.
-   */
-  std::string serial_number();
-  
-  bool set_desired_packet_size (int which, unsigned long packet_size);
-
-  unsigned long desired_packet_size (int which) const;
-
-};
-
-
-// ================================================================
-//      concrete sources
-// ================================================================
-
-
-// ----------------------------------------------------------------
-
-GR_SWIG_BLOCK_MAGIC(msdd,source_s)
-
-msdd_source_s_sptr
-msdd_make_source_s (int which_board, 
-            unsigned int decim_rate,
-            unsigned int fft_points,
-            double initial_rx_freq,
-            int opp_mode,
-            const char *src, 
-            unsigned short port_src
-         ) throw (std::runtime_error);
-
-
-class msdd_source_s : public msdd_source_base {
- protected:
-  msdd_source_s (int which_board, 
-      unsigned int decim_rate,
-      unsigned int fft_points,
-      double initial_rx_freq,
-      int opp_mode,
-          const char *src, 
-          unsigned short port_src
-      ) throw (std::runtime_error);
-
- public:
-  ~msdd_source_s ();
-};
-
-
-GR_SWIG_BLOCK_MAGIC(msdd,source_c)
-
-msdd_source_c_sptr
-msdd_make_source_c (int which_board, 
-            int opp_mode,
-            const char *src, 
-            unsigned short port_src
-         ) throw (std::runtime_error);
-
-
-class msdd_source_c : public msdd_source_base {
- protected:
-  msdd_source_c (int which_board, 
-      int opp_mode,
-          const char *src, 
-          unsigned short port_src
-      ) throw (std::runtime_error);
-
- public:
-  ~msdd_source_c ();
-};
-
-
-
-
-
 GR_SWIG_BLOCK_MAGIC(msdd,source_simple)
 
 msdd_source_simple_sptr

Modified: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd6000.cc
===================================================================
--- gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd6000.cc  2009-02-23 
22:36:16 UTC (rev 10486)
+++ gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd6000.cc  2009-02-23 
22:39:24 UTC (rev 10487)
@@ -86,7 +86,8 @@
 
 MSDD6000::~MSDD6000()
 {
-  // NOP
+    // printf("MSDD6000::Destructing\n");
+    close(d_sock);
 }
 
 

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_base.cc

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_base.h

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_c.cc

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_c.h

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_s.cc

Deleted: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_s.h

Modified: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.cc
===================================================================
--- gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.cc        
2009-02-23 22:36:16 UTC (rev 10486)
+++ gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.cc        
2009-02-23 22:39:24 UTC (rev 10487)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2008 Free Software Foundation, Inc.
+ * Copyright 2008,2009 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -28,20 +28,20 @@
 
 
 msdd_source_simple_sptr
-msdd_make_source_simple ( const char *src, unsigned short port_src) 
+msdd_make_source_simple (const char *src, unsigned short port_src) 
 {
   return msdd_source_simple_sptr (new msdd_source_simple ( src, port_src)); 
 }
 
 
-msdd_source_simple::msdd_source_simple (
-                   const char *src, 
-                   unsigned short port_src) 
-               : gr_sync_block("MSDD_SOURCE_SIMPLE",
-                               gr_make_io_signature (0,0,0),
-                               gr_make_io_signature (1, 1, sizeof (short))),
-                  rcv(new MSDD6000((char*) src)), d_lastseq(0)
+msdd_source_simple::msdd_source_simple (const char *src, 
+                                       unsigned short port_src) 
+  : gr_sync_block("MSDD_SOURCE_SIMPLE",
+                 gr_make_io_signature (0,0,0),
+                 gr_make_io_signature (1, 1, sizeof (short))),
+    rcv(new MSDD6000((char*) src)), d_lastseq(0), d_firstrun(true)
 {
+  set_output_multiple(MSDD_COMPLEX_SAMPLES_PER_PACKET*2);
 }
 
 msdd_source_simple::~msdd_source_simple ()
@@ -55,107 +55,111 @@
                          gr_vector_void_star &output_items)
 {
        
-#define BUF_LEN        (366*sizeof(short)*2 + 6)
+#define BUF_LEN        (MSDD_COMPLEX_SAMPLES_PER_PACKET*sizeof(short)*2 + 6)
 
-       float* out1 =(float*) output_items[0];
+  float* out1 =(float*) output_items[0];
 
-       char buffer[BUF_LEN];
-       rcv->read( &buffer[0], BUF_LEN );
+  for(int i=0; 
i<floor(noutput_items*1.0/(2*MSDD_COMPLEX_SAMPLES_PER_PACKET));i++){
+    char buffer[BUF_LEN];
+    rcv->read( &buffer[0], BUF_LEN );
 
-       int seq = *((int*) &buffer[2]);
-       
-       // FIXME get rid of these magic 366's!
-       if(d_lastseq == -366){
-               // not started case
-               if(seq == 0){
-                       d_lastseq = 0;
-                       } else {
-                       // THROW AWAY SAMPLES WE ARE NOT STARTED YET!
-                       return 0;
-                       }
-               
-               } else {
-               // started case
-               int samples_missed = seq - d_lastseq - 366;
-               if(samples_missed > 0){
-                       printf("dropped %d samples.\n", samples_missed);
-                       }
-               d_lastseq = seq;
-               }
-       
-       if(noutput_items< 366*2){
-               printf("NOT ENOUGH SPACE IN OUTPUT BUFFER!!! >:-(\n");
-               }
-       
-       memcpy(&out1[0], &buffer[6], BUF_LEN - 6);
-       
-//     for(int i = 0; i < 366*2; i++){
-//             out1[i] = (float)  (*((short*) &buffer[6+2*i]) );
-//     }
-       
-       return 366*2;
+    int seq = *((int*) &buffer[2]);
+
+    if(d_lastseq == -MSDD_COMPLEX_SAMPLES_PER_PACKET){
+      // not started case
+      if(seq == 0){
+       d_lastseq = 0;
+      } else {
+       // THROW AWAY SAMPLES WE ARE NOT STARTED YET!
+       return 0;
+      }
+
+    } else {
+      // started case
+      int samples_missed = seq - d_lastseq - MSDD_COMPLEX_SAMPLES_PER_PACKET;
+      if(samples_missed > 0){
+       if(d_firstrun == true){
+         // we may have missed some initial samples off the beginning of
+         // a stream but there are no drop outs in the middle of what we have
+       } else {
+         printf("dropped %d samples.\n", samples_missed);
+       }
+      }
+      d_lastseq = seq;
+    }
+
+    int out_idx = i*MSDD_COMPLEX_SAMPLES_PER_PACKET*2;
+    memcpy(&out1[out_idx], &buffer[6], BUF_LEN - 6);
+    d_firstrun = false;
+  }
+
+  return noutput_items;
+
 }
 
 bool msdd_source_simple::set_decim_rate(unsigned int rate)
 {
-       // FIXME seems buggy.  How about a floor or ceil?
-        rcv->set_decim((int) log2(rate));
-       return true;
+  rcv->set_decim((int) floor(log2(rate)));
+  return true;
 }
 
 
 bool msdd_source_simple::set_rx_freq(int channel, double freq)
 {
-       long new_fc = (long)freq;
-       rcv->set_fc( new_fc/1000000, new_fc%1000000);
-       return true;
+  long new_fc = (long)freq;
+  rcv->set_fc( new_fc/1000000, new_fc%1000000);
+  return true;
 }
 
 
 bool msdd_source_simple::set_pga(int which, double gain)
 {
-       if(gain < 0 || gain > 10){
-               printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n");
-               return false;
-       }
-       // ok i lied this is not really a pga, its decimation gain
-       rcv->set_ddc_gain((int)gain);
-       return true;
+  if(gain < 0 || gain > 10){
+    printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n");
+    return false;
+  }
+  // ok i lied this is not really a pga, its decimation gain
+  rcv->set_ddc_gain((int)gain);
+  return true;
 }
 
 
 bool msdd_source_simple::start()
 {
-       rcv->start();
-       return true;
+  rcv->start();
+  return true;
 }
 
 
 bool msdd_source_simple::stop()
 {
-       rcv->stop();
-       return true;
+  rcv->stop();
+  return true;
 }
 
-long msdd_source_simple::adc_freq(){
-       return 102400000;
+long msdd_source_simple::adc_freq()
+{
+  return 102400000;
 }
 
-int msdd_source_simple::decim_rate(){
-       return 1 << rcv->d_decim;
+int msdd_source_simple::decim_rate()
+{
+  return 1 << rcv->d_decim;
 }
 
 
-std::vector<int> msdd_source_simple::gain_range(){
-       static std::vector<int> r;
-       r.push_back(0);
-       r.push_back(12);
-       return r;
+std::vector<int> msdd_source_simple::gain_range()
+{
+  static std::vector<int> r;
+  r.push_back(0);
+  r.push_back(12);
+  return r;
 }
 
-std::vector<float> msdd_source_simple::freq_range(){
-       std::vector<float> r;
-       r.push_back(30.0*1000*1000);
-       r.push_back(6.0*1000*1000*1000);
-       return r;
+std::vector<float> msdd_source_simple::freq_range()
+{
+  std::vector<float> r;
+  r.push_back(30.0*1000*1000);
+  r.push_back(6.0*1000*1000*1000);
+  return r;
 }

Modified: gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.h
===================================================================
--- gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.h 
2009-02-23 22:36:16 UTC (rev 10486)
+++ gnuradio/branches/releases/3.2/gr-msdd6000/src/msdd_source_simple.h 
2009-02-23 22:39:24 UTC (rev 10487)
@@ -25,6 +25,7 @@
 #include <msdd6000.h>
 #include <boost/scoped_ptr.hpp>
 
+#define     MSDD_COMPLEX_SAMPLES_PER_PACKET        366
 
 class msdd_source_simple;
 typedef boost::shared_ptr<msdd_source_simple> msdd_source_simple_sptr;
@@ -32,22 +33,23 @@
 
 // public shared_ptr constructor
 
-msdd_source_simple_sptr msdd_make_source_simple ( const char *src, unsigned 
short port_src);
+msdd_source_simple_sptr msdd_make_source_simple(const char *src, unsigned 
short port_src);
 
 
 class msdd_source_simple : public gr_sync_block {
  private:
   friend msdd_source_simple_sptr
-  msdd_make_source_simple ( const char *src, unsigned short port_src);
+  msdd_make_source_simple(const char *src, unsigned short port_src);
 
   boost::scoped_ptr<MSDD6000> rcv;
   int d_lastseq;
+  bool d_firstrun;
 
  protected:
-  msdd_source_simple (const char *src, unsigned short port_src);
+  msdd_source_simple(const char *src, unsigned short port_src);
 
  public:
-  ~msdd_source_simple ();
+  ~msdd_source_simple();
   bool stop();
   bool start();
 





reply via email to

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