Merge pull request 'Avoid namespace conflicts' (#4) from argilo/gr-osmosdr:freesrp-namespaces into master
Reviewed-on: #4
This commit is contained in:
commit
674863d9cb
|
@ -6,13 +6,11 @@
|
|||
|
||||
#include <arg_helpers.h>
|
||||
|
||||
using namespace FreeSRP;
|
||||
using namespace std;
|
||||
using namespace boost::assign;
|
||||
|
||||
std::shared_ptr<::FreeSRP::FreeSRP> freesrp_common::_srp;
|
||||
|
||||
freesrp_common::freesrp_common(const string &args)
|
||||
freesrp_common::freesrp_common(const std::string &args)
|
||||
{
|
||||
dict_t dict = params_to_dict(args);
|
||||
|
||||
|
@ -20,7 +18,7 @@ freesrp_common::freesrp_common(const string &args)
|
|||
{
|
||||
try
|
||||
{
|
||||
string serial = "";
|
||||
std::string serial = "";
|
||||
|
||||
if(dict.count("freesrp"))
|
||||
{
|
||||
|
@ -29,22 +27,22 @@ freesrp_common::freesrp_common(const string &args)
|
|||
|
||||
if(dict.count("fx3"))
|
||||
{
|
||||
if(Util::find_fx3())
|
||||
if(FreeSRP::Util::find_fx3())
|
||||
{
|
||||
// Upload firmware to FX3
|
||||
string firmware_path = string(getenv("HOME")) + "/.freesrp/fx3.img";
|
||||
std::string firmware_path = std::string(getenv("HOME")) + "/.freesrp/fx3.img";
|
||||
if(dict["fx3"].length() > 0)
|
||||
{
|
||||
firmware_path = dict["fx3"];
|
||||
}
|
||||
Util::find_fx3(true, firmware_path);
|
||||
cout << "FX3 programmed with '" << firmware_path << "'" << endl;
|
||||
FreeSRP::Util::find_fx3(true, firmware_path);
|
||||
std::cout << "FX3 programmed with '" << firmware_path << "'" << std::endl;
|
||||
// Give FX3 time to re-enumerate
|
||||
this_thread::sleep_for(chrono::milliseconds(600));
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(600));
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "No FX3 in bootloader mode found" << endl;
|
||||
std::cout << "No FX3 in bootloader mode found" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,45 +50,45 @@ freesrp_common::freesrp_common(const string &args)
|
|||
|
||||
if(dict.count("fpga") || !_srp->fpga_loaded())
|
||||
{
|
||||
string bitstream_path = string(getenv("HOME")) + "/.freesrp/fpga.bin";
|
||||
std::string bitstream_path = std::string(getenv("HOME")) + "/.freesrp/fpga.bin";
|
||||
if(dict["fpga"].length() > 0)
|
||||
{
|
||||
bitstream_path = dict["fpga"];
|
||||
}
|
||||
fpga_status stat = _srp->load_fpga(bitstream_path);
|
||||
FreeSRP::fpga_status stat = _srp->load_fpga(bitstream_path);
|
||||
switch(stat)
|
||||
{
|
||||
case FPGA_CONFIG_ERROR:
|
||||
throw runtime_error("Could not load FPGA configuration!");
|
||||
case FPGA_CONFIG_SKIPPED:
|
||||
cout << "FPGA already configured. Restart the FreeSRP to load a new bitstream." << endl;
|
||||
case FreeSRP::FPGA_CONFIG_ERROR:
|
||||
throw std::runtime_error("Could not load FPGA configuration!");
|
||||
case FreeSRP::FPGA_CONFIG_SKIPPED:
|
||||
std::cout << "FPGA already configured. Restart the FreeSRP to load a new bitstream." << std::endl;
|
||||
break;
|
||||
case FPGA_CONFIG_DONE:
|
||||
cout << "FPGA configured with '" << bitstream_path << "'" << endl;
|
||||
case FreeSRP::FPGA_CONFIG_DONE:
|
||||
std::cout << "FPGA configured with '" << bitstream_path << "'" << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Connected to FreeSRP" << endl;
|
||||
std::cout << "Connected to FreeSRP" << std::endl;
|
||||
|
||||
if(dict.count("loopback"))
|
||||
{
|
||||
response res = _srp->send_cmd({SET_LOOPBACK_EN, 1});
|
||||
if(res.error == CMD_OK)
|
||||
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_LOOPBACK_EN, 1});
|
||||
if(res.error == FreeSRP::CMD_OK)
|
||||
{
|
||||
cout << "AD9364 in loopback mode" << endl;
|
||||
std::cout << "AD9364 in loopback mode" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw runtime_error("Could not put AD9364 into loopback mode!");
|
||||
throw std::runtime_error("Could not put AD9364 into loopback mode!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
response res = _srp->send_cmd({SET_LOOPBACK_EN, 0});
|
||||
if(res.error != CMD_OK)
|
||||
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_LOOPBACK_EN, 0});
|
||||
if(res.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
throw runtime_error("Error disabling AD9364 loopback mode!");
|
||||
throw std::runtime_error("Error disabling AD9364 loopback mode!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,28 +101,28 @@ freesrp_common::freesrp_common(const string &args)
|
|||
_ignore_overflow = false;
|
||||
}
|
||||
}
|
||||
catch(const runtime_error& e)
|
||||
catch(const std::runtime_error& e)
|
||||
{
|
||||
cerr << "FreeSRP Error: " << e.what() << endl;
|
||||
throw runtime_error(e.what());
|
||||
std::cerr << "FreeSRP Error: " << e.what() << std::endl;
|
||||
throw std::runtime_error(e.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> freesrp_common::get_devices()
|
||||
std::vector<std::string> freesrp_common::get_devices()
|
||||
{
|
||||
vector<string> devices;
|
||||
std::vector<std::string> devices;
|
||||
|
||||
vector<string> serial_numbers = ::FreeSRP::FreeSRP::list_connected();
|
||||
std::vector<std::string> serial_numbers = ::FreeSRP::FreeSRP::list_connected();
|
||||
|
||||
int index = 0;
|
||||
|
||||
for(string &serial : serial_numbers)
|
||||
for(std::string &serial : serial_numbers)
|
||||
{
|
||||
index++;
|
||||
|
||||
string str;
|
||||
str = "freesrp=" + serial + ",label='FreeSRP " + to_string(index) + "'";
|
||||
std::string str;
|
||||
str = "freesrp=" + serial + ",label='FreeSRP " + std::to_string(index) + "'";
|
||||
|
||||
devices.push_back(str);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "freesrp_sink_c.h"
|
||||
|
||||
using namespace FreeSRP;
|
||||
using namespace std;
|
||||
|
||||
freesrp_sink_c_sptr make_freesrp_sink_c (const string &args)
|
||||
freesrp_sink_c_sptr make_freesrp_sink_c (const std::string &args)
|
||||
{
|
||||
return gnuradio::get_initial_sptr(new freesrp_sink_c (args));
|
||||
}
|
||||
|
@ -22,21 +19,21 @@ static const int MAX_IN = 1; // maximum number of input streams
|
|||
static const int MIN_OUT = 0; // minimum number of output streams
|
||||
static const int MAX_OUT = 0; // maximum number of output streams
|
||||
|
||||
freesrp_sink_c::freesrp_sink_c (const string & args) : gr::sync_block("freesrp_sink_c",
|
||||
freesrp_sink_c::freesrp_sink_c (const std::string & args) : gr::sync_block("freesrp_sink_c",
|
||||
gr::io_signature::make (MIN_IN, MAX_IN, sizeof (gr_complex)),
|
||||
gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
|
||||
freesrp_common(args)
|
||||
{
|
||||
if(_srp == nullptr)
|
||||
{
|
||||
throw runtime_error("FreeSRP not initialized!");
|
||||
throw std::runtime_error("FreeSRP not initialized!");
|
||||
}
|
||||
}
|
||||
|
||||
bool freesrp_sink_c::start()
|
||||
{
|
||||
response res = _srp->send_cmd({SET_DATAPATH_EN, 1});
|
||||
if(res.error != CMD_OK)
|
||||
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 1});
|
||||
if(res.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -46,16 +43,16 @@ bool freesrp_sink_c::start()
|
|||
|
||||
bool freesrp_sink_c::stop()
|
||||
{
|
||||
_srp->send_cmd({SET_DATAPATH_EN, 0});
|
||||
_srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 0});
|
||||
_srp->stop_tx();
|
||||
return true;
|
||||
}
|
||||
|
||||
void freesrp_sink_c::freesrp_tx_callback(vector<sample>& samples)
|
||||
void freesrp_sink_c::freesrp_tx_callback(std::vector<FreeSRP::sample>& samples)
|
||||
{
|
||||
unique_lock<std::mutex> lk(_buf_mut);
|
||||
std::unique_lock<std::mutex> lk(_buf_mut);
|
||||
|
||||
for(sample &s : samples)
|
||||
for(FreeSRP::sample &s : samples)
|
||||
{
|
||||
if(!_buf_queue.try_dequeue(s))
|
||||
{
|
||||
|
@ -75,7 +72,7 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
|
|||
{
|
||||
const gr_complex *in = (const gr_complex *) input_items[0];
|
||||
|
||||
unique_lock<std::mutex> lk(_buf_mut);
|
||||
std::unique_lock<std::mutex> lk(_buf_mut);
|
||||
|
||||
// Wait until enough space is available
|
||||
while(_buf_available_space < (unsigned int) noutput_items)
|
||||
|
@ -85,13 +82,13 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
|
|||
|
||||
for(int i = 0; i < noutput_items; ++i)
|
||||
{
|
||||
sample s;
|
||||
FreeSRP::sample s;
|
||||
s.i = (int16_t) (real(in[i]) * 2047.0f);
|
||||
s.q = (int16_t) (imag(in[i]) * 2047.0f);
|
||||
|
||||
if(!_buf_queue.try_enqueue(s))
|
||||
{
|
||||
throw runtime_error("Failed to add sample to buffer. This should never happen. Available space reported to be " + to_string(_buf_available_space) + " samples, noutput_items=" + to_string(noutput_items) + ", i=" + to_string(i));
|
||||
throw std::runtime_error("Failed to add sample to buffer. This should never happen. Available space reported to be " + std::to_string(_buf_available_space) + " samples, noutput_items=" + std::to_string(noutput_items) + ", i=" + std::to_string(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -104,11 +101,11 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
|
|||
|
||||
double freesrp_sink_c::set_sample_rate( double rate )
|
||||
{
|
||||
command cmd = _srp->make_command(SET_TX_SAMP_FREQ, rate);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_SAMP_FREQ, rate);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set TX sample rate, error: " << r.error << endl;
|
||||
std::cerr << "Could not set TX sample rate, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -119,10 +116,10 @@ double freesrp_sink_c::set_sample_rate( double rate )
|
|||
|
||||
double freesrp_sink_c::get_sample_rate( void )
|
||||
{
|
||||
response r = _srp->send_cmd({GET_TX_SAMP_FREQ, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_SAMP_FREQ, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get TX sample rate, error: " << r.error << endl;
|
||||
std::cerr << "Could not get TX sample rate, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -133,11 +130,11 @@ double freesrp_sink_c::get_sample_rate( void )
|
|||
|
||||
double freesrp_sink_c::set_center_freq( double freq, size_t chan )
|
||||
{
|
||||
command cmd = _srp->make_command(SET_TX_LO_FREQ, freq);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_LO_FREQ, freq);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set TX LO frequency, error: " << r.error << endl;
|
||||
std::cerr << "Could not set TX LO frequency, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -148,10 +145,10 @@ double freesrp_sink_c::set_center_freq( double freq, size_t chan )
|
|||
|
||||
double freesrp_sink_c::get_center_freq( size_t chan )
|
||||
{
|
||||
response r = _srp->send_cmd({GET_TX_LO_FREQ, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_LO_FREQ, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get TX LO frequency, error: " << r.error << endl;
|
||||
std::cerr << "Could not get TX LO frequency, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -160,9 +157,9 @@ double freesrp_sink_c::get_center_freq( size_t chan )
|
|||
}
|
||||
}
|
||||
|
||||
vector<string> freesrp_sink_c::get_gain_names( size_t chan )
|
||||
std::vector<std::string> freesrp_sink_c::get_gain_names( size_t chan )
|
||||
{
|
||||
vector<string> names;
|
||||
std::vector<std::string> names;
|
||||
|
||||
names.push_back("TX_RF");
|
||||
|
||||
|
@ -178,7 +175,7 @@ osmosdr::gain_range_t freesrp_sink_c::get_gain_range(size_t chan)
|
|||
return gain_ranges;
|
||||
}
|
||||
|
||||
osmosdr::gain_range_t freesrp_sink_c::get_gain_range(const string& name, size_t chan)
|
||||
osmosdr::gain_range_t freesrp_sink_c::get_gain_range(const std::string& name, size_t chan)
|
||||
{
|
||||
return get_gain_range(chan);
|
||||
}
|
||||
|
@ -189,11 +186,11 @@ double freesrp_sink_c::set_gain(double gain, size_t chan)
|
|||
|
||||
double atten = 89.75 - gain;
|
||||
|
||||
command cmd = _srp->make_command(SET_TX_ATTENUATION, atten * 1000);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_ATTENUATION, atten * 1000);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set TX attenuation, error: " << r.error << endl;
|
||||
std::cerr << "Could not set TX attenuation, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -202,17 +199,17 @@ double freesrp_sink_c::set_gain(double gain, size_t chan)
|
|||
}
|
||||
}
|
||||
|
||||
double freesrp_sink_c::set_gain(double gain, const string& name, size_t chan)
|
||||
double freesrp_sink_c::set_gain(double gain, const std::string& name, size_t chan)
|
||||
{
|
||||
return set_gain(gain, chan);
|
||||
}
|
||||
|
||||
double freesrp_sink_c::get_gain(size_t chan)
|
||||
{
|
||||
response r = _srp->send_cmd({GET_TX_ATTENUATION, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_ATTENUATION, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get TX RF attenuation, error: " << r.error << endl;
|
||||
std::cerr << "Could not get TX RF attenuation, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -221,7 +218,7 @@ double freesrp_sink_c::get_gain(size_t chan)
|
|||
}
|
||||
}
|
||||
|
||||
double freesrp_sink_c::get_gain(const string& name, size_t chan)
|
||||
double freesrp_sink_c::get_gain(const std::string& name, size_t chan)
|
||||
{
|
||||
return get_gain(chan);
|
||||
}
|
||||
|
@ -231,32 +228,32 @@ double freesrp_sink_c::set_bb_gain(double gain, size_t chan)
|
|||
return set_gain(gain, chan);
|
||||
}
|
||||
|
||||
vector<string> freesrp_sink_c::get_antennas(size_t chan)
|
||||
std::vector<std::string> freesrp_sink_c::get_antennas(size_t chan)
|
||||
{
|
||||
vector<string> antennas;
|
||||
std::vector<std::string> antennas;
|
||||
|
||||
antennas.push_back(get_antenna(chan));
|
||||
|
||||
return antennas;
|
||||
}
|
||||
|
||||
string freesrp_sink_c::set_antenna(const string& antenna, size_t chan)
|
||||
std::string freesrp_sink_c::set_antenna(const std::string& antenna, size_t chan)
|
||||
{
|
||||
return get_antenna(chan);
|
||||
}
|
||||
|
||||
string freesrp_sink_c::get_antenna(size_t chan)
|
||||
std::string freesrp_sink_c::get_antenna(size_t chan)
|
||||
{
|
||||
return "TX";
|
||||
}
|
||||
|
||||
double freesrp_sink_c::set_bandwidth(double bandwidth, size_t chan)
|
||||
{
|
||||
command cmd = _srp->make_command(SET_TX_RF_BANDWIDTH, bandwidth);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_RF_BANDWIDTH, bandwidth);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set TX RF bandwidth, error: " << r.error << endl;
|
||||
std::cerr << "Could not set TX RF bandwidth, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -267,10 +264,10 @@ double freesrp_sink_c::set_bandwidth(double bandwidth, size_t chan)
|
|||
|
||||
double freesrp_sink_c::get_bandwidth(size_t chan)
|
||||
{
|
||||
response r = _srp->send_cmd({GET_TX_RF_BANDWIDTH, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_RF_BANDWIDTH, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get TX RF bandwidth, error: " << r.error << endl;
|
||||
std::cerr << "Could not get TX RF bandwidth, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "freesrp_source_c.h"
|
||||
|
||||
using namespace FreeSRP;
|
||||
using namespace std;
|
||||
|
||||
freesrp_source_c_sptr make_freesrp_source_c (const string &args)
|
||||
freesrp_source_c_sptr make_freesrp_source_c (const std::string &args)
|
||||
{
|
||||
return gnuradio::get_initial_sptr(new freesrp_source_c (args));
|
||||
}
|
||||
|
@ -22,21 +19,21 @@ static const int MAX_IN = 0; // maximum number of input streams
|
|||
static const int MIN_OUT = 1; // minimum number of output streams
|
||||
static const int MAX_OUT = 1; // maximum number of output streams
|
||||
|
||||
freesrp_source_c::freesrp_source_c (const string & args) : gr::sync_block ("freesrp_source_c",
|
||||
freesrp_source_c::freesrp_source_c (const std::string & args) : gr::sync_block ("freesrp_source_c",
|
||||
gr::io_signature::make (MIN_IN, MAX_IN, sizeof (gr_complex)),
|
||||
gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
|
||||
freesrp_common(args)
|
||||
{
|
||||
if(_srp == nullptr)
|
||||
{
|
||||
throw runtime_error("FreeSRP not initialized!");
|
||||
throw std::runtime_error("FreeSRP not initialized!");
|
||||
}
|
||||
}
|
||||
|
||||
bool freesrp_source_c::start()
|
||||
{
|
||||
response res = _srp->send_cmd({SET_DATAPATH_EN, 1});
|
||||
if(res.error != CMD_OK)
|
||||
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 1});
|
||||
if(res.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -49,7 +46,7 @@ bool freesrp_source_c::start()
|
|||
|
||||
bool freesrp_source_c::stop()
|
||||
{
|
||||
_srp->send_cmd({SET_DATAPATH_EN, 0});
|
||||
_srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 0});
|
||||
_srp->stop_rx();
|
||||
|
||||
_running = false;
|
||||
|
@ -57,17 +54,17 @@ bool freesrp_source_c::stop()
|
|||
return true;
|
||||
}
|
||||
|
||||
void freesrp_source_c::freesrp_rx_callback(const vector<sample> &samples)
|
||||
void freesrp_source_c::freesrp_rx_callback(const std::vector<FreeSRP::sample> &samples)
|
||||
{
|
||||
unique_lock<std::mutex> lk(_buf_mut);
|
||||
std::unique_lock<std::mutex> lk(_buf_mut);
|
||||
|
||||
for(const sample &s : samples)
|
||||
for(const FreeSRP::sample &s : samples)
|
||||
{
|
||||
if(!_buf_queue.try_enqueue(s))
|
||||
{
|
||||
if(!_ignore_overflow)
|
||||
{
|
||||
throw runtime_error("RX buffer overflow");
|
||||
throw std::runtime_error("RX buffer overflow");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -83,7 +80,7 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
|
|||
{
|
||||
gr_complex *out = static_cast<gr_complex *>(output_items[0]);
|
||||
|
||||
unique_lock<std::mutex> lk(_buf_mut);
|
||||
std::unique_lock<std::mutex> lk(_buf_mut);
|
||||
|
||||
if(!_running)
|
||||
{
|
||||
|
@ -98,11 +95,11 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
|
|||
|
||||
for(int i = 0; i < noutput_items; ++i)
|
||||
{
|
||||
sample s;
|
||||
FreeSRP::sample s;
|
||||
if(!_buf_queue.try_dequeue(s))
|
||||
{
|
||||
// This should not be happening
|
||||
throw runtime_error("Failed to get sample from buffer. This should never happen. Number of available samples reported to be " + to_string(_buf_num_samples) + ", noutput_items=" + to_string(noutput_items) + ", i=" + to_string(i));
|
||||
throw std::runtime_error("Failed to get sample from buffer. This should never happen. Number of available samples reported to be " + std::to_string(_buf_num_samples) + ", noutput_items=" + std::to_string(noutput_items) + ", i=" + std::to_string(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,11 +114,11 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
|
|||
|
||||
double freesrp_source_c::set_sample_rate( double rate )
|
||||
{
|
||||
command cmd = _srp->make_command(SET_RX_SAMP_FREQ, rate);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_SAMP_FREQ, rate);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set RX sample rate, error: " << r.error << endl;
|
||||
std::cerr << "Could not set RX sample rate, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -132,10 +129,10 @@ double freesrp_source_c::set_sample_rate( double rate )
|
|||
|
||||
double freesrp_source_c::get_sample_rate( void )
|
||||
{
|
||||
response r = _srp->send_cmd({GET_RX_SAMP_FREQ, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_SAMP_FREQ, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get RX sample rate, error: " << r.error << endl;
|
||||
std::cerr << "Could not get RX sample rate, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -146,11 +143,11 @@ double freesrp_source_c::get_sample_rate( void )
|
|||
|
||||
double freesrp_source_c::set_center_freq( double freq, size_t chan )
|
||||
{
|
||||
command cmd = _srp->make_command(SET_RX_LO_FREQ, freq);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_LO_FREQ, freq);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set RX LO frequency, error: " << r.error << endl;
|
||||
std::cerr << "Could not set RX LO frequency, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -161,10 +158,10 @@ double freesrp_source_c::set_center_freq( double freq, size_t chan )
|
|||
|
||||
double freesrp_source_c::get_center_freq( size_t chan )
|
||||
{
|
||||
response r = _srp->send_cmd({GET_RX_LO_FREQ, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_LO_FREQ, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get RX LO frequency, error: " << r.error << endl;
|
||||
std::cerr << "Could not get RX LO frequency, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -173,9 +170,9 @@ double freesrp_source_c::get_center_freq( size_t chan )
|
|||
}
|
||||
}
|
||||
|
||||
vector<string> freesrp_source_c::get_gain_names( size_t chan )
|
||||
std::vector<std::string> freesrp_source_c::get_gain_names( size_t chan )
|
||||
{
|
||||
vector<string> names;
|
||||
std::vector<std::string> names;
|
||||
|
||||
names.push_back("RF");
|
||||
|
||||
|
@ -193,41 +190,41 @@ osmosdr::gain_range_t freesrp_source_c::get_gain_range(size_t chan)
|
|||
|
||||
bool freesrp_source_c::set_gain_mode( bool automatic, size_t chan )
|
||||
{
|
||||
uint8_t gc_mode = RF_GAIN_SLOWATTACK_AGC;
|
||||
uint8_t gc_mode = FreeSRP::RF_GAIN_SLOWATTACK_AGC;
|
||||
|
||||
if(!automatic)
|
||||
{
|
||||
gc_mode = RF_GAIN_MGC;
|
||||
gc_mode = FreeSRP::RF_GAIN_MGC;
|
||||
}
|
||||
|
||||
command cmd = _srp->make_command(SET_RX_GC_MODE, gc_mode);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_GC_MODE, gc_mode);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set RX RF gain control mode, error: " << r.error << endl;
|
||||
std::cerr << "Could not set RX RF gain control mode, error: " << r.error << std::endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r.param != RF_GAIN_MGC;
|
||||
return r.param != FreeSRP::RF_GAIN_MGC;
|
||||
}
|
||||
}
|
||||
|
||||
bool freesrp_source_c::get_gain_mode( size_t chan )
|
||||
{
|
||||
response r = _srp->send_cmd({GET_RX_GC_MODE, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_GC_MODE, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get RX RF gain control mode, error: " << r.error << endl;
|
||||
std::cerr << "Could not get RX RF gain control mode, error: " << r.error << std::endl;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return r.param != RF_GAIN_MGC;
|
||||
return r.param != FreeSRP::RF_GAIN_MGC;
|
||||
}
|
||||
}
|
||||
|
||||
osmosdr::gain_range_t freesrp_source_c::get_gain_range(const string& name, size_t chan)
|
||||
osmosdr::gain_range_t freesrp_source_c::get_gain_range(const std::string& name, size_t chan)
|
||||
{
|
||||
return get_gain_range(chan);
|
||||
}
|
||||
|
@ -236,11 +233,11 @@ double freesrp_source_c::set_gain(double gain, size_t chan)
|
|||
{
|
||||
gain = get_gain_range().clip(gain);
|
||||
|
||||
command cmd = _srp->make_command(SET_RX_RF_GAIN, gain);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_RF_GAIN, gain);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set RX RF gain, error: " << r.error << endl;
|
||||
std::cerr << "Could not set RX RF gain, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -249,7 +246,7 @@ double freesrp_source_c::set_gain(double gain, size_t chan)
|
|||
}
|
||||
}
|
||||
|
||||
double freesrp_source_c::set_gain(double gain, const string& name, size_t chan)
|
||||
double freesrp_source_c::set_gain(double gain, const std::string& name, size_t chan)
|
||||
{
|
||||
if(name == "RF")
|
||||
{
|
||||
|
@ -263,10 +260,10 @@ double freesrp_source_c::set_gain(double gain, const string& name, size_t chan)
|
|||
|
||||
double freesrp_source_c::get_gain(size_t chan)
|
||||
{
|
||||
response r = _srp->send_cmd({GET_RX_RF_GAIN, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_RF_GAIN, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get RX RF gain, error: " << r.error << endl;
|
||||
std::cerr << "Could not get RX RF gain, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -275,7 +272,7 @@ double freesrp_source_c::get_gain(size_t chan)
|
|||
}
|
||||
}
|
||||
|
||||
double freesrp_source_c::get_gain(const string& name, size_t chan)
|
||||
double freesrp_source_c::get_gain(const std::string& name, size_t chan)
|
||||
{
|
||||
if(name == "RF")
|
||||
{
|
||||
|
@ -292,32 +289,32 @@ double freesrp_source_c::set_bb_gain(double gain, size_t chan)
|
|||
return set_gain(gain, chan);
|
||||
}
|
||||
|
||||
vector<string> freesrp_source_c::get_antennas(size_t chan)
|
||||
std::vector<std::string> freesrp_source_c::get_antennas(size_t chan)
|
||||
{
|
||||
vector<string> antennas;
|
||||
std::vector<std::string> antennas;
|
||||
|
||||
antennas.push_back(get_antenna(chan));
|
||||
|
||||
return antennas;
|
||||
}
|
||||
|
||||
string freesrp_source_c::set_antenna(const string& antenna, size_t chan)
|
||||
std::string freesrp_source_c::set_antenna(const std::string& antenna, size_t chan)
|
||||
{
|
||||
return get_antenna(chan);
|
||||
}
|
||||
|
||||
string freesrp_source_c::get_antenna(size_t chan)
|
||||
std::string freesrp_source_c::get_antenna(size_t chan)
|
||||
{
|
||||
return "RX";
|
||||
}
|
||||
|
||||
double freesrp_source_c::set_bandwidth(double bandwidth, size_t chan)
|
||||
{
|
||||
command cmd = _srp->make_command(SET_RX_RF_BANDWIDTH, bandwidth);
|
||||
response r = _srp->send_cmd(cmd);
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_RF_BANDWIDTH, bandwidth);
|
||||
FreeSRP::response r = _srp->send_cmd(cmd);
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not set RX RF bandwidth, error: " << r.error << endl;
|
||||
std::cerr << "Could not set RX RF bandwidth, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
@ -328,10 +325,10 @@ double freesrp_source_c::set_bandwidth(double bandwidth, size_t chan)
|
|||
|
||||
double freesrp_source_c::get_bandwidth(size_t chan)
|
||||
{
|
||||
response r = _srp->send_cmd({GET_RX_RF_BANDWIDTH, 0});
|
||||
if(r.error != CMD_OK)
|
||||
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_RF_BANDWIDTH, 0});
|
||||
if(r.error != FreeSRP::CMD_OK)
|
||||
{
|
||||
cerr << "Could not get RX RF bandwidth, error: " << r.error << endl;
|
||||
std::cerr << "Could not get RX RF bandwidth, error: " << r.error << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue