Hello,
I have been having some problems collecting DTV data on the second
channel of my TVRX2 daughterboard on the USRP2. The .dat files created
from the second channel are blank. I have had no problems
collecting the data on the first channel. I think I’m overlooking a
small error in my code but cannot figure out what it is. Does anyone
have any idea?
Below is the function I’m using, where I believe the error is. The
command I use to execute is:
rx_samples_tvrx2.exe --file1 A\000000.dat --file2 B\000000.dat --freq1
183e6 --freq2 183e6 --rate 8e6 --gain 30 --nsamps 400000 --subdev “A:RX1
A:RX2”
The full code is attached, and I can give any more info needed. Any help
is greatly appreciated.
Thanks,
Kaylene
template void recv_to_file(
uhd::usrp::multi_usrp::sptr usrp,
const std::string &cpu_format,
const std::string &wire_format,
const std::string &file1,
const std::string &file2,
size_t samps_per_buff,
int num_requested_samples
){
int num_total_samps = 0;
//create a receive streamer
uhd::stream_args_t stream_args(cpu_format,wire_format);
uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
uhd::rx_metadata_t md;
//allocate buffers to receive with samples (one buffer per channel)
std::vector<std::vector<std::complex > > buff(
usrp->get_rx_num_channels(), std::vector<std::complex
(samps_per_buff)
);
//create a vector of pointers to point to each of the channel
buffers
std::vector<std::complex *> buff_ptrs;
for (size_t i = 0; i < buff.size(); i++)
buff_ptrs.push_back(&buff[i].front());
std::ofstream outfile1(file1.c_str(), std::ofstream::binary);
std::ofstream outfile2(file2.c_str(), std::ofstream::binary);
bool overflow_message = true;
//setup streaming
uhd::stream_cmd_t stream_cmd((num_requested_samples == 0)?
uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS:
uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE
);
stream_cmd.num_samps = num_requested_samples;
stream_cmd.stream_now = true;
stream_cmd.time_spec = uhd::time_spec_t();
usrp->issue_stream_cmd(stream_cmd);
while(not stop_signal_called and (num_requested_samples !=
num_total_samps or num_requested_samples == 0)){
size_t num_rx_samps = rx_stream->recv(buff_ptrs, buff.size(),
md, 3.0);
if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) {
std::cout << boost::format("Timeout while streaming") <<
std::endl;
break;
}
if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW){
if (overflow_message){
overflow_message = false;
std::cerr << boost::format(
“Got an overflow indication. Please consider the
following:\n”
" Your write medium must sustain a rate of
%fMB/s.\n"
" Dropped samples will not be written to the
file.\n"
" Please modify this example for your purposes.\n"
" This message will not appear again.\n"
) % (usrp->get_rx_rate()*sizeof(samp_type)/1e6);
}
continue;
}
if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
throw std::runtime_error(str(boost::format(
“Unexpected error code 0x%x”
) % md.error_code));
}
num_total_samps += num_rx_samps;
outfile1.write((const char*)&buff[0].front(),
num_rx_sampssizeof(samp_type));
outfile2.write((const char)&buff[1].front(),
num_rx_samps*sizeof(samp_type));
}
outfile1.close();
outfile2.close();
}