LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0003-add-antenna-AUTO-selection.patch of Package gr-osmosdr (Project home:dl8fcl:sdr)

From ec709647c81659b7ac6b6df9ce3de356b72bd7c2 Mon Sep 17 00:00:00 2001
From: Sergey Kostanbaev <sergey.kostanbaev@gmail.com>
Date: Sat, 21 Apr 2018 15:13:03 +0300
Subject: [PATCH 3/5] add antenna AUTO selection

---
 lib/xtrx/xtrx_obj.cc      |  8 +++++---
 lib/xtrx/xtrx_source_c.cc | 10 +++++++++-
 lib/xtrx/xtrx_source_c.h  |  1 +
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/xtrx/xtrx_obj.cc b/lib/xtrx/xtrx_obj.cc
index 369f9ec..ce4e6f3 100644
--- a/lib/xtrx/xtrx_obj.cc
+++ b/lib/xtrx/xtrx_obj.cc
@@ -87,7 +87,7 @@ double xtrx_obj::set_smaplerate(double rate, double master, bool sink, unsigned
     _source_rate = rate;
     _source_master = master;
   }
-  _flags |= flags;
+  _flags |= flags | XTRX_SAMPLERATE_FORCE_UPDATE;
 
   if (_sink_master != 0 && _source_master != 0 && _sink_master != _source_master) {
     std::stringstream message;
@@ -97,7 +97,7 @@ double xtrx_obj::set_smaplerate(double rate, double master, bool sink, unsigned
     throw std::runtime_error( message.str() );
   }
 
-  double rxrate, txrate;
+  double rxrate = 0, txrate = 0;
   double actmaster = (_source_master > 0) ? _source_master : _sink_master;
   int res = xtrx_set_samplerate(_obj,
                                 actmaster,
@@ -109,7 +109,9 @@ double xtrx_obj::set_smaplerate(double rate, double master, bool sink, unsigned
                                 &txrate);
   if (res) {
     std::cerr << "Unable to set samplerate, error=" << res << std::endl;
-    return 0;
+  if (sink)
+    return _sink_rate;
+  return _source_rate;
   }
 
   if (sink)
diff --git a/lib/xtrx/xtrx_source_c.cc b/lib/xtrx/xtrx_source_c.cc
index 47bb39e..b4d9e35 100644
--- a/lib/xtrx/xtrx_source_c.cc
+++ b/lib/xtrx/xtrx_source_c.cc
@@ -388,8 +388,14 @@ double xtrx_source_c::get_bandwidth( size_t chan )
   return _bandwidth;
 }
 
+osmosdr::freq_range_t xtrx_source_c::get_bandwidth_range( size_t chan )
+{
+  return osmosdr::freq_range_t(500e3, 140e6, 0);
+}
+
 
 static const std::map<std::string, xtrx_antenna_t> s_ant_map = boost::assign::map_list_of
+    ("AUTO", XTRX_RX_AUTO)
     ("RXL", XTRX_RX_L)
     ("RXH", XTRX_RX_H)
     ("RXW", XTRX_RX_W)
@@ -397,6 +403,7 @@ static const std::map<std::string, xtrx_antenna_t> s_ant_map = boost::assign::ma
     ("RXW_LB", XTRX_RX_W_LB)
     ;
 static const std::map<xtrx_antenna_t, std::string> s_ant_map_r = boost::assign::map_list_of
+    (XTRX_RX_AUTO, "AUTO")
     (XTRX_RX_L, "RXL")
     (XTRX_RX_H, "RXH")
     (XTRX_RX_W, "RXW")
@@ -417,7 +424,7 @@ static xtrx_antenna_t get_ant_type(const std::string& name)
 }
 
 static const std::vector<std::string> s_ant_list = boost::assign::list_of
-    ("RXL")("RXH")("RXW")
+    ("AUTO")("RXL")("RXH")("RXW")
     ;
 
 
@@ -454,6 +461,7 @@ int xtrx_source_c::work (int noutput_items,
   ri.buffer_count = output_items.size();
   ri.buffers = &output_items[0];
   ri.flags = RCVEX_DONT_INSER_ZEROS | RCVEX_DROP_OLD_ON_OVERFLOW;
+  ri.timeout = 1000;
 
   int res = xtrx_recv_sync_ex(_xtrx->dev(), &ri);
   if (res) {
diff --git a/lib/xtrx/xtrx_source_c.h b/lib/xtrx/xtrx_source_c.h
index c05c7fb..0f2d2d0 100644
--- a/lib/xtrx/xtrx_source_c.h
+++ b/lib/xtrx/xtrx_source_c.h
@@ -78,6 +78,7 @@ public:
 
   double set_bandwidth( double bandwidth, size_t chan = 0 );
   double get_bandwidth( size_t chan = 0 );
+  osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0);
 
   int work (int noutput_items,
             gr_vector_const_void_star &input_items,
-- 
2.16.4