Ejemplo n.º 1
0
void uhd_device::restart(uhd::time_spec_t ts)
{
	uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS;
	usrp_dev->issue_stream_cmd(cmd);

	flush_recv(50);

	usrp_dev->set_time_now(ts);
	aligned = false;

	cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
	cmd.stream_now = true;
	usrp_dev->issue_stream_cmd(cmd);
}
Ejemplo n.º 2
0
bool UHDDevice::restart()
{
	double delay = 0.1;

	aligned = false;

	uhd::time_spec_t current = usrp_dev->get_time_now();

	uhd::stream_cmd_t cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
	cmd.stream_now = false;
	cmd.time_spec = uhd::time_spec_t(current.get_real_secs() + delay);

	usrp_dev->issue_stream_cmd(cmd);

	return flush_recv(10);
}
Ejemplo n.º 3
0
int SHD_SAFE_MAIN(int argc, char *argv[]) {
    shd::set_thread_priority_safe();

    //variables to be set by po
    std::string args;
    size_t ntests;

    //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 shd device address args")
    ("ntests", po::value<size_t>(&ntests)->default_value(50),    "number of tests to run")
    ;
    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    //print the help message
    if (vm.count("help")) {
        std::cout << boost::format("SHD Test Messages %s") % desc << std::endl;
        return ~0;
    }

    //create a smini device
    std::cout << std::endl;
    std::cout << boost::format("Creating the smini device with: %s...") % args << std::endl;
    shd::smini::multi_smini::sptr smini = shd::smini::multi_smini::make(args);
    std::cout << boost::format("Using Device: %s") % smini->get_pp_string() << std::endl;

    //create RX and TX streamers
    shd::stream_args_t stream_args("fc32"); //complex floats
    shd::rx_streamer::sptr rx_stream = smini->get_rx_stream(stream_args);
    shd::tx_streamer::sptr tx_stream = smini->get_tx_stream(stream_args);

    //------------------------------------------------------------------
    // begin messages test
    //------------------------------------------------------------------
    static const shd::dict<std::string, boost::function<bool(shd::smini::multi_smini::sptr, shd::rx_streamer::sptr, shd::tx_streamer::sptr)> >
    tests = boost::assign::map_list_of
            ("Test Burst ACK ", &test_burst_ack_message)
            ("Test Underflow ", &test_underflow_message)
            ("Test Time Error", &test_time_error_message)
            ("Test Late Command", &test_late_command_message)
            ("Test Broken Chain", &test_broken_chain_message)
            ;

    //init result counts
    shd::dict<std::string, size_t> failures, successes;
    BOOST_FOREACH(const std::string &key, tests.keys()) {
        failures[key] = 0;
        successes[key] = 0;
    }

    //run the tests, pick at random
    std::srand((unsigned int) time(NULL));
    for (size_t n = 0; n < ntests; n++) {
        std::string key = tests.keys()[std::rand() % tests.size()];
        bool pass = tests[key](smini, rx_stream, tx_stream);
        flush_async(smini);
        flush_recv(rx_stream);

        //store result
        if (pass) successes[key]++;
        else      failures[key]++;
    }

    //print the result summary
    std::cout << std::endl << "Summary:" << std::endl << std::endl;
    BOOST_FOREACH(const std::string &key, tests.keys()) {
        std::cout << boost::format(
                      "%s   ->   %3u successes, %3u failures"
                  ) % key % successes[key] % failures[key] << std::endl;
    }

    //finished
    std::cout << std::endl << "Done!" << std::endl << std::endl;

    return 0;
}