aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-02-19 14:16:24 -0800
committerMartin Braun <martin.braun@ettus.com>2018-02-19 17:01:40 -0800
commit305d0e79e219b427c6425dab0715ed2132d928b8 (patch)
tree9962f0fd34c1d0488255785cf99243708dec4fb6 /host/examples
parent21b5f2c6aa88af5488b140da0ef7ed34cc14153f (diff)
downloaduhd-305d0e79e219b427c6425dab0715ed2132d928b8.tar.gz
uhd-305d0e79e219b427c6425dab0715ed2132d928b8.tar.bz2
uhd-305d0e79e219b427c6425dab0715ed2132d928b8.zip
examples: Fix some minor compiler warnings
All warnings reported by MSVC. Mostly related to narrowing conversions.
Diffstat (limited to 'host/examples')
-rw-r--r--host/examples/benchmark_rate.cpp11
-rw-r--r--host/examples/rx_samples_to_file.cpp10
-rw-r--r--host/examples/test_messages.cpp2
-rw-r--r--host/examples/tx_samples_c.c2
-rw-r--r--host/examples/tx_samples_from_file.cpp14
-rw-r--r--host/examples/tx_waveforms.cpp9
-rw-r--r--host/examples/wavetable.hpp7
7 files changed, 38 insertions, 17 deletions
diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp
index 0c16e5ecf..3b5816847 100644
--- a/host/examples/benchmark_rate.cpp
+++ b/host/examples/benchmark_rate.cpp
@@ -20,8 +20,8 @@
namespace po = boost::program_options;
-const double CLOCK_TIMEOUT = 1000; // 1000mS timeout for external clock locking
-const double INIT_DELAY = 0.05; // 50mS initial delay before transmit
+const int64_t CLOCK_TIMEOUT = 1000; // 1000mS timeout for external clock locking
+const float INIT_DELAY = 0.05; // 50mS initial delay before transmit
//typedef boost::atomic<bool> atomic_bool;
// We'll fake atomic bools for now, for more backward compat.
// This is just an example, after all.
@@ -72,7 +72,8 @@ void benchmark_rx_rate(
cmd.stream_now = (buffs.size() == 1);
rx_stream->issue_stream_cmd(cmd);
- const float burst_pkt_time = std::max(0.100, (2 * max_samps_per_packet/rate));
+ const float burst_pkt_time =
+ std::max<float>(0.100f, (2 * max_samps_per_packet/rate));
float recv_timeout = burst_pkt_time + INIT_DELAY;
bool stop_called = false;
@@ -353,7 +354,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
if(ref != "internal") {
std::cout << "Now confirming lock on clock signals..." << std::endl;
bool is_locked = false;
- boost::system_time end_time = boost::get_system_time() + boost::posix_time::milliseconds(CLOCK_TIMEOUT);
+ boost::system_time end_time =
+ boost::get_system_time() +
+ boost::posix_time::milliseconds(CLOCK_TIMEOUT);
for (int i = 0; i < num_mboards; i++) {
if (ref == "mimo" and i == 0) continue;
while((is_locked = usrp->get_mboard_sensor("ref_locked",i).to_bool()) == false and
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp
index b4ca8cfee..59de6c26b 100644
--- a/host/examples/rx_samples_to_file.cpp
+++ b/host/examples/rx_samples_to_file.cpp
@@ -17,6 +17,8 @@
#include <fstream>
#include <csignal>
#include <complex>
+#include <thread>
+#include <chrono>
namespace po = boost::program_options;
@@ -184,7 +186,7 @@ bool check_locked_sensor(std::vector<std::string> sensor_names, const char* sens
std::cout.flush();
}
else {
- first_lock_time = boost::system_time(); //reset to 'not a date time'
+ first_lock_time = boost::system_time(); //reset to 'not a date time'
if (boost::get_system_time() > (start + boost::posix_time::seconds(setup_time))){
std::cout << std::endl;
@@ -193,7 +195,7 @@ bool check_locked_sensor(std::vector<std::string> sensor_names, const char* sens
std::cout << "_";
std::cout.flush();
}
- boost::this_thread::sleep(boost::posix_time::milliseconds(100));
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
std::cout << std::endl;
return true;
@@ -307,7 +309,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//set the antenna
if (vm.count("ant")) usrp->set_rx_antenna(ant);
- boost::this_thread::sleep(boost::posix_time::seconds(setup_time)); //allow for some setup time
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(int64_t(1000 * setup_time))
+ );
//check Ref and LO Lock detect
if (not vm.count("skip-lo")){
diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp
index 5276dfd46..0f7c289d2 100644
--- a/host/examples/test_messages.cpp
+++ b/host/examples/test_messages.cpp
@@ -345,7 +345,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << boost::format(
"%s -> %3u successes, %3u failures"
) % key % successes[key] % failures[key] << std::endl;
- any_failure = any_failure or bool(failures[key]);
+ any_failure = any_failure or (failures[key] > 0);
}
//finished
diff --git a/host/examples/tx_samples_c.c b/host/examples/tx_samples_c.c
index aabf17805..eab061edb 100644
--- a/host/examples/tx_samples_c.c
+++ b/host/examples/tx_samples_c.c
@@ -115,7 +115,7 @@ int main(int argc, char* argv[]){
// Create TX metadata
uhd_tx_metadata_handle md;
EXECUTE_OR_GOTO(free_tx_streamer,
- uhd_tx_metadata_make(&md, false, 0.0, 0.1, true, false)
+ uhd_tx_metadata_make(&md, false, 0, 0.1, true, false)
)
// Create other necessary structs
diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp
index ba2ad6cb8..31d70ad7e 100644
--- a/host/examples/tx_samples_from_file.cpp
+++ b/host/examples/tx_samples_from_file.cpp
@@ -16,6 +16,8 @@
#include <fstream>
#include <complex>
#include <csignal>
+#include <chrono>
+#include <thread>
namespace po = boost::program_options;
@@ -74,7 +76,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("bw", po::value<double>(&bw), "analog frontend filter bandwidth in Hz")
("ref", po::value<std::string>(&ref)->default_value("internal"), "reference source (internal, external, mimo)")
("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8 or sc16)")
- ("delay", po::value<double>(&delay)->default_value(0.0), "specify a delay between repeated transmission of file")
+ ("delay", po::value<double>(&delay)->default_value(0.0), "specify a delay between repeated transmission of file (in seconds)")
("channel", po::value<std::string>(&channel)->default_value("0"), "which channel to use")
("repeat", "repeatedly transmit file")
("int-n", "tune USRP with integer-n tuning")
@@ -147,7 +149,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//set the antenna
if (vm.count("ant")) usrp->set_tx_antenna(ant);
- boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time
+ //allow for some setup time:
+ std::this_thread::sleep_for(std::chrono::seconds(1));
//Check Ref and LO Lock detect
std::vector<std::string> sensor_names;
@@ -193,7 +196,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
else if (type == "short") send_from_file<std::complex<short> >(tx_stream, file, spb);
else throw std::runtime_error("Unknown type " + type);
- if(repeat and delay != 0.0) boost::this_thread::sleep(boost::posix_time::milliseconds(delay));
+ if(repeat and delay > 0.0) {
+ boost::this_thread::sleep(boost::posix_time::milliseconds(delay));
+ std::this_thread::sleep_for(
+ std::chrono::milliseconds(int64_t(delay*1000))
+ );
+ }
} while(repeat and not stop_signal_called);
//finished
diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp
index 385110d7c..04cd8f3b4 100644
--- a/host/examples/tx_waveforms.cpp
+++ b/host/examples/tx_waveforms.cpp
@@ -37,7 +37,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
std::string args, wave_type, ant, subdev, ref, pps, otw, channel_list;
- uint64_t total_num_samps, spb;
+ uint64_t total_num_samps;
+ size_t spb;
double rate, freq, gain, wave_freq, bw;
float ampl;
@@ -46,7 +47,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
desc.add_options()
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "single uhd device address args")
- ("spb", po::value<uint64_t>(&spb)->default_value(0), "samples per buffer, 0 for default")
+ ("spb", po::value<size_t>(&spb)->default_value(0), "samples per buffer, 0 for default")
("nsamps", po::value<uint64_t>(&total_num_samps)->default_value(0), "total number of samples to transmit")
("rate", po::value<double>(&rate), "rate of outgoing samples")
("freq", po::value<double>(&freq), "RF center frequency in Hz")
@@ -166,7 +167,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::tx_streamer::sptr tx_stream = usrp->get_tx_stream(stream_args);
//allocate a buffer which we re-use for each channel
- if (spb == 0) spb = tx_stream->get_max_num_samps()*10;
+ if (spb == 0) {
+ spb = tx_stream->get_max_num_samps()*10;
+ }
std::vector<std::complex<float> > buff(spb);
std::vector<std::complex<float> *> buffs(channel_nums.size(), &buff.front());
diff --git a/host/examples/wavetable.hpp b/host/examples/wavetable.hpp
index acced0d3a..8fdc8db30 100644
--- a/host/examples/wavetable.hpp
+++ b/host/examples/wavetable.hpp
@@ -19,7 +19,7 @@ public:
_wave_table(wave_table_len)
{
//compute real wave table with 1.0 amplitude
- std::vector<double> real_wave_table(wave_table_len);
+ std::vector<float> real_wave_table(wave_table_len);
if (wave_type == "CONST"){
for (size_t i = 0; i < wave_table_len; i++)
real_wave_table[i] = 1.0;
@@ -42,7 +42,10 @@ public:
//compute i and q pairs with 90% offset and scale to amplitude
for (size_t i = 0; i < wave_table_len; i++){
const size_t q = (i+(3*wave_table_len)/4)%wave_table_len;
- _wave_table[i] = std::complex<float>(ampl*real_wave_table[i], ampl*real_wave_table[q]);
+ _wave_table[i] = std::complex<float>(
+ ampl*real_wave_table[i],
+ ampl*real_wave_table[q]
+ );
}
}