Hi, the recv function has a return value which tells you the amount of samples returned. Usually you use this value to increase your buffer pointer and continue writing where you stopped. You should also try to plot the data to see what is happening. Hope that helps,
Fabian Am 04.09.2018 um 17:27 schrieb Jeremy Foran: > Thanks Fabian, > > I have tried a few different values for timeout as per your > recommendation and none seem to have an affect: > 2.0 > 1.0 > 0.5 > 0.25 > 0.001 > > All have about the same result of ~50% of the samples contain a zero. > > Ive also tried setting the sample sizes from fc32 to sc16 with more or > less the same result. > > What would be a normal amount of zeros to receive from a stream like > this? %1? %10? > >> On Sep 4, 2018, at 11:11 AM, Fabian Schwartau via USRP-users >> <[email protected] <mailto:[email protected]>> wrote: >> >> Hi, >> >> maybe your recv runs frequently into timeout. It is the 4th parameter >> which is optional and set to a default value of 0.1 seconds. >> >> Best regards, >> >> Fabian >> >> Am 04.09.2018 um 16:56 schrieb Jeremy Foran via USRP-users: >>> Hello All, >>> I'm new to the community and excited to be a part of it. >>> I am looking to capture the full FM spectrum for a couple of seconds, >>> 88Mhz to 108Mhz, using the examples supplied by Ettus. I seem to be >>> getting more zeros in the results then I would have expected. About >>> half of the complex numbers will have a zero in it. Is that normal? >>> Am I doing something wrong? Code below: >>> #include <uhd/types/tune_request.hpp> >>> #include <uhd/utils/thread.hpp> >>> #include <uhd/utils/safe_main.hpp> >>> #include <uhd/usrp/multi_usrp.hpp> >>> #include <uhd/transport/udp_simple.hpp> >>> #include <uhd/exception.hpp> >>> #include <boost/program_options.hpp> >>> #include <boost/format.hpp> >>> #include <iostream> >>> #include <complex> >>> #include <chrono> >>> #include <thread> >>> using namespace std::chrono; >>> static bool stop_signal_called = false; >>> void sig_int_handler(int){stop_signal_called = true;} >>> namespace po = boost::program_options; >>> using namespace std; >>> int UHD_SAFE_MAIN(int argc, char *argv[]){ >>> uhd::set_thread_priority_safe(); >>> //variables to be set by po >>> std::string args, file, ant, subdev, ref; >>> size_t total_num_samps; >>> double rate, freq, gain, bw, duration; >>> std::string addr, port; >>> uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); >>> //Lock mboard clocks >>> usrp->set_clock_source("internal"); >>> freq = 98e6; >>> gain = 2; >>> rate = 1e6; >>> bw = 20e6; >>> duration= 8; >>> //set the rx sample rate >>> usrp->set_rx_rate(rate); >>> uhd::tune_request_t tune_request(freq); >>> usrp->set_rx_freq(tune_request); >>> //set the rx rf gain >>> usrp->set_rx_gain(gain); >>> //set the analog frontend filter bandwidth >>> usrp->set_rx_bandwidth(bw); >>> //create a receive streamer >>> uhd::stream_args_t stream_args("fc32"); >>> uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); >>> uhd::stream_cmd_t >>> stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); >>> const size_t samps_per_buff = rx_stream->get_max_num_samps(); >>> total_num_samps = rate * duration; >>> stream_cmd.num_samps = total_num_samps; >>> stream_cmd.stream_now = true; >>> // int const buff_size = rx_stream->get_max_num_samps(); >>> rx_stream->issue_stream_cmd(stream_cmd); >>> uhd::rx_metadata_t md; >>> std::vector<std::complex<float>> buff(total_num_samps); >>> std::vector<std::complex<float>> sizeor(samps_per_buff); >>> const size_t size_of_buff = sizeor.size(); >>> cout<<"Number of samples to capture: "<<total_num_samps<<endl; >>> //allow for some setup time >>> std::this_thread::sleep_for(std::chrono::seconds(2)); >>> //////////////////////////////////////////////////////////////////////// >>> cout<<"Starting Capture....."<<endl<<"======================"<<endl; >>> milliseconds start_time_ms = duration_cast< milliseconds >>> >(system_clock::now().time_since_epoch()); >>> int index=0; >>> while (!md.end_of_burst){ >>> rx_stream->recv( &buff[index * samps_per_buff], size_of_buff, >>> md); >>> index++; >>> } >>> milliseconds end_time_ms = duration_cast< milliseconds >>> >(system_clock::now().time_since_epoch()); >>> cout<<"Ending Capture....."<<endl<<"======================"<<endl; >>> //////////////////////////////////////////////////////////////////////// >>> // int x=1; >>> int zero = 0; >>> int zero_all = 0; >>> int real = 0; >>> int imag = 0; >>> for (std::complex<float> p: buff){ >>> if(p.real() == 0){real++;} >>> if(p.imag() == 0){imag++;} >>> if( (p.real()) == 0 && (p.imag() == 0) ){zero_all++;} >>> if( (p.real()) == 0 || (p.imag() == 0) ){zero++;} >>> } >>> cout<<"Samps : "<<buff.size()<<endl; >>> cout<<"Start : "<<start_time_ms.count()<<endl; >>> cout<<"End : "<<end_time_ms.count()<<endl; >>> cout<<"Total time: "<<end_time_ms.count() - >>> start_time_ms.count()<<endl<<endl; >>> cout<<"real :"<<real<<endl; >>> cout<<"image :"<<imag<<endl; >>> cout<<"Zeros :"<<zero<<endl; >>> cout<<"Zeros_all :"<<zero_all<<endl<<endl; >>> cout<<"Performance :"<<double (double(zero) / >>> double(buff.size()))<<endl; >>> std::cout << std::endl << "Done!" << std::endl << std::endl; >>> return EXIT_SUCCESS; >>> } >>> _______________________________________________ >>> USRP-users mailing list >>> [email protected] <mailto:[email protected]> >>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com >> >> _______________________________________________ >> USRP-users mailing list >> [email protected] <mailto:[email protected]> >> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com > > > > Jeremy Foran > > Technology Specialist > > BAI COMMUNICATIONS > > 33 BLOOR ST EAST, TORONTO, ON, CANADA M4W 3H1 > M: 416.500.4283 baicommunications.com <http://baicommunications.com> > Stay connected - LinkedIn | Twitter | Google+ | YouTube > _______________________________________________ USRP-users mailing list [email protected] http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
