Greetings!
I'm having some issues with talking to two channels at the same time. I'm
building from the maint branch, and if I use just one channel, I get
readings, but if I do two channels, the device simply hangs and never
responds.
The following is the sample code for this:
// Compile with:
// g++ -DZERO -o /tmp/channels channels.cc -luhd -lboost_system
// or
// g++ -DONE -o /tmp/channels channels.cc -luhd -lboost_system
// or
// g++ -DBOTH -o /tmp/channels channels.cc -luhd -lboost_system
#include <iostream>
#include <uhd/device3.hpp>
#include <uhd/rfnoc/radio_ctrl.hpp>
using ::boost::uint32_t;
using ::std::cout;
using ::std::vector;
using uhd::rfnoc::radio_ctrl;
constexpr double kTimeout_sec = 20;
constexpr int kSPP = 1000;
void Report(int samples_read, const uhd::rx_metadata_t &md) {
cout << "Read : " << samples_read
<< " sample\n Metadata is: " << md.to_pp_string(false) << "\n";
}
int main(int argc, char *argv[]) {
uhd::device3::sptr usrp = uhd::device3::make(std::string(argv[1]));
int samples_to_read = 10;
uhd::device_addr_t streamer_args(std::string(""));
uhd::stream_args_t stream_args("sc16", "sc16");
#ifdef ZERO
uhd::rfnoc::block_id_t radio_ctrl_id0(0, "Radio");
radio_ctrl::sptr radio0 =
usrp->get_block_ctrl<radio_ctrl>(radio_ctrl_id0);
radio0->set_arg<int>(std::string("spp"), kSPP);
streamer_args["block_id"] = radio_ctrl_id0.to_string();
stream_args.channels = {0};
vector<vector<uint32_t>> buffs(1, vector<uint32_t>(samples_to_read));
#endif
#ifdef ONE
uhd::rfnoc::block_id_t radio_ctrl_id1(0, "Radio", 1);
radio_ctrl::sptr radio1 =
usrp->get_block_ctrl<radio_ctrl>(radio_ctrl_id1);
radio1->set_arg<int>(std::string("spp"), kSPP);
streamer_args["block_id"] = radio_ctrl_id1.to_string();
stream_args.channels = {1};
vector<vector<uint32_t>> buffs(1, vector<uint32_t>(samples_to_read));
#endif
#ifdef BOTH
uhd::rfnoc::block_id_t radio_ctrl_id0(0, "Radio");
uhd::rfnoc::block_id_t radio_ctrl_id1(0, "Radio", 1);
radio_ctrl::sptr radio0 =
usrp->get_block_ctrl<radio_ctrl>(radio_ctrl_id0);
radio_ctrl::sptr radio1 =
usrp->get_block_ctrl<radio_ctrl>(radio_ctrl_id1);
radio0->set_arg<int>(std::string("spp"), kSPP);
radio1->set_arg<int>(std::string("spp"), kSPP);
streamer_args["block_id0"] = radio_ctrl_id0.to_string();
streamer_args["block_id1"] = radio_ctrl_id1.to_string();
stream_args.channels = {0, 1};
vector<vector<uint32_t>> buffs(2, vector<uint32_t>(samples_to_read));
#endif
stream_args.args = streamer_args;
streamer_args["block_port"] = std::string("0");
stream_args.args["spp"] = boost::lexical_cast<std::string>(kSPP);
uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
uhd::stream_cmd_t
stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
stream_cmd.stream_now = true;
rx_stream->issue_stream_cmd(stream_cmd);
vector<uint32_t *> buff_ptrs;
for (auto &b : buffs) buff_ptrs.push_back(b.data());
uhd::rx_metadata_t md;
int samples_read =
rx_stream->recv(buff_ptrs, samples_to_read, md, kTimeout_sec);
Report(samples_read, md);
stream_cmd.stream_mode = uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS;
stream_cmd.stream_now = true;
rx_stream->issue_stream_cmd(stream_cmd);
return EXIT_SUCCESS;
}
-Tal
_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com