diff options
author | Josh Blum | 2009-08-20 16:20:31 -0700 |
---|---|---|
committer | Josh Blum | 2009-08-20 16:20:31 -0700 |
commit | 91f18267cd90fdeaea0a5f57543fa149019b251a (patch) | |
tree | b66eabb998e89fd48476d05127af5fc47f0c5994 | |
parent | 82d6410198b91eb21ccac9fe2aae66690956e584 (diff) | |
download | gnuradio-91f18267cd90fdeaea0a5f57543fa149019b251a.tar.gz gnuradio-91f18267cd90fdeaea0a5f57543fa149019b251a.tar.bz2 gnuradio-91f18267cd90fdeaea0a5f57543fa149019b251a.zip |
added get band select
-rw-r--r-- | gr-vrt/src/vrt_quadradio_source_32fc.cc | 6 | ||||
-rw-r--r-- | gr-vrt/src/vrt_quadradio_source_32fc.h | 1 | ||||
-rw-r--r-- | vrt/include/vrt/quadradio.h | 3 | ||||
-rw-r--r-- | vrt/lib/quadradio.cc | 21 |
4 files changed, 21 insertions, 10 deletions
diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.cc b/gr-vrt/src/vrt_quadradio_source_32fc.cc index 0321062aa..77e61cf04 100644 --- a/gr-vrt/src/vrt_quadradio_source_32fc.cc +++ b/gr-vrt/src/vrt_quadradio_source_32fc.cc @@ -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) //{ diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.h b/gr-vrt/src/vrt_quadradio_source_32fc.h index 6ad63f7be..c7d5b9c50 100644 --- a/gr-vrt/src/vrt_quadradio_source_32fc.h +++ b/gr-vrt/src/vrt_quadradio_source_32fc.h @@ -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. diff --git a/vrt/include/vrt/quadradio.h b/vrt/include/vrt/quadradio.h index 747ca8ef4..86039aa37 100644 --- a/vrt/include/vrt/quadradio.h +++ b/vrt/include/vrt/quadradio.h @@ -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); diff --git a/vrt/lib/quadradio.cc b/vrt/lib/quadradio.cc index ab5de89b8..d4b466b21 100644 --- a/vrt/lib/quadradio.cc +++ b/vrt/lib/quadradio.cc @@ -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 } |