[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11174 - in gnuradio/branches/developers/eb/vrt: gr-ut
From: |
jblum |
Subject: |
[Commit-gnuradio] r11174 - in gnuradio/branches/developers/eb/vrt: gr-utils/src/python gr-vrt/src vrt/include/vrt vrt/lib |
Date: |
Thu, 4 Jun 2009 11:05:32 -0600 (MDT) |
Author: jblum
Date: 2009-06-04 11:05:32 -0600 (Thu, 04 Jun 2009)
New Revision: 11174
Modified:
gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt.i
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
Log:
convenience methods that ultimately write the dboard pins
Modified: gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
2009-06-04 03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/gr-utils/src/python/qr_fft.py
2009-06-04 17:05:32 UTC (rev 11174)
@@ -200,13 +200,14 @@
hbox.Add((5,0), 0)
vbox.Add(hbox, 0, wx.EXPAND)
##### db control stuff #####
+ self.subscribe('db_ctrl_atten', self.u.set_attenuation)
+ self.subscribe('db_ctrl_10db', self.u.set_10dB_atten)
+ self.subscribe('db_ctrl_bandsel', self.u.set_band_select)
+ self.subscribe('db_ctrl_type', self.u.select_rx_antenna)
self['db_ctrl_atten'] = 0
self['db_ctrl_10db'] = False
- self['db_ctrl_bandsel'] = 3
- self['db_ctrl_type'] = 0
- for key in ('db_ctrl_atten', 'db_ctrl_10db', 'db_ctrl_bandsel',
'db_ctrl_type'):
- self.subscribe(key, self.update_db_ctrl)
- self.update_db_ctrl() #init
+ self['db_ctrl_bandsel'] = 'A'
+ self['db_ctrl_type'] = 'cal'
hbox = wx.BoxSizer(wx.HORIZONTAL)
hbox.AddSpacer(10)
#create slider for atten
@@ -224,7 +225,7 @@
ps=self,
key='db_ctrl_atten',
minimum=0,
- maximum=(2**5)-1,
+ maximum=31,
step_size=1,
cast=int,
sizer=hbox,
@@ -250,7 +251,7 @@
label='Band Select',
ps=self,
key='db_ctrl_bandsel',
- choices=[3, 1, 2, 0],
+ choices=['A', 'B', 'C', 'D'],
labels=['A', 'B', 'C', 'D'],
sizer=hbox,
parent=panel,
@@ -262,7 +263,7 @@
label='RF Input',
ps=self,
key='db_ctrl_type',
- choices=[0, 1],
+ choices=['rf', 'cal'],
labels=['Main RF', 'Calibrator'],
sizer=hbox,
parent=panel,
@@ -271,18 +272,6 @@
hbox.AddSpacer(10)
vbox.Add(hbox, 0, wx.EXPAND)
- def update_db_ctrl(self, *args):
- db_ctrl = \
- ((0x1f ^ (self['db_ctrl_atten'] & 0x1f)) << 2) | \
- ((self['db_ctrl_bandsel'] & 0x3) << 7) | \
- ((self['db_ctrl_type'] & 0x1) << 9)
- if self['db_ctrl_10db']: #take band sel + 1 for alternative
- db_ctrl |= (self['db_ctrl_bandsel']+1) & 0x3
- else: #take current band sel
- db_ctrl |= (self['db_ctrl_bandsel']) & 0x3
- #print 'Setting db ctrl %.3x'%db_ctrl
- self.u.write_dboard_pins(db_ctrl)
-
def set_freq(self, target_freq):
"""
Set the center frequency we're interested in.
Modified: gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt.i
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt.i 2009-06-04
03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt.i 2009-06-04
17:05:32 UTC (rev 11174)
@@ -73,6 +73,16 @@
bool write_dboard_pins(int v);
+ bool set_center_freq(float target_freq);
+
+ bool set_band_select(const std::string &band);
+
+ void set_10dB_atten(bool on);
+
+ bool select_rx_antenna(const std::string &ant);
+
+ bool set_attenuation(int attenuation);
+
};
Modified:
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
2009-06-04 03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.cc
2009-06-04 17:05:32 UTC (rev 11174)
@@ -65,3 +65,33 @@
{
return d_qr->write_dboard_pins(v);
}
+
+bool
+vrt_quadradio_source_32fc::set_center_freq(float target_freq)
+{
+ return d_qr->set_center_freq(target_freq);
+}
+
+bool
+vrt_quadradio_source_32fc::set_band_select(const std::string &band)
+{
+ return d_qr->set_band_select(band);
+}
+
+void
+vrt_quadradio_source_32fc::set_10dB_atten(bool on)
+{
+ return d_qr->set_10dB_atten(on);
+}
+
+bool
+vrt_quadradio_source_32fc::select_rx_antenna(const std::string &ant)
+{
+ return d_qr->select_rx_antenna(ant);
+}
+
+bool
+vrt_quadradio_source_32fc::set_attenuation(int attenuation)
+{
+ return d_qr->set_attenuation(attenuation);
+}
Modified:
gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
2009-06-04 03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/gr-vrt/src/vrt_quadradio_source_32fc.h
2009-06-04 17:05:32 UTC (rev 11174)
@@ -62,6 +62,34 @@
*/
bool write_dboard_pins(int v);
+ /*!
+ * \brief Set the LO frequency (actually just sets the band select for now).
+ */
+ bool set_center_freq(float target_freq);
+
+ /*!
+ * \brief Set the band select dboard bits.
+ * \param band "A", "B", "C", "D"
+ */
+ bool set_band_select(const std::string &band);
+
+ /*!
+ * \brief Turn the 10 dB attenuation on/off.
+ */
+ void set_10dB_atten(bool on);
+
+ /*!
+ * \brief Set the antenna type to the main rf or calibrator.
+ * \param ant "rf" or "cal"
+ */
+ bool select_rx_antenna(const std::string &ant);
+
+ /*!
+ * \brief Set the attenuation.
+ * \param attenuation 0 to 31 in dB
+ */
+ bool set_attenuation(int attenuation);
+
};
Modified: gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
2009-06-04 03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/vrt/include/vrt/quadradio.h
2009-06-04 17:05:32 UTC (rev 11174)
@@ -42,6 +42,11 @@
int d_data_fd; // socket for data (owned by
d_rx)
int d_data_port; // our data port number
vrt::rx::sptr d_rx; // has-a rx
+
+ int d_band_select; // band select setting
+ int d_rx_antenna; // antenna type rf/cal
+ int d_attenuation; // attenuation setting
+ bool d_10dB_atten; // 10dB attenuation on/of
static bool
open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port,
@@ -59,6 +64,8 @@
int data_socket_fd() const { return d_data_fd; }
bool open(const char *ip);
+
+ void update_dboard_pins(void);
public:
typedef boost::shared_ptr<quadradio> sptr;
@@ -72,6 +79,14 @@
bool stop_streaming();
bool write_dboard_pins(int v);
+
+ /* convenience methods that ultimately write the dboard pins */
+ bool set_center_freq(float target_freq);
+ bool set_band_select(const std::string &band);
+ void set_10dB_atten(bool on);
+ bool select_rx_antenna(const std::string &ant);
+ bool set_attenuation(int attenuation);
+
};
};
Modified: gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc
===================================================================
--- gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc 2009-06-04
03:22:21 UTC (rev 11173)
+++ gnuradio/branches/developers/eb/vrt/vrt/lib/quadradio.cc 2009-06-04
17:05:32 UTC (rev 11174)
@@ -32,7 +32,8 @@
vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize)
- : d_ctrl_fd(0), d_data_fd(0), d_data_port(0)
+ : d_ctrl_fd(0), d_data_fd(0), d_data_port(0),
+ d_band_select(0), d_rx_antenna(0), d_attenuation(0), d_10dB_atten(true)
{
if (!open(ip.c_str()))
throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n");
@@ -67,6 +68,66 @@
}
bool
+vrt::quadradio::set_center_freq(float target_freq){
+ if (target_freq < 700e6) return false;
+ if (target_freq <= 1.0e9) return set_band_select("A");
+ if (target_freq <= 1.5e9) return set_band_select("B");
+ if (target_freq <= 2.2e9) return set_band_select("C");
+ if (target_freq <= 3.0e9) return set_band_select("D");
+ return false;
+}
+
+bool
+vrt::quadradio::set_band_select(const std::string &band){
+ if (band == "A") d_band_select = 3;
+ else if (band == "B") d_band_select = 1;
+ else if (band == "C") d_band_select = 2;
+ else if (band == "D") d_band_select = 0;
+ else return false;
+ update_dboard_pins();
+ return true;
+}
+
+void
+vrt::quadradio::set_10dB_atten(bool on){
+ d_10dB_atten = on;
+ update_dboard_pins();
+}
+
+bool
+vrt::quadradio::select_rx_antenna(const std::string &ant){
+ if (ant == "rf") d_rx_antenna = 0;
+ else if (ant == "cal") d_rx_antenna = 1;
+ else return true;
+ update_dboard_pins();
+ return true;
+}
+
+bool
+vrt::quadradio::set_attenuation(int attenuation){
+ if (attenuation < 0 || attenuation > 31) return false;
+ d_attenuation = attenuation;
+ update_dboard_pins();
+ return true;
+}
+
+void
+vrt::quadradio::update_dboard_pins(void){
+ int db_ctrl = \
+ ((~d_attenuation & 0x1f) << 2) | \
+ ((d_band_select & 0x3) << 7) | \
+ ((d_rx_antenna & 0x1) << 9);
+ if (d_10dB_atten){ //take band + 1 for alternative band
+ db_ctrl |= (d_band_select+1) & 0x3;
+ }else{ //take current band for 10dB attenuation
+ db_ctrl |= (d_band_select) & 0x3;
+ }
+ /*printf("Setting dboard pins:\nband_sel %d, rx_ant %d, 10dB(on/off) %d,
atten %d, bits %x\n",
+ d_band_select, d_rx_antenna, d_10dB_atten, d_attenuation, db_ctrl);*/
+ write_dboard_pins(db_ctrl);
+}
+
+bool
vrt::quadradio::write_dboard_pins(int v)
{
uint32_t cmd[3];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11174 - in gnuradio/branches/developers/eb/vrt: gr-utils/src/python gr-vrt/src vrt/include/vrt vrt/lib,
jblum <=