added get band select
authorJosh Blum <josh@joshknows.com>
Thu, 20 Aug 2009 23:20:31 +0000 (16:20 -0700)
committerJosh Blum <josh@joshknows.com>
Thu, 20 Aug 2009 23:20:31 +0000 (16:20 -0700)
gr-vrt/src/vrt_quadradio_source_32fc.cc
gr-vrt/src/vrt_quadradio_source_32fc.h
vrt/include/vrt/quadradio.h
vrt/lib/quadradio.cc

index 0321062aa93e015ae60118570719c4aed8aea5b3..77e61cf047440fb982ccef1f8a1a410e6d2253e6 100644 (file)
@@ -91,6 +91,12 @@ vrt_quadradio_source_32fc::set_band_select(const std::string &band)
   return d_qr->set_band_select(band);
 }
 
+std::string 
+vrt_quadradio_source_32fc::get_band_select(void)
+{
+  return d_qr->get_band_select();
+}
+
 //void 
 //vrt_quadradio_source_32fc::set_10dB_atten(bool on)
 //{
index 6ad63f7be46784f99aae3e54d52ca461c7e1206d..c7d5b9c503347210fd1d34edb47b8550465a0aec 100644 (file)
@@ -71,6 +71,7 @@ public:
    * \param band "A", "B", "C", "D"
    */
   bool set_band_select(const std::string &band);
+  std::string get_band_select(void);
 
   /*!
    * \brief Turn the 10 dB attenuation on/off.
index 747ca8ef4745e3d4f6dd948ee6b6a64a91a768df..86039aa375bb123e9bf88edfe945b6a2c677f51f 100644 (file)
@@ -53,7 +53,7 @@ namespace vrt {
     int                   d_data_port;        // our data port number
     vrt::rx::sptr  d_rx;              // has-a rx
     
-    int                   d_band_select;              // band select setting
+    std::string                   d_band_select;              // band select setting
     int                   d_rx_antenna;               // antenna type rf/cal
     int                   d_attenuation0;             // attenuation setting
     int                   d_attenuation1;             // attenuation setting
@@ -93,6 +93,7 @@ namespace vrt {
     /* convenience methods that ultimately write the dboard pins */
     bool set_center_freq(double target_freq);
     bool set_band_select(const std::string &band);
+    std::string get_band_select(void){return d_band_select;}
     //void set_10dB_atten(bool on);
     bool set_attenuation0(int attenuation);
     bool select_rx_antenna(const std::string &ant);
index ab5de89b8a2223712f7d38b4e2d5bff0e2d2db83..d4b466b2136589984383d13c555dc1ce1842cc44 100644 (file)
@@ -51,7 +51,7 @@ send_and_check(int fd, void *buf, size_t len)
 
 vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
   : d_ctrl_fd(0), d_data_fd(0), d_data_port(0),
-  d_band_select(0), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
+  d_band_select("A"), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true)
 {
   if (!open(ip.c_str()))
     throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
@@ -98,11 +98,7 @@ vrt::quadradio::set_center_freq(double target_freq){
 
 bool
 vrt::quadradio::set_band_select(const std::string &band){
-    if (band == "A") d_band_select = 3;
-    else if (band == "B") d_band_select = 2;
-    else if (band == "C") d_band_select = 1;
-    else if (band == "D") d_band_select = 0;
-    else return false;
+    d_band_select = band;
     update_dboard_pins();
     return true;
 }
@@ -149,11 +145,18 @@ static int reverse_bits(int input, int len){
 
 void
 vrt::quadradio::update_dboard_pins(void){
+    //convert the band ID to bits
+    int band_select;
+    if (d_band_select == "A") band_select = 3;
+    else if (d_band_select == "B") band_select = 2;
+    else if (d_band_select == "C") band_select = 1;
+    else if (d_band_select == "D") band_select = 0;
+    //calculate the control bits
     int db_ctrl = \
-        ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \
+        ((reverse_bits(d_attenuation0, 5)  & 0x1f) << 10) | \
         ((reverse_bits(~d_attenuation1, 5) & 0x1f) << 03) | \
-        ((d_band_select                   & 0x03) << 01) | \
-        ((d_rx_antenna                    & 0x01) << 00);
+        ((band_select                      & 0x03) << 01) | \
+        ((d_rx_antenna                     & 0x01) << 00);
     set_dboard_pins(ALL_DBOARDS, db_ctrl);  // FIXME sets them all
 }