Hi,
I would greatly appreciate help with editing some code. The provided code writes binary samples from a usrp radio to a .dat file. I am trying to edit the code to write to a "pipe (or fifo)" rather than a file but have not had much luck. The code is provided below. Thank you!
while(not stop_signal_called and (num_requested_samples != num_total_samps or num_requested_samples == 0)){
boost::system_time now = boost::get_system_time();
std::cout << boost::format("Waiting for \"%s\": ") % sensor_name;
std::cout.flush();
while (true){
if ((not first_lock_time.is_not_a_date_time()) and
(boost::get_system_time() > (first_lock_time + boost::posix_time::seconds(setup_time))))
{
std::cout << " locked." << std::endl;
break;
}
if (get_sensor_fn(sensor_name).to_bool()){
if (first_lock_time.is_not_a_date_time())
first_lock_time = boost::get_system_time();
std::cout << "+";
std::cout.flush();
}
else{
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;
throw std::runtime_error(str(boost::format("timed out waiting for consecutive locks on sensor \"%s\"") % sensor_name));
}
int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::set_thread_priority_safe();
//variables to be set by po
std::string args, file, type, ant, subdev, ref, wirefmt;
size_t total_num_samps, spb;
double rate, freq, gain, bw, total_time, setup_time;
//setup the program options
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
("args", po::value<std::string>(&args)->default_value(""), "multi uhd device address args")
("file", po::value<std::string>(&file)->default_value("usrp_samples.dat"), "name of the file to write binary samples to")
("type", po::value<std::string>(&type)->default_value("short"), "sample type: double, float, or short")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(0), "total number of samples to receive")
("time", po::value<double>(&total_time)->default_value(0), "total number of seconds to receive")
("spb", po::value<size_t>(&spb)->default_value(10000), "samples per buffer")
("rate", po::value<double>(&rate)->default_value(1e6), "rate of incoming samples")
("freq", po::value<double>(&freq)->default_value(0.0), "RF center frequency in Hz")
("gain", po::value<double>(&gain), "gain for the RF chain")
("ant", po::value<std::string>(&ant), "daughterboard antenna selection")
("subdev", po::value<std::string>(&subdev), "daughterboard subdevice specification")
("bw", po::value<double>(&bw), "daughterboard IF filter bandwidth in Hz")
("ref", po::value<std::string>(&ref)->default_value("internal"), "waveform type (internal, external, mimo)")
("wirefmt", po::value<std::string>(&wirefmt)->default_value("sc16"), "wire format (sc8 or sc16)")
("setup", po::value<double>(&setup_time)->default_value(1.0), "seconds of setup time")
("progress", "periodically display short-term bandwidth")
("stats", "show average bandwidth on exit")
("sizemap", "track packet size and display breakdown on exit")
("null", "run without writing to file")
("continue", "don't abort on a bad packet")
("skip-lo", "skip checking LO lock status")
("int-n", "tune USRP with integer-N tuning")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
#define recv_to_file_args(format) \
(usrp, format, wirefmt, file, spb, total_num_samps, total_time, bw_summary, stats, null, enable_size_map, continue_on_bad_packet)
//recv to file
if (type == "double") recv_to_file<std::complex<double> >recv_to_file_args("fc64");
else if (type == "float") recv_to_file<std::complex<float> >recv_to_file_args("fc32");
else if (type == "short") recv_to_file<std::complex<short> >recv_to_file_args("sc16");
else throw std::runtime_error("Unknown type " + type);
Isn't is simply a case of asking the operating system to pipe the standard output? In terms of the code, that means instead of writing to a file you need to send the data to the standard output std::cout etc.
You may need to separate out any extraneous information messages and direct them to a different output (such as a log file).