From 232a398f9df97c00a7a62657118ec49f5d174583 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 15 Mar 2011 12:30:20 -0700 Subject: uhd: added missing set_tx_antenna() in tx waveforms --- host/examples/tx_waveforms.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 9c45e918b..5b3a1b70c 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -137,6 +137,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Actual TX Bandwidth: %f MHz...") % usrp->get_tx_bandwidth() << std::endl << std::endl; } + //set the antenna + if (vm.count("ant")) usrp->set_tx_antenna(ant); + //for the const wave, set the wave freq for small samples per period if (wave_freq == 0 and wave_type == "CONST"){ wave_freq = usrp->get_tx_rate()/2; -- cgit v1.2.3 From 3a1ad3f13c41a448083100ada6d4162a0092ee58 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 15 Mar 2011 12:52:56 -0700 Subject: uhd: copied examples changes from next onto master branch --- host/examples/CMakeLists.txt | 2 + host/examples/latency_test.cpp | 6 +- host/examples/rx_multi_samples.cpp | 158 +++++++++++++++++++++++++++++++++ host/examples/rx_samples_to_file.cpp | 147 ++++++++++++++++++------------ host/examples/rx_timed_samples.cpp | 57 ++++++------ host/examples/tx_samples_from_file.cpp | 149 +++++++++++++++++++++++++++++++ host/examples/tx_timed_samples.cpp | 66 ++++++++------ host/examples/tx_waveforms.cpp | 69 ++++++++++---- 8 files changed, 515 insertions(+), 139 deletions(-) create mode 100644 host/examples/rx_multi_samples.cpp create mode 100644 host/examples/tx_samples_from_file.cpp diff --git a/host/examples/CMakeLists.txt b/host/examples/CMakeLists.txt index 434caa328..44ed55380 100644 --- a/host/examples/CMakeLists.txt +++ b/host/examples/CMakeLists.txt @@ -20,11 +20,13 @@ ######################################################################## SET(example_sources benchmark_rx_rate.cpp + rx_multi_samples.cpp rx_samples_to_file.cpp rx_samples_to_udp.cpp rx_timed_samples.cpp test_async_messages.cpp test_pps_input.cpp + tx_samples_from_file.cpp tx_timed_samples.cpp tx_waveforms.cpp latency_test.cpp diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index be44aad70..85ac73567 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -150,9 +150,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ break; default: - std::cout << boost::format - ("failed:\n Got unexpected event code 0x%x.\n") - % async_md.event_code << std::endl; + std::cerr << boost::format( + "failed:\n Got unexpected event code 0x%x.\n" + ) % async_md.event_code << std::endl; other++; break; } diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp new file mode 100644 index 000000000..e820343ca --- /dev/null +++ b/host/examples/rx_multi_samples.cpp @@ -0,0 +1,158 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace po = boost::program_options; + +int UHD_SAFE_MAIN(int argc, char *argv[]){ + uhd::set_thread_priority_safe(); + + //variables to be set by po + std::string args, sync, subdev; + double seconds_in_future; + size_t total_num_samps; + double rate; + + //setup the program options + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "help message") + ("args", po::value(&args)->default_value(""), "single uhd device address args") + ("secs", po::value(&seconds_in_future)->default_value(1.5), "number of seconds in the future to receive") + ("nsamps", po::value(&total_num_samps)->default_value(10000), "total number of samples to receive") + ("rate", po::value(&rate)->default_value(100e6/16), "rate of incoming samples") + ("sync", po::value(&sync)->default_value("now"), "synchronization method: now, pps") + ("subdev", po::value(&subdev)->default_value(""), "subdev spec (homogeneous across motherboards)") + ("dilv", "specify to disable inner-loop verbose") + ; + 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("UHD RX Multi Samples %s") % desc << std::endl; + std::cout << + " This is a demonstration of how to receive aligned data from multiple channels.\n" + " This example can receive from multiple DSPs, multiple motherboards, or both.\n" + " The MIMO cable or PPS can be used to synchronize the configuration. See --sync\n" + "\n" + " Specify --subdev to select multiple channels per motherboard.\n" + " Ex: --subdev=\"0:A 0:B\" to get 2 channels on a Basic RX.\n" + "\n" + " Specify --args to select multiple motherboards in a configuration.\n" + " Ex: --args=\"addr0=192.168.10.2, addr1=192.168.10.3\"\n" + << std::endl; + return ~0; + } + + bool verbose = vm.count("dilv") == 0; + + //create a usrp device + std::cout << std::endl; + std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; + uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); + + //always select the subdevice first, the channel mapping affects the other settings + if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev); //sets across all mboards + + std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; + + //set the rx sample rate (sets across all channels) + std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; + usrp->set_rx_rate(rate); + std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl; + + std::cout << boost::format("Setting device timestamp to 0...") << std::endl; + if (sync == "now"){ + usrp->set_time_now(uhd::time_spec_t(0.0)); + boost::this_thread::sleep(boost::posix_time::milliseconds(50)); //wait for mimo cable time sync + } + else if (sync == "pps"){ + usrp->set_time_unknown_pps(uhd::time_spec_t(0.0)); + boost::this_thread::sleep(boost::posix_time::seconds(1)); //wait for pps sync pulse + } + + //setup streaming + std::cout << std::endl; + std::cout << boost::format( + "Begin streaming %u samples, %f seconds in the future..." + ) % total_num_samps % seconds_in_future << std::endl; + uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); + stream_cmd.num_samps = total_num_samps; + stream_cmd.stream_now = false; + stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future); + usrp->issue_stream_cmd(stream_cmd); //tells all channels to stream + + //meta-data will be filled in by recv() + uhd::rx_metadata_t md; + + //allocate buffers to receive with samples (one buffer per channel) + size_t samps_per_buff = usrp->get_device()->get_max_recv_samps_per_packet(); + std::vector > > buffs( + usrp->get_rx_num_channels(), std::vector >(samps_per_buff) + ); + + //create a vector of pointers to point to each of the channel buffers + std::vector *> buff_ptrs; + for (size_t i = 0; i < buffs.size(); i++) buff_ptrs.push_back(&buffs[i].front()); + + //the first call to recv() will block this many seconds before receiving + double timeout = seconds_in_future + 0.1; //timeout (delay before receive + padding) + + size_t num_acc_samps = 0; //number of accumulated samples + while(num_acc_samps < total_num_samps){ + //receive a single packet + size_t num_rx_samps = usrp->get_device()->recv( + buff_ptrs, samps_per_buff, md, + uhd::io_type_t::COMPLEX_FLOAT32, + uhd::device::RECV_MODE_ONE_PACKET, timeout + ); + + //use a small timeout for subsequent packets + timeout = 0.1; + + //handle the error code + if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; + 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)); + } + + if(verbose) std::cout << boost::format( + "Received packet: %u samples, %u full secs, %f frac secs" + ) % num_rx_samps % md.time_spec.get_full_secs() % md.time_spec.get_frac_secs() << std::endl; + + num_acc_samps += num_rx_samps; + } + + if (num_acc_samps < total_num_samps) std::cerr << "Receive timeout before all samples received..." << std::endl; + + //finished + std::cout << std::endl << "Done!" << std::endl << std::endl; + + return 0; +} diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index e202fcb1c..d44315701 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -23,28 +23,66 @@ #include #include #include +#include #include namespace po = boost::program_options; +static bool stop_signal_called = false; +void sig_int_handler(int){stop_signal_called = true;} + +template void recv_to_file( + uhd::usrp::multi_usrp::sptr usrp, + const uhd::io_type_t &io_type, + const std::string &file, + size_t samps_per_buff +){ + uhd::rx_metadata_t md; + std::vector buff(samps_per_buff); + std::ofstream outfile(file.c_str(), std::ofstream::binary); + + while(not stop_signal_called){ + size_t num_rx_samps = usrp->get_device()->recv( + &buff.front(), buff.size(), md, io_type, + uhd::device::RECV_MODE_FULL_BUFF + ); + + if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; + 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)); + } + + outfile.write((const char*)&buff.front(), num_rx_samps*sizeof(samp_type)); + } + + outfile.close(); +} + int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, file; - size_t total_num_samps; - double rate, freq, gain; + std::string args, file, type, ant, subdev; + size_t total_num_samps, spb; + double rate, freq, gain, bw; //setup the program options po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "multi uhd device address args") - ("file", po::value(&file)->default_value("out.16sc.dat"), "name of the file to write binary samples to") - ("nsamps", po::value(&total_num_samps)->default_value(1000), "total number of samples to receive") - ("rate", po::value(&rate)->default_value(100e6/16), "rate of incoming samples") - ("freq", po::value(&freq)->default_value(0), "rf center frequency in Hz") - ("gain", po::value(&gain)->default_value(0), "gain for the RF chain") + ("file", po::value(&file)->default_value("usrp_samples.dat"), "name of the file to write binary samples to") + ("type", po::value(&type)->default_value("float"), "sample type: double, float, or short") + ("nsamps", po::value(&total_num_samps)->default_value(0), "total number of samples to receive") + ("spb", po::value(&spb)->default_value(10000), "samples per buffer") + ("rate", po::value(&rate), "rate of incoming samples") + ("freq", po::value(&freq), "RF center frequency in Hz") + ("gain", po::value(&gain), "gain for the RF chain") + ("ant", po::value(&ant), "daughterboard antenna selection") + ("subdev", po::value(&subdev), "daughterboard subdevice specification") + ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); @@ -60,70 +98,67 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); + + //always select the subdevice first, the channel mapping affects the other settings + if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev); + std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; - //set the rx sample rate + //set the sample rate + if (not vm.count("rate")){ + std::cerr << "Please specify the sample rate with --rate" << std::endl; + return ~0; + } std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; usrp->set_rx_rate(rate); std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl; - //set the rx center frequency - std::cout << boost::format("Setting RX Freq: %f Mhz...") % (freq/1e6) << std::endl; + //set the center frequency + if (not vm.count("freq")){ + std::cerr << "Please specify the center frequency with --freq" << std::endl; + return ~0; + } + std::cout << boost::format("Setting RX Freq: %f MHz...") % (freq/1e6) << std::endl; usrp->set_rx_freq(freq); - std::cout << boost::format("Actual RX Freq: %f Mhz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl; + std::cout << boost::format("Actual RX Freq: %f MHz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl; - //set the rx rf gain - std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl; - usrp->set_rx_gain(gain); - std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl; + //set the rf gain + if (vm.count("gain")){ + std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl; + usrp->set_rx_gain(gain); + std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl; + } + + //set the IF filter bandwidth + if (vm.count("bw")){ + std::cout << boost::format("Setting RX Bandwidth: %f MHz...") % bw << std::endl; + usrp->set_rx_bandwidth(bw); + std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % usrp->get_rx_bandwidth() << std::endl << std::endl; + } + + //set the antenna + if (vm.count("ant")) usrp->set_rx_antenna(ant); boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time //setup streaming - uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); + uhd::stream_cmd_t stream_cmd((total_num_samps == 0)? + uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS: + uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE + ); stream_cmd.num_samps = total_num_samps; stream_cmd.stream_now = true; usrp->issue_stream_cmd(stream_cmd); + if (total_num_samps == 0){ + std::signal(SIGINT, &sig_int_handler); + std::cout << "Press Ctrl + C to stop streaming..." << std::endl; + } - //loop until total number of samples reached - size_t num_acc_samps = 0; //number of accumulated samples - uhd::rx_metadata_t md; - std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); - std::ofstream outfile(file.c_str(), std::ofstream::binary); - - while(num_acc_samps < total_num_samps){ - size_t num_rx_samps = usrp->get_device()->recv( - &buff.front(), buff.size(), md, - uhd::io_type_t::COMPLEX_INT16, - uhd::device::RECV_MODE_ONE_PACKET - ); - - //handle the error codes - switch(md.error_code){ - case uhd::rx_metadata_t::ERROR_CODE_NONE: - break; - - case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: - if (num_acc_samps == 0) continue; - std::cout << boost::format( - "Got timeout before all samples received, possible packet loss, exiting loop..." - ) << std::endl; - goto done_loop; - - default: - std::cout << boost::format( - "Got error code 0x%x, exiting loop..." - ) % md.error_code << std::endl; - goto done_loop; - } - - //write complex short integer samples to the binary file - outfile.write((const char*)&buff[0], num_rx_samps * sizeof(std::complex)); - - num_acc_samps += num_rx_samps; - } done_loop: - - outfile.close(); + //recv to file + if (type == "double") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT64, file, spb); + else if (type == "float") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT32, file, spb); + else if (type == "short") recv_to_file >(usrp, uhd::io_type_t::COMPLEX_INT16, file, spb); + else throw std::runtime_error("Unknown type " + type); //finished std::cout << std::endl << "Done!" << std::endl << std::endl; diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 630b4a7a9..28d7ee466 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -32,18 +32,17 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string args; double seconds_in_future; size_t total_num_samps; - double rate, freq, clock; + double rate, clock; //setup the program options po::options_description desc("Allowed options"); desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "single uhd device address args") - ("secs", po::value(&seconds_in_future)->default_value(3), "number of seconds in the future to receive") - ("nsamps", po::value(&total_num_samps)->default_value(1000), "total number of samples to receive") + ("secs", po::value(&seconds_in_future)->default_value(1.5), "number of seconds in the future to receive") + ("nsamps", po::value(&total_num_samps)->default_value(10000), "total number of samples to receive") ("clock", po::value(&clock), "master clock frequency in Hz") ("rate", po::value(&rate)->default_value(100e6/16), "rate of incoming samples") - ("freq", po::value(&freq)->default_value(0), "rf center frequency in Hz") ("dilv", "specify to disable inner-loop verbose") ; po::variables_map vm; @@ -75,11 +74,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_rx_rate(rate); std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl; - //set the rx center frequency - std::cout << boost::format("Setting RX Freq: %f Mhz...") % (freq/1e6) << std::endl; - usrp->set_rx_freq(freq); - std::cout << boost::format("Actual RX Freq: %f Mhz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl; - std::cout << boost::format("Setting device timestamp to 0...") << std::endl; usrp->set_time_now(uhd::time_spec_t(0.0)); @@ -94,44 +88,43 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future); usrp->issue_stream_cmd(stream_cmd); - //allocate buffer to receive + //meta-data will be filled in by recv() + uhd::rx_metadata_t md; + + //allocate buffer to receive with samples std::vector > buff(usrp->get_device()->get_max_recv_samps_per_packet()); - //loop until total number of samples reached + //the first call to recv() will block this many seconds before receiving + double timeout = seconds_in_future + 0.1; //timeout (delay before receive + padding) + size_t num_acc_samps = 0; //number of accumulated samples while(num_acc_samps < total_num_samps){ - uhd::rx_metadata_t md; + //receive a single packet size_t num_rx_samps = usrp->get_device()->recv( &buff.front(), buff.size(), md, uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET + uhd::device::RECV_MODE_ONE_PACKET, timeout ); - //handle the error codes - switch(md.error_code){ - case uhd::rx_metadata_t::ERROR_CODE_NONE: - break; - - case uhd::rx_metadata_t::ERROR_CODE_TIMEOUT: - if (num_acc_samps == 0) continue; - std::cout << boost::format( - "Got timeout before all samples received, possible packet loss, exiting loop..." - ) << std::endl; - goto done_loop; - - default: - std::cout << boost::format( - "Got error code 0x%x, exiting loop..." - ) % md.error_code << std::endl; - goto done_loop; + //use a small timeout for subsequent packets + timeout = 0.1; + + //handle the error code + if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break; + 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)); } if(verbose) std::cout << boost::format( - "Got packet: %u samples, %u full secs, %f frac secs" + "Received packet: %u samples, %u full secs, %f frac secs" ) % num_rx_samps % md.time_spec.get_full_secs() % md.time_spec.get_frac_secs() << std::endl; num_acc_samps += num_rx_samps; - } done_loop: + } + + if (num_acc_samps < total_num_samps) std::cerr << "Receive timeout before all samples received..." << std::endl; //finished std::cout << std::endl << "Done!" << std::endl << std::endl; diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp new file mode 100644 index 000000000..acf899fa9 --- /dev/null +++ b/host/examples/tx_samples_from_file.cpp @@ -0,0 +1,149 @@ +// +// Copyright 2011 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace po = boost::program_options; + +template void send_from_file( + uhd::usrp::multi_usrp::sptr usrp, + const uhd::io_type_t &io_type, + const std::string &file, + size_t samps_per_buff +){ + uhd::tx_metadata_t md; + md.start_of_burst = false; + md.end_of_burst = false; + std::vector buff(samps_per_buff); + std::ifstream infile(file.c_str(), std::ifstream::binary); + + //loop until the entire file has been read + while(not md.end_of_burst){ + + infile.read((char*)&buff.front(), buff.size()*sizeof(samp_type)); + size_t num_tx_samps = infile.gcount()/sizeof(samp_type); + + md.end_of_burst = infile.eof(); + + usrp->get_device()->send( + &buff.front(), num_tx_samps, md, io_type, + uhd::device::SEND_MODE_FULL_BUFF + ); + } + + infile.close(); +} + +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; + size_t spb; + double rate, freq, gain, bw; + + //setup the program options + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "help message") + ("args", po::value(&args)->default_value(""), "multi uhd device address args") + ("file", po::value(&file)->default_value("usrp_samples.dat"), "name of the file to read binary samples from") + ("type", po::value(&type)->default_value("float"), "sample type: double, float, or short") + ("spb", po::value(&spb)->default_value(10000), "samples per buffer") + ("rate", po::value(&rate), "rate of outgoing samples") + ("freq", po::value(&freq), "RF center frequency in Hz") + ("gain", po::value(&gain), "gain for the RF chain") + ("ant", po::value(&ant), "daughterboard antenna selection") + ("subdev", po::value(&subdev), "daughterboard subdevice specification") + ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") + ; + 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("UHD TX samples from file %s") % desc << std::endl; + return ~0; + } + + //create a usrp device + std::cout << std::endl; + std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; + uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); + + //always select the subdevice first, the channel mapping affects the other settings + if (vm.count("subdev")) usrp->set_tx_subdev_spec(subdev); + + std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; + + //set the sample rate + if (not vm.count("rate")){ + std::cerr << "Please specify the sample rate with --rate" << std::endl; + return ~0; + } + std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl; + usrp->set_tx_rate(rate); + std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl; + + //set the center frequency + if (not vm.count("freq")){ + std::cerr << "Please specify the center frequency with --freq" << std::endl; + return ~0; + } + std::cout << boost::format("Setting TX Freq: %f MHz...") % (freq/1e6) << std::endl; + usrp->set_tx_freq(freq); + std::cout << boost::format("Actual TX Freq: %f MHz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; + + //set the rf gain + if (vm.count("gain")){ + std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl; + usrp->set_tx_gain(gain); + std::cout << boost::format("Actual TX Gain: %f dB...") % usrp->get_tx_gain() << std::endl << std::endl; + } + + //set the IF filter bandwidth + if (vm.count("bw")){ + std::cout << boost::format("Setting TX Bandwidth: %f MHz...") % bw << std::endl; + usrp->set_tx_bandwidth(bw); + std::cout << boost::format("Actual TX Bandwidth: %f MHz...") % usrp->get_tx_bandwidth() << std::endl << std::endl; + } + + //set the antenna + if (vm.count("ant")) usrp->set_tx_antenna(ant); + + boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time + + //send from file + if (type == "double") send_from_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT64, file, spb); + else if (type == "float") send_from_file >(usrp, uhd::io_type_t::COMPLEX_FLOAT32, file, spb); + else if (type == "short") send_from_file >(usrp, uhd::io_type_t::COMPLEX_INT16, file, spb); + else throw std::runtime_error("Unknown type " + type); + + //finished + std::cout << std::endl << "Done!" << std::endl << std::endl; + + return 0; +} diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index f10d7e4ea..03f87122d 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -33,8 +33,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string args; double seconds_in_future; size_t total_num_samps; - size_t samps_per_packet; - double rate, freq; + double rate; float ampl; //setup the program options @@ -42,11 +41,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "single uhd device address args") - ("secs", po::value(&seconds_in_future)->default_value(3), "number of seconds in the future to transmit") - ("nsamps", po::value(&total_num_samps)->default_value(1000), "total number of samples to transmit") - ("spp", po::value(&samps_per_packet)->default_value(1000), "number of samples per packet") + ("secs", po::value(&seconds_in_future)->default_value(1.5), "number of seconds in the future to transmit") + ("nsamps", po::value(&total_num_samps)->default_value(10000), "total number of samples to transmit") ("rate", po::value(&rate)->default_value(100e6/16), "rate of outgoing samples") - ("freq", po::value(&freq)->default_value(0), "rf center frequency in Hz") ("ampl", po::value(&l)->default_value(float(0.3)), "amplitude of each sample") ("dilv", "specify to disable inner-loop verbose") ; @@ -73,45 +70,56 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ usrp->set_tx_rate(rate); std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl; - //set the tx center frequency - std::cout << boost::format("Setting TX Freq: %f Mhz...") % (freq/1e6) << std::endl; - usrp->set_tx_freq(freq); - std::cout << boost::format("Actual TX Freq: %f Mhz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; - std::cout << boost::format("Setting device timestamp to 0...") << std::endl; usrp->set_time_now(uhd::time_spec_t(0.0)); - //allocate data to send - std::vector > buff(samps_per_packet, std::complex(ampl, ampl)); + //allocate buffer with data to send + std::vector > buff(usrp->get_device()->get_max_send_samps_per_packet(), std::complex(ampl, ampl)); + //setup metadata for the first packet uhd::tx_metadata_t md; + md.start_of_burst = false; + md.end_of_burst = false; + md.has_time_spec = true; md.time_spec = uhd::time_spec_t(seconds_in_future); - //send the data in multiple packets - size_t num_packets = (total_num_samps+samps_per_packet-1)/samps_per_packet; - for (size_t i = 0; i < num_packets; i++){ + //the first call to send() will block this many seconds before sending: + double timeout = seconds_in_future + 0.1; //timeout (delay before transmit + padding) - //setup the metadata flags per fragment - md.start_of_burst = (i == 0); //only first packet has SOB - md.end_of_burst = (i == num_packets-1); //only last packet has EOB - md.has_time_spec = (i == 0); //only first packet has time + size_t num_acc_samps = 0; //number of accumulated samples + while(num_acc_samps < total_num_samps){ + size_t samps_to_send = std::min(total_num_samps - num_acc_samps, buff.size()); - size_t samps_to_send = std::min(total_num_samps - samps_per_packet*i, samps_per_packet); + //ensure the the last packet has EOB set + md.end_of_burst = samps_to_send <= buff.size(); - //send the entire packet (driver fragments internally) + //send a single packet size_t num_tx_samps = usrp->get_device()->send( &buff.front(), samps_to_send, md, uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF, - //send will backup into the host this many seconds before sending: - seconds_in_future + 0.1 //timeout (delay before transmit + padding) + uhd::device::SEND_MODE_ONE_PACKET, timeout ); - if (num_tx_samps < samps_to_send) std::cout << "Send timeout..." << std::endl; - if(verbose) std::cout << std::endl << boost::format("Sent %d samples") % num_tx_samps << std::endl; + + //use a small timeout for subsequent packets + timeout = 0.1; + + //do not use time spec for subsequent packets + md.has_time_spec = false; + + if (num_tx_samps < samps_to_send) std::cerr << "Send timeout..." << std::endl; + if(verbose) std::cout << boost::format("Sent packet: %u samples") % num_tx_samps << std::endl; + + num_acc_samps += num_tx_samps; } - //ensure that the buffers have flushed out to the device before deconstruction - boost::this_thread::sleep(boost::posix_time::seconds(1)); + std::cout << std::endl << "Waiting for async burst ACK... " << std::flush; + uhd::async_metadata_t async_md; + bool got_async_burst_ack = false; + //loop through all messages for the ACK packet (may have underflow messages in queue) + while (not got_async_burst_ack and usrp->get_device()->recv_async_msg(async_md, seconds_in_future)){ + got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK); + } + std::cout << (got_async_burst_ack? "success" : "fail") << std::endl; //finished std::cout << std::endl << "Done!" << std::endl << std::endl; diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 05d49a8b3..5b3a1b70c 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -20,16 +20,19 @@ #include #include #include -#include //system time #include #include #include #include #include +#include #include namespace po = boost::program_options; +static bool stop_signal_called = false; +void sig_int_handler(int){stop_signal_called = true;} + /*********************************************************************** * Waveform generators **********************************************************************/ @@ -61,9 +64,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::set_thread_priority_safe(); //variables to be set by po - std::string args, wave_type; - size_t total_duration, spb; - double rate, freq, gain, wave_freq; + std::string args, wave_type, ant, subdev; + size_t spb; + double rate, freq, gain, wave_freq, bw; float ampl; //setup the program options @@ -71,12 +74,14 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ desc.add_options() ("help", "help message") ("args", po::value(&args)->default_value(""), "single uhd device address args") - ("duration", po::value(&total_duration)->default_value(3), "number of seconds to transmit") ("spb", po::value(&spb)->default_value(10000), "samples per buffer") - ("rate", po::value(&rate)->default_value(1.5e6), "rate of outgoing samples") - ("freq", po::value(&freq)->default_value(0), "rf center frequency in Hz") + ("rate", po::value(&rate), "rate of outgoing samples") + ("freq", po::value(&freq), "RF center frequency in Hz") ("ampl", po::value(&l)->default_value(float(0.3)), "amplitude of the waveform") - ("gain", po::value(&gain)->default_value(0), "gain for the RF chain") + ("gain", po::value(&gain), "gain for the RF chain") + ("ant", po::value(&ant), "daughterboard antenna selection") + ("subdev", po::value(&subdev), "daughterboard subdevice specification") + ("bw", po::value(&bw), "daughterboard IF filter bandwidth in Hz") ("wave-type", po::value(&wave_type)->default_value("CONST"), "waveform type (CONST, SQUARE, RAMP, SINE)") ("wave-freq", po::value(&wave_freq)->default_value(0), "waveform frequency in Hz") ; @@ -94,22 +99,46 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl; std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl; uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args); + + //always select the subdevice first, the channel mapping affects the other settings + if (vm.count("subdev")) usrp->set_tx_subdev_spec(subdev); + std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl; - //set the tx sample rate + //set the sample rate + if (not vm.count("rate")){ + std::cerr << "Please specify the sample rate with --rate" << std::endl; + return ~0; + } std::cout << boost::format("Setting TX Rate: %f Msps...") % (rate/1e6) << std::endl; usrp->set_tx_rate(rate); std::cout << boost::format("Actual TX Rate: %f Msps...") % (usrp->get_tx_rate()/1e6) << std::endl << std::endl; - //set the tx center frequency - std::cout << boost::format("Setting TX Freq: %f Mhz...") % (freq/1e6) << std::endl; + //set the center frequency + if (not vm.count("freq")){ + std::cerr << "Please specify the center frequency with --freq" << std::endl; + return ~0; + } + std::cout << boost::format("Setting TX Freq: %f MHz...") % (freq/1e6) << std::endl; usrp->set_tx_freq(freq); - std::cout << boost::format("Actual TX Freq: %f Mhz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; + std::cout << boost::format("Actual TX Freq: %f MHz...") % (usrp->get_tx_freq()/1e6) << std::endl << std::endl; + + //set the rf gain + if (vm.count("gain")){ + std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl; + usrp->set_tx_gain(gain); + std::cout << boost::format("Actual TX Gain: %f dB...") % usrp->get_tx_gain() << std::endl << std::endl; + } - //set the tx rf gain - std::cout << boost::format("Setting TX Gain: %f dB...") % gain << std::endl; - usrp->set_tx_gain(gain); - std::cout << boost::format("Actual TX Gain: %f dB...") % usrp->get_tx_gain() << std::endl << std::endl; + //set the IF filter bandwidth + if (vm.count("bw")){ + std::cout << boost::format("Setting TX Bandwidth: %f MHz...") % bw << std::endl; + usrp->set_tx_bandwidth(bw); + std::cout << boost::format("Actual TX Bandwidth: %f MHz...") % usrp->get_tx_bandwidth() << std::endl << std::endl; + } + + //set the antenna + if (vm.count("ant")) usrp->set_tx_antenna(ant); //for the const wave, set the wave freq for small samples per period if (wave_freq == 0 and wave_type == "CONST"){ @@ -144,9 +173,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ md.start_of_burst = false; //never SOB when continuous md.end_of_burst = false; - //send the data in multiple packets - boost::system_time end_time(boost::get_system_time() + boost::posix_time::seconds(total_duration)); - while(end_time > boost::get_system_time()){ + std::signal(SIGINT, &sig_int_handler); + std::cout << "Press Ctrl + C to stop streaming..." << std::endl; + + //send data until the signal handler gets called + while(not stop_signal_called){ //fill the buffer with the waveform for (size_t n = 0; n < buff.size(); n++){ -- cgit v1.2.3 From 0d0d03d08d13037da2f2f1c85e546addff32aa69 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 15 Mar 2011 18:21:59 -0700 Subject: uhd: replace file_string() with string() for deprecation reasons Patch from moritz.fischer@student.kit.edu [1] http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/deprecated.html [2] http://www.boost.org/doc/libs/1_46_1/libs/filesystem/v3/doc/index.htm Boost 1.36 appears to have string(), so this should be safe to use. --- host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 2 +- host/lib/utils/images.cpp | 4 ++-- host/lib/utils/load_modules.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp index 40ea56466..f430090f0 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp @@ -53,7 +53,7 @@ static device_addrs_t usrp_e100_find(const device_addr_t &hint){ if (fs::exists(hint["node"])){ device_addr_t new_addr; new_addr["type"] = "usrp-e"; - new_addr["node"] = fs::system_complete(fs::path(hint["node"])).file_string(); + new_addr["node"] = fs::system_complete(fs::path(hint["node"])).string(); try{ usrp_e100_iface::sptr iface = usrp_e100_iface::make(new_addr["node"]); new_addr["name"] = iface->mb_eeprom["name"]; diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 395e542c1..24a599322 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.cpp @@ -30,11 +30,11 @@ std::vector get_image_paths(void); //defined in paths.cpp **********************************************************************/ std::string uhd::find_image_path(const std::string &image_name){ if (fs::exists(image_name)){ - return fs::system_complete(image_name).file_string(); + return fs::system_complete(image_name).string(); } BOOST_FOREACH(const fs::path &path, get_image_paths()){ fs::path image_path = path / image_name; - if (fs::exists(image_path)) return image_path.file_string(); + if (fs::exists(image_path)) return image_path.string(); } throw std::runtime_error("Could not find path for image: " + image_name); } diff --git a/host/lib/utils/load_modules.cpp b/host/lib/utils/load_modules.cpp index fa9b22438..33152855a 100644 --- a/host/lib/utils/load_modules.cpp +++ b/host/lib/utils/load_modules.cpp @@ -72,7 +72,7 @@ static void load_module(const std::string &file_name){ */ static void load_module_path(const fs::path &path){ if (not fs::exists(path)){ - //std::cerr << boost::format("Module path \"%s\" not found.") % path.file_string() << std::endl; + //std::cerr << boost::format("Module path \"%s\" not found.") % path.string() << std::endl; return; } @@ -90,7 +90,7 @@ static void load_module_path(const fs::path &path){ //its not a directory, try to load it try{ - load_module(path.file_string()); + load_module(path.string()); } catch(const std::exception &err){ std::cerr << boost::format("Error: %s") % err.what() << std::endl; -- cgit v1.2.3 From 5287fd580b9a68e6d7db4ce20aff3cc337b7e86c Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 16 Mar 2011 05:22:27 -0700 Subject: usrp_e100: Delete old test scripts. --- host/apps/omap_debug/fetch-bin.sh | 6 -- host/apps/omap_debug/fetch-kernel.sh | 7 -- host/apps/omap_debug/fetch-module.sh | 6 -- host/apps/omap_debug/fetch-u-boot.sh | 7 -- host/apps/omap_debug/read_board_id.sh | 10 --- host/apps/omap_debug/reload-fpga.sh | 7 -- host/apps/omap_debug/setup-board-id-eeprom.sh | 17 ----- host/apps/omap_debug/write-eeprom.sh | 92 --------------------------- host/apps/omap_debug/write_board_id.sh | 10 --- 9 files changed, 162 deletions(-) delete mode 100755 host/apps/omap_debug/fetch-bin.sh delete mode 100755 host/apps/omap_debug/fetch-kernel.sh delete mode 100755 host/apps/omap_debug/fetch-module.sh delete mode 100755 host/apps/omap_debug/fetch-u-boot.sh delete mode 100755 host/apps/omap_debug/read_board_id.sh delete mode 100755 host/apps/omap_debug/reload-fpga.sh delete mode 100755 host/apps/omap_debug/setup-board-id-eeprom.sh delete mode 100755 host/apps/omap_debug/write-eeprom.sh delete mode 100755 host/apps/omap_debug/write_board_id.sh diff --git a/host/apps/omap_debug/fetch-bin.sh b/host/apps/omap_debug/fetch-bin.sh deleted file mode 100755 index 019ddaaf2..000000000 --- a/host/apps/omap_debug/fetch-bin.sh +++ /dev/null @@ -1,6 +0,0 @@ -if [ $GHQ ]; then - scp $GHQ_USER@astro:/workspace/usrp1-e-dev/u1e.bin /home/root -else - scp -P 8822 balister@192.168.1.10:src/git/fpgapriv/usrp2/top/u1e/build/u1e.bin /home/root -fi -sync diff --git a/host/apps/omap_debug/fetch-kernel.sh b/host/apps/omap_debug/fetch-kernel.sh deleted file mode 100755 index ce420f3d2..000000000 --- a/host/apps/omap_debug/fetch-kernel.sh +++ /dev/null @@ -1,7 +0,0 @@ -if [ $GHQ ]; then - scp $GHQ_USER@astro:/workspace/usrp1-e-dev/kernel_usrp/arch/arm/boot/uImage /media/mmcblk0p1/uImage -else - scp balister@192.168.1.10:src/git/kernel_usrp/arch/arm/boot/uImage /media/mmcblk0p1/uImage -fi -sync - diff --git a/host/apps/omap_debug/fetch-module.sh b/host/apps/omap_debug/fetch-module.sh deleted file mode 100755 index ec28989bd..000000000 --- a/host/apps/omap_debug/fetch-module.sh +++ /dev/null @@ -1,6 +0,0 @@ -if [ $GHQ ]; then - scp $GHQ_USER@astro:/workspace/usrp1-e-dev/kernel_usrp/drivers/misc/usrp_e.ko /lib/modules/2.6.33/kernel/drivers/misc -else - scp balister@192.168.1.10:src/git/kernel_usrp/drivers/misc/usrp_e.ko /lib/modules/2.6.33/kernel/drivers/misc -fi -sync diff --git a/host/apps/omap_debug/fetch-u-boot.sh b/host/apps/omap_debug/fetch-u-boot.sh deleted file mode 100755 index 5309364b8..000000000 --- a/host/apps/omap_debug/fetch-u-boot.sh +++ /dev/null @@ -1,7 +0,0 @@ -if [ $GHQ ]; then - scp $GHQ_USER@astro:/workspace/usrp1-e-dev/u-boot-overo/u-boot.bin /media/mmcblk0p1/ -else - scp balister@192.168.1.167:src/git/u-boot/u-boot.bin /media/mmcblk0p1/ -fi -sync - diff --git a/host/apps/omap_debug/read_board_id.sh b/host/apps/omap_debug/read_board_id.sh deleted file mode 100755 index 96081f219..000000000 --- a/host/apps/omap_debug/read_board_id.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -i2cget -y 3 0x51 0x00 b -i2cget -y 3 0x51 0x01 b -i2cget -y 3 0x51 0x02 b -i2cget -y 3 0x51 0x03 b -i2cget -y 3 0x51 0x04 b -i2cget -y 3 0x51 0x05 b - - diff --git a/host/apps/omap_debug/reload-fpga.sh b/host/apps/omap_debug/reload-fpga.sh deleted file mode 100755 index 2754718a4..000000000 --- a/host/apps/omap_debug/reload-fpga.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -rmmod usrp_e -fpga-downloader /home/root/u1e.bin -modprobe usrp_e -usrp-e-debug-pins 1 - diff --git a/host/apps/omap_debug/setup-board-id-eeprom.sh b/host/apps/omap_debug/setup-board-id-eeprom.sh deleted file mode 100755 index 4dba1cce5..000000000 --- a/host/apps/omap_debug/setup-board-id-eeprom.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -i2cset -y 3 0x51 0x00 0x00 -i2cset -y 3 0x51 0x01 0x03 -i2cset -y 3 0x51 0x02 0x00 -i2cset -y 3 0x51 0x03 0x01 -i2cset -y 3 0x51 0x04 0x01 -i2cset -y 3 0x51 0x05 0x00 -i2cset -y 3 0x51 0x06 0x00 - -i2cget -y 3 0x51 0 b -i2cget -y 3 0x51 1 b -i2cget -y 3 0x51 2 b -i2cget -y 3 0x51 3 b -i2cget -y 3 0x51 4 b -i2cget -y 3 0x51 5 b -i2cget -y 3 0x51 6 b diff --git a/host/apps/omap_debug/write-eeprom.sh b/host/apps/omap_debug/write-eeprom.sh deleted file mode 100755 index 301b06f07..000000000 --- a/host/apps/omap_debug/write-eeprom.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash - -if [ $# -ne 3 ] && [ $# -ne 5 ]; -then - echo "Usage:" - echo "" - echo "writeprom.sh deviceid rev fab_rev [envvar envsetting]" - echo - echo " deviceid - expansion board device number from table:" - echo - echo " Summit 0x01" - echo " Tobi 0x02" - echo " Tobi Duo 0x03" - echo " Palo35 0x04" - echo " Palo43 0x05" - echo " Chestnut43 0x06" - echo " Pinto 0x07" - echo - echo " rev - board revision (e.g. 0x00)" - echo " fab_rev - revision marking from pcb (e.g. R2411)" - echo " envvar - optional u-boot env variable name" - echo " (e.g. dvimode)" - echo " envsetting - optional u-boot env variable setting" - echo " (e.g. 1024x768MR-16@60)" - exit 1 -fi - -fabrevision=$3 -if [ ${#fabrevision} -ge 8 ]; then - echo "Error: fab revision string must less than 8 characters" - exit 1 -fi - -envvar=$4 -if [ ${#envar} -ge 16 ]; then - echo "Error: environment variable name string must less than 16 characters" - exit 1 -fi - -envsetting=$5 -if [ ${#ensetting} -ge 64 ]; then - echo "Error: environment setting string must less than 64 characters" - exit 1 -fi - -bus=3 -device=0x51 -vendorid=0x03 - -i2cset -y $bus $device 0x00 0x00 -i2cset -y $bus $device 0x01 $vendorid -i2cset -y $bus $device 0x02 0x00 -i2cset -y $bus $device 0x03 $1 -i2cset -y $bus $device 0x04 $2 -i2cset -y $bus $device 0x05 00 - -let i=6 -hexdumpargs="'${#fabrevision}/1 \"0x%02x \"'" -command="echo -n \"$fabrevision\" | hexdump -e $hexdumpargs" -hex=$(eval $command) -for character in $hex; do - i2cset -y $bus $device $i $character - let i=$i+1 -done -i2cset -y $bus $device $i 0x00 - -if [ $# -eq 5 ] -then - i2cset -y $bus $device 0x05 0x01 - - let i=14 - hexdumpargs="'${#envvar}/1 \"0x%02x \"'" - command="echo -n \"$envvar\" | hexdump -e $hexdumpargs" - hex=$(eval $command) - for character in $hex; do - i2cset -y $bus $device $i $character - let i=$i+1 - done - i2cset -y $bus $device $i 0x00 - - let i=30 - hexdumpargs="'${#envsetting}/1 \"0x%02x \"'" - command="echo -n \"$envsetting\" | hexdump -e $hexdumpargs" - hex=$(eval $command) - for character in $hex; do - i2cset -y $bus $device $i $character - let i=$i+1 - done - i2cset -y $bus $device $i 0x00 -fi - - diff --git a/host/apps/omap_debug/write_board_id.sh b/host/apps/omap_debug/write_board_id.sh deleted file mode 100755 index 067269c64..000000000 --- a/host/apps/omap_debug/write_board_id.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -i2cset -y 3 0x51 0x00 0x00 -i2cset -y 3 0x51 0x01 0x03 -i2cset -y 3 0x51 0x02 0x00 -i2cset -y 3 0x51 0x03 0x01 -i2cset -y 3 0x51 0x04 0x00 -i2cset -y 3 0x51 0x05 0x00 - - -- cgit v1.2.3 From a8f7839af32c2b38fc586bccffc7eb57f558672b Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Wed, 16 Mar 2011 05:25:22 -0700 Subject: usrp_e100: Move gpio test program to utils. Still needs changing to use the new register map header. --- host/apps/omap_debug/usrp-e-gpio.c | 83 -------------------------------------- host/usrp_e_utils/usrp-e-gpio.c | 83 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 83 deletions(-) delete mode 100644 host/apps/omap_debug/usrp-e-gpio.c create mode 100644 host/usrp_e_utils/usrp-e-gpio.c diff --git a/host/apps/omap_debug/usrp-e-gpio.c b/host/apps/omap_debug/usrp-e-gpio.c deleted file mode 100644 index adef877d3..000000000 --- a/host/apps/omap_debug/usrp-e-gpio.c +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "usrp_e.h" -#include "usrp_e_regs.hpp" - -// Usage: usrp_e_gpio - -static int fp; - -static int read_reg(__u16 reg) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - ret = ioctl(fp, USRP_E_READ_CTL16, &d); - return d.buf[0]; -} - -static void write_reg(__u16 reg, __u16 val) -{ - int ret; - struct usrp_e_ctl16 d; - - d.offset = reg; - d.count = 1; - d.buf[0] = val; - ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); -} - -int main(int argc, char *argv[]) -{ - int i, test, data_in; - - test = 0; - if (argc > 1) - test = 1; - - fp = open("/dev/usrp_e0", O_RDWR); - printf("fp = %d\n", fp); - - write_reg(UE_REG_GPIO_TX_DDR, 0x0); - write_reg(UE_REG_GPIO_RX_DDR, 0xFFFF); - - for (i=0; i < 16; i++) { - write_reg(UE_REG_GPIO_RX_IO, 1 << i); - sleep(1); - if (test) { - data_in = read_reg(UE_REG_GPIO_TX_IO); - if (data_in != (1 << i)) - printf("Read failed, wrote: %X read: %X\n", \ - 1 << i, data_in); - } - } - - write_reg(UE_REG_GPIO_RX_DDR, 0x0); - write_reg(UE_REG_GPIO_TX_DDR, 0xFFFF); - - sleep(1); - - for (i=0; i < 16; i++) { - write_reg(UE_REG_GPIO_TX_IO, 1 << i); - sleep(1); - if (test) { - data_in = read_reg(UE_REG_GPIO_RX_IO); - if (data_in != (1 << i)) - printf("Read failed, wrote: %X read: %X\n", \ - 1 << i, data_in); - } - } - - write_reg(UE_REG_GPIO_RX_DDR, 0x0); - write_reg(UE_REG_GPIO_TX_DDR, 0x0); - - return 0; -} diff --git a/host/usrp_e_utils/usrp-e-gpio.c b/host/usrp_e_utils/usrp-e-gpio.c new file mode 100644 index 000000000..adef877d3 --- /dev/null +++ b/host/usrp_e_utils/usrp-e-gpio.c @@ -0,0 +1,83 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "usrp_e.h" +#include "usrp_e_regs.hpp" + +// Usage: usrp_e_gpio + +static int fp; + +static int read_reg(__u16 reg) +{ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + ret = ioctl(fp, USRP_E_READ_CTL16, &d); + return d.buf[0]; +} + +static void write_reg(__u16 reg, __u16 val) +{ + int ret; + struct usrp_e_ctl16 d; + + d.offset = reg; + d.count = 1; + d.buf[0] = val; + ret = ioctl(fp, USRP_E_WRITE_CTL16, &d); +} + +int main(int argc, char *argv[]) +{ + int i, test, data_in; + + test = 0; + if (argc > 1) + test = 1; + + fp = open("/dev/usrp_e0", O_RDWR); + printf("fp = %d\n", fp); + + write_reg(UE_REG_GPIO_TX_DDR, 0x0); + write_reg(UE_REG_GPIO_RX_DDR, 0xFFFF); + + for (i=0; i < 16; i++) { + write_reg(UE_REG_GPIO_RX_IO, 1 << i); + sleep(1); + if (test) { + data_in = read_reg(UE_REG_GPIO_TX_IO); + if (data_in != (1 << i)) + printf("Read failed, wrote: %X read: %X\n", \ + 1 << i, data_in); + } + } + + write_reg(UE_REG_GPIO_RX_DDR, 0x0); + write_reg(UE_REG_GPIO_TX_DDR, 0xFFFF); + + sleep(1); + + for (i=0; i < 16; i++) { + write_reg(UE_REG_GPIO_TX_IO, 1 << i); + sleep(1); + if (test) { + data_in = read_reg(UE_REG_GPIO_RX_IO); + if (data_in != (1 << i)) + printf("Read failed, wrote: %X read: %X\n", \ + 1 << i, data_in); + } + } + + write_reg(UE_REG_GPIO_RX_DDR, 0x0); + write_reg(UE_REG_GPIO_TX_DDR, 0x0); + + return 0; +} -- cgit v1.2.3 From 9d752805de2020b6a8705c4abfce536620dcb760 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 16 Mar 2011 10:31:52 -0700 Subject: USB zero copy impl: proper cleanup for canceled transfers -- wait for cancel before freeing --- host/lib/transport/libusb1_zero_copy.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 87adece45..b425843fa 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -105,6 +105,12 @@ static void libusb_async_cb(libusb_transfer *lut){ (*static_cast *>(lut->user_data))(); } +//! callback to free transfer upon cancellation +static void cancel_transfer_cb(libusb_transfer *lut) { + if(lut->status == LIBUSB_TRANSFER_CANCELLED) libusb_free_transfer(lut); + else std::cout << "cancel_transfer unexpected status " << lut->status << std::endl; +} + /*********************************************************************** * USB zero_copy device class **********************************************************************/ @@ -190,16 +196,18 @@ public: } ~libusb_zero_copy_impl(void){ - //shutdown the threads - _threads_running = false; - _thread_group.interrupt_all(); - _thread_group.join_all(); - //cancel and free all transfers BOOST_FOREACH(libusb_transfer *lut, _all_luts){ + lut->callback = &cancel_transfer_cb; libusb_cancel_transfer(lut); - libusb_free_transfer(lut); + while(lut->status != LIBUSB_TRANSFER_CANCELLED && lut->status != LIBUSB_TRANSFER_COMPLETED) { + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + } } + //shutdown the threads + _threads_running = false; + _thread_group.interrupt_all(); + _thread_group.join_all(); } managed_recv_buffer::sptr get_recv_buff(double timeout){ -- cgit v1.2.3 From 71e82fb3cd960153603b48d50eae077ff0fb8ace Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 16 Mar 2011 10:34:22 -0700 Subject: E100: fix test clock output enable --- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index e29fe18ce..d18ccdcb9 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -302,7 +302,7 @@ public: _ad9522_regs.out4_cmos_configuration = (enb)? ad9522_regs_t::OUT4_CMOS_CONFIGURATION_A_ON : ad9522_regs_t::OUT4_CMOS_CONFIGURATION_OFF; - this->send_reg(0x0F0); + this->send_reg(0x0F4); this->latch_regs(); } -- cgit v1.2.3 From a57310606c581addc5bafdb9c645eb7b46cb4a79 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 17 Mar 2011 04:41:38 -0700 Subject: usrp_e : Add usrp e1xx gpio test program the usrp e100 utils directory. --- host/usrp_e_utils/CMakeLists.txt | 1 + host/usrp_e_utils/usrp-e-gpio.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index 1ecd2ac46..f3537e542 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -37,6 +37,7 @@ IF(ENABLE_USRP_E_UTILS) usrp-e-timed.c usrp-e-wb-test.cpp usrp-e-debug-pins.c + usrp-e-gpio.c usrp-e-i2c.c usrp-e-spi.c ) diff --git a/host/usrp_e_utils/usrp-e-gpio.c b/host/usrp_e_utils/usrp-e-gpio.c index adef877d3..7e4bc4e13 100644 --- a/host/usrp_e_utils/usrp-e-gpio.c +++ b/host/usrp_e_utils/usrp-e-gpio.c @@ -6,8 +6,8 @@ #include #include -#include "usrp_e.h" -#include "usrp_e_regs.hpp" +#include "linux/usrp_e.h" +#include "usrp_e100_regs.hpp" // Usage: usrp_e_gpio -- cgit v1.2.3 From 31953ec55d038d75cfe9307bd38abdc953904b07 Mon Sep 17 00:00:00 2001 From: Philip Balister Date: Thu, 17 Mar 2011 05:38:32 -0700 Subject: usrp_e : Check packet length received from FPGA in case of corruption. If the packet length in invalid, do not calculate the checksum to avoid segfaulting. --- host/usrp_e_utils/usrp-e-loopback.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/host/usrp_e_utils/usrp-e-loopback.c b/host/usrp_e_utils/usrp-e-loopback.c index 78e2b5d16..0bd3d3100 100644 --- a/host/usrp_e_utils/usrp-e-loopback.c +++ b/host/usrp_e_utils/usrp-e-loopback.c @@ -38,11 +38,15 @@ static int calc_checksum(struct pkt *p) i = 0; sum = 0; - for (i=0; i < p->len; i++) - sum += p->data[i]; - - sum += p->seq_num; - sum += p->len; + if (p->len < 1016) { + for (i=0; i < p->len; i++) + sum += p->data[i]; + + sum += p->seq_num; + sum += p->len; + } else { + printf("Bad packet length = %d received.\n", p->len); + } return sum; } -- cgit v1.2.3 From 843886694f847bb4ddfb838ca6e43094b51edec0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Mar 2011 17:19:29 +0000 Subject: usrp-e100: disabling VCO cal check, its not right, and the warning alarms people --- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index aba630d88..ef6179119 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -425,6 +425,8 @@ private: this->send_reg(0x18); this->latch_regs(); //wait for calibration done: + boost::this_thread::sleep(boost::posix_time::milliseconds(50)); + /* this routine seems to not work, just sleep and return... static const boost::uint8_t addr = 0x01F; for (size_t ms10 = 0; ms10 < 100; ms10++){ boost::uint32_t reg = _iface->read_spi( @@ -436,6 +438,7 @@ private: boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } std::cerr << "USRP-E100 clock control: VCO calibration timeout" << std::endl; + */ } void send_all_regs(void){ -- cgit v1.2.3 From fb65f85e0f915b8587f218bde433210cc574b21f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 17 Mar 2011 17:41:12 -0700 Subject: uhd: whoops, spi convenience functions have 32 bit data --- host/include/uhd/types/serial.hpp | 4 ++-- host/lib/types/serial.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp index 5c6de162b..ef6125933 100644 --- a/host/include/uhd/types/serial.hpp +++ b/host/include/uhd/types/serial.hpp @@ -151,7 +151,7 @@ namespace uhd{ virtual boost::uint32_t read_spi( int which_slave, const spi_config_t &config, - boost::uint16_t data, + boost::uint32_t data, size_t num_bits ); @@ -165,7 +165,7 @@ namespace uhd{ virtual void write_spi( int which_slave, const spi_config_t &config, - boost::uint16_t data, + boost::uint32_t data, size_t num_bits ); }; diff --git a/host/lib/types/serial.cpp b/host/lib/types/serial.cpp index aa1133e72..9e9d32954 100644 --- a/host/lib/types/serial.cpp +++ b/host/lib/types/serial.cpp @@ -58,7 +58,7 @@ byte_vector_t i2c_iface::read_eeprom( boost::uint32_t spi_iface::read_spi( int which_slave, const spi_config_t &config, - boost::uint16_t data, + boost::uint32_t data, size_t num_bits ){ return transact_spi( @@ -69,7 +69,7 @@ boost::uint32_t spi_iface::read_spi( void spi_iface::write_spi( int which_slave, const spi_config_t &config, - boost::uint16_t data, + boost::uint32_t data, size_t num_bits ){ transact_spi( -- cgit v1.2.3 From e460ae41da48a5853898366a403dae9a874a2981 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 17 Mar 2011 17:50:18 -0700 Subject: usrp: dboard iface can inherit from i2c iface --- host/include/uhd/usrp/dboard_iface.hpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/host/include/uhd/usrp/dboard_iface.hpp b/host/include/uhd/usrp/dboard_iface.hpp index c5898365d..1ec0fa1ff 100644 --- a/host/include/uhd/usrp/dboard_iface.hpp +++ b/host/include/uhd/usrp/dboard_iface.hpp @@ -55,7 +55,7 @@ struct UHD_API dboard_iface_special_props_t{ * This interface provides i2c, spi, gpio, atr, aux dac/adc access. * Each mboard should have a specially tailored iface for its dboard. */ -class UHD_API dboard_iface{ +class UHD_API dboard_iface : public uhd::i2c_iface{ public: typedef boost::shared_ptr sptr; typedef dboard_iface_special_props_t special_props_t; @@ -208,23 +208,6 @@ public: */ virtual boost::uint16_t read_gpio(unit_t unit) = 0; - /*! - * Write to an I2C peripheral. - * - * \param addr I2C bus address (7-bits) - * \param bytes the data to write - */ - virtual void write_i2c(boost::uint8_t addr, const byte_vector_t &bytes) = 0; - - /*! - * Read from an I2C peripheral. - * - * \param addr I2C bus address (7-bits) - * \param num_bytes number of bytes to read - * \return the data read if successful, else a zero length string. - */ - virtual byte_vector_t read_i2c(boost::uint8_t addr, size_t num_bytes) = 0; - /*! * Write data to SPI bus peripheral. * -- cgit v1.2.3 From 7a949ffd2be87c0bbf5f733e71dbe81d565f0444 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 6 Mar 2011 12:35:42 +0000 Subject: usrp-e100: reinstate the VCO calibration timeout message --- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index ef6179119..aba630d88 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -425,8 +425,6 @@ private: this->send_reg(0x18); this->latch_regs(); //wait for calibration done: - boost::this_thread::sleep(boost::posix_time::milliseconds(50)); - /* this routine seems to not work, just sleep and return... static const boost::uint8_t addr = 0x01F; for (size_t ms10 = 0; ms10 < 100; ms10++){ boost::uint32_t reg = _iface->read_spi( @@ -438,7 +436,6 @@ private: boost::this_thread::sleep(boost::posix_time::milliseconds(10)); } std::cerr << "USRP-E100 clock control: VCO calibration timeout" << std::endl; - */ } void send_all_regs(void){ -- cgit v1.2.3 From 6fc9a384a7d9aef9457e7f7015431880f6bf91d8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Mar 2011 17:02:11 +0000 Subject: usrp-e100: added module compat num check, made fpga compat constant more obvious --- host/lib/usrp/usrp_e100/usrp_e100_iface.cpp | 11 ++++++++++- host/lib/usrp/usrp_e100/usrp_e100_impl.cpp | 8 ++++---- host/lib/usrp/usrp_e100/usrp_e100_impl.hpp | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp index ec0baf490..55446da63 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.cpp @@ -22,7 +22,7 @@ #include //open, close #include //ioctl structures and constants #include -#include //mutex +#include #include #include #include @@ -109,6 +109,15 @@ public: throw uhd::io_error("Failed to open " + node); } + //check the module compatibility number + int module_compat_num = ::ioctl(_node_fd, USRP_E_GET_COMPAT_NUMBER, NULL); + if (module_compat_num != USRP_E_COMPAT_NUMBER){ + throw uhd::runtime_error(str(boost::format( + "Expected module compatibility number 0x%x, but got 0x%x:\n" + "The module build is not compatible with the host code build." + ) % USRP_E_COMPAT_NUMBER % module_compat_num)); + } + mb_eeprom = mboard_eeprom_t(get_i2c_dev_iface(), mboard_eeprom_t::MAP_E100); } diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp index a120c3303..a8fbe5d69 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.cpp @@ -120,10 +120,10 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){ try{std::ifstream(hash_file_path) >> loaded_hash;}catch(...){} //if not loaded: load the fpga image and write the hash-file - if (fpga_compat_num != USRP_E_COMPAT_NUM or loaded_hash != fpga_hash){ + if (fpga_compat_num != USRP_E_FPGA_COMPAT_NUM or loaded_hash != fpga_hash){ iface.reset(); usrp_e100_load_fpga(usrp_e100_fpga_image); - sleep(1); ///\todo do this better one day. + sleep(1); ///\todo do this better one day. std::cout << boost::format("re-Opening USRP-E on %s") % node << std::endl; iface = usrp_e100_iface::make(node); try{std::ofstream(hash_file_path) << fpga_hash;}catch(...){} @@ -131,11 +131,11 @@ static device::sptr usrp_e100_make(const device_addr_t &device_addr){ //check that the compatibility is correct fpga_compat_num = iface->peek16(UE_REG_MISC_COMPAT); - if (fpga_compat_num != USRP_E_COMPAT_NUM){ + if (fpga_compat_num != USRP_E_FPGA_COMPAT_NUM){ throw uhd::runtime_error(str(boost::format( "Expected fpga compatibility number 0x%x, but got 0x%x:\n" "The fpga build is not compatible with the host code build." - ) % USRP_E_COMPAT_NUM % fpga_compat_num)); + ) % USRP_E_FPGA_COMPAT_NUM % fpga_compat_num)); } return device::sptr(new usrp_e100_impl(iface)); diff --git a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp index 897616320..98117cf26 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_impl.hpp @@ -30,7 +30,7 @@ #ifndef INCLUDED_USRP_E100_IMPL_HPP #define INCLUDED_USRP_E100_IMPL_HPP -static const boost::uint16_t USRP_E_COMPAT_NUM = 0x03; +static const boost::uint16_t USRP_E_FPGA_COMPAT_NUM = 0x03; //! load an fpga image from a bin file into the usrp-e fpga extern void usrp_e100_load_fpga(const std::string &bin_file); -- cgit v1.2.3 From fb2059949e0ad898e745aafbe958dfb2f326b077 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 21 Mar 2011 10:34:16 -0700 Subject: usb: fix callback cast in libusb zero copy under msvc --- host/lib/transport/libusb1_zero_copy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 697944089..9f38ce97b 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -199,7 +199,7 @@ public: ~libusb_zero_copy_impl(void){ //cancel and free all transfers BOOST_FOREACH(libusb_transfer *lut, _all_luts){ - lut->callback = &cancel_transfer_cb; + lut->callback = libusb_transfer_cb_fn(&cancel_transfer_cb); libusb_cancel_transfer(lut); while(lut->status != LIBUSB_TRANSFER_CANCELLED && lut->status != LIBUSB_TRANSFER_COMPLETED) { boost::this_thread::sleep(boost::posix_time::milliseconds(10)); -- cgit v1.2.3 From 2183c502ee556013e543fcb1f2cf66386b8d7288 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 21 Mar 2011 10:44:46 -0700 Subject: uhd: added comments/documentation to clock_config --- host/include/uhd/types/clock_config.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/host/include/uhd/types/clock_config.hpp b/host/include/uhd/types/clock_config.hpp index a72eb63de..7301d43a0 100644 --- a/host/include/uhd/types/clock_config.hpp +++ b/host/include/uhd/types/clock_config.hpp @@ -26,10 +26,17 @@ namespace uhd{ * Clock configuration settings: * The source for the 10MHz reference clock. * The source and polarity for the PPS clock. + * + * Use the convenience functions external() and internal(), + * unless you have a special purpose and cannot use them. */ struct UHD_API clock_config_t{ //------ simple usage --------// + + //! A convenience function to create an external clock configuration static clock_config_t external(void); + + //! A convenience function to create an internal clock configuration static clock_config_t internal(void); //------ advanced usage --------// -- cgit v1.2.3 From 3938de0cfedb4c4ca8b5fdb1ed7137ee32208648 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 21 Mar 2011 11:52:38 -0700 Subject: usrp2: use the discovered mtu to clip the user specified mtu --- host/lib/usrp/usrp2/usrp2_impl.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 96552929a..f42be321b 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -241,14 +241,17 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu); } - std::cout << "mtu recv bytes " << mtu.recv_mtu << std::endl; - std::cout << "mtu send bytes " << mtu.send_mtu << std::endl; - - //use the discovered mtu if not specified by the user - if (not device_addr.has_key("recv_frame_size")) - device_addr["recv_frame_size"] = boost::lexical_cast(mtu.recv_mtu); - if (not device_addr.has_key("send_frame_size")) - device_addr["send_frame_size"] = boost::lexical_cast(mtu.send_mtu); + //use the discovered mtu or clip the users requested mtu + mtu.recv_mtu = std::min(size_t(device_addr.cast("recv_frame_size", 9000)), mtu.recv_mtu); + mtu.send_mtu = std::min(size_t(device_addr.cast("send_frame_size", 9000)), mtu.send_mtu); + + device_addr["recv_frame_size"] = boost::lexical_cast(mtu.recv_mtu); + device_addr["send_frame_size"] = boost::lexical_cast(mtu.send_mtu); + + std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; + std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + + device_args = separate_device_addr(device_addr); //update args for new frame sizes //setup rx otw type _rx_otw_type.width = 16; -- cgit v1.2.3 From a963caab9b6500ecef015fa5c514f2a7ae23046f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 21 Mar 2011 16:40:21 -0700 Subject: uhd: setup cpack components for component based installers --- host/CMakeLists.txt | 2 ++ host/Modules/UHDPackage.cmake | 37 ++++++++++++++++++++++++++++++- host/docs/CMakeLists.txt | 6 ++--- host/examples/CMakeLists.txt | 4 ++-- host/include/uhd/CMakeLists.txt | 1 + host/include/uhd/transport/CMakeLists.txt | 1 + host/include/uhd/types/CMakeLists.txt | 1 + host/include/uhd/usrp/CMakeLists.txt | 3 ++- host/include/uhd/utils/CMakeLists.txt | 1 + host/lib/CMakeLists.txt | 1 + host/tests/CMakeLists.txt | 6 +---- host/utils/CMakeLists.txt | 5 +++-- 12 files changed, 54 insertions(+), 14 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index bbcf34373..590f1b138 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -156,6 +156,7 @@ CONFIGURE_FILE( INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/uhd.pc DESTINATION ${LIBRARY_DIR}/pkgconfig + COMPONENT libraries ) ######################################################################## @@ -166,6 +167,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS DESTINATION ${PKG_DOC_DIR} + COMPONENT libraries ) ######################################################################## diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 2a11d407b..ed705148a 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -19,7 +19,7 @@ INCLUDE(UHDVersion) #sets version information ######################################################################## -# Setup CPack +# Setup CPack General ######################################################################## SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Ettus Research - Universal Hardware Driver") SET(CPACK_PACKAGE_VENDOR "Ettus Research LLC") @@ -29,6 +29,35 @@ SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH}) SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README) SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) + +######################################################################## +# Setup CPack Components +######################################################################## +SET(CPACK_COMPONENT_LIBRARIES_GROUP "Development") +SET(CPACK_COMPONENT_HEADERS_GROUP "Development") +SET(CPACK_COMPONENT_UTILITIES_GROUP "Runtime") +SET(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") +SET(CPACK_COMPONENT_TESTS_GROUP "Runtime") +SET(CPACK_COMPONENT_MANUAL_GROUP "Documentation") +SET(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") + +SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") +SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") +SET(CPACK_COMPONENT_UTILITIES_DISPLAY_NAME "Utilities") +SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples") +SET(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Unit Tests") +SET(CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Manual") +SET(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") + +SET(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) +SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) +SET(CPACK_COMPONENT_TESTS_DEPENDS libraries) + +SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxygen) + +######################################################################## +# Setup CPack Debian +######################################################################## SET(BOOST_MIN_VERSION 1.36) #used in setup for boost STRING(REPLACE "," ", " CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-date-time-dev (>= ${BOOST_MIN_VERSION})," @@ -40,5 +69,11 @@ STRING(REPLACE "," ", " CPACK_DEBIAN_PACKAGE_DEPENDS "libboost-thread-dev (>= ${BOOST_MIN_VERSION})" ) SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") + +######################################################################## +# Setup CPack RPM +######################################################################## SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${BOOST_MIN_VERSION}") + +######################################################################## INCLUDE(CPack) #include after setting vars diff --git a/host/docs/CMakeLists.txt b/host/docs/CMakeLists.txt index c04262b63..1a2738647 100644 --- a/host/docs/CMakeLists.txt +++ b/host/docs/CMakeLists.txt @@ -64,14 +64,14 @@ IF(ENABLE_MANUAL) #make the manual target depend on the html file LIST(APPEND manual_html_files ${htmlfile}) - INSTALL(FILES ${htmlfile} DESTINATION ${PKG_DOC_DIR}/manual/html) + INSTALL(FILES ${htmlfile} DESTINATION ${PKG_DOC_DIR}/manual/html COMPONENT manual) ENDFOREACH(rstfile ${manual_sources}) #make the html manual a build-time dependency ADD_CUSTOM_TARGET(manual_html ALL DEPENDS ${manual_html_files}) ENDIF(ENABLE_MANUAL) -INSTALL(FILES ${manual_sources} DESTINATION ${PKG_DOC_DIR}/manual/rst) +INSTALL(FILES ${manual_sources} DESTINATION ${PKG_DOC_DIR}/manual/rst COMPONENT manual) ######################################################################## # Setup Doxygen @@ -99,5 +99,5 @@ IF(ENABLE_DOXYGEN) #make the doxygen generation a built-time dependency ADD_CUSTOM_TARGET(doxygen_docs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN}) - INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} DESTINATION ${PKG_DOC_DIR}) + INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR_DOXYGEN} DESTINATION ${PKG_DOC_DIR} COMPONENT doxygen) ENDIF(ENABLE_DOXYGEN) diff --git a/host/examples/CMakeLists.txt b/host/examples/CMakeLists.txt index 44ed55380..1bb037d16 100644 --- a/host/examples/CMakeLists.txt +++ b/host/examples/CMakeLists.txt @@ -37,7 +37,7 @@ FOREACH(example_source ${example_sources}) GET_FILENAME_COMPONENT(example_name ${example_source} NAME_WE) ADD_EXECUTABLE(${example_name} ${example_source}) TARGET_LINK_LIBRARIES(${example_name} uhd) - INSTALL(TARGETS ${example_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/examples) + INSTALL(TARGETS ${example_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/examples COMPONENT examples) ENDFOREACH(example_source) ######################################################################## @@ -49,5 +49,5 @@ IF(CURSES_FOUND) INCLUDE_DIRECTORIES(${CURSES_INCLUDE_DIR}) ADD_EXECUTABLE(rx_ascii_art_dft rx_ascii_art_dft.cpp) TARGET_LINK_LIBRARIES(rx_ascii_art_dft uhd ${CURSES_LIBRARIES}) - INSTALL(TARGETS rx_ascii_art_dft RUNTIME DESTINATION ${PKG_DATA_DIR}/examples) + INSTALL(TARGETS rx_ascii_art_dft RUNTIME DESTINATION ${PKG_DATA_DIR}/examples COMPONENT examples) ENDIF(CURSES_FOUND) diff --git a/host/include/uhd/CMakeLists.txt b/host/include/uhd/CMakeLists.txt index db755511e..74dc4a7d6 100644 --- a/host/include/uhd/CMakeLists.txt +++ b/host/include/uhd/CMakeLists.txt @@ -29,4 +29,5 @@ INSTALL(FILES version.hpp wax.hpp DESTINATION ${INCLUDE_DIR}/uhd + COMPONENT headers ) diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt index 14ca82226..bf7497ee7 100644 --- a/host/include/uhd/transport/CMakeLists.txt +++ b/host/include/uhd/transport/CMakeLists.txt @@ -29,4 +29,5 @@ INSTALL(FILES vrt_if_packet.hpp zero_copy.hpp DESTINATION ${INCLUDE_DIR}/uhd/transport + COMPONENT headers ) diff --git a/host/include/uhd/types/CMakeLists.txt b/host/include/uhd/types/CMakeLists.txt index c856e5568..0971ca472 100644 --- a/host/include/uhd/types/CMakeLists.txt +++ b/host/include/uhd/types/CMakeLists.txt @@ -34,4 +34,5 @@ INSTALL(FILES tune_request.hpp tune_result.hpp DESTINATION ${INCLUDE_DIR}/uhd/types + COMPONENT headers ) diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index 59a1302af..e441433fd 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,4 +46,5 @@ INSTALL(FILES mboard_iface.hpp DESTINATION ${INCLUDE_DIR}/uhd/usrp + COMPONENT headers ) diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt index 70f724c2d..71808ac98 100644 --- a/host/include/uhd/utils/CMakeLists.txt +++ b/host/include/uhd/utils/CMakeLists.txt @@ -31,4 +31,5 @@ INSTALL(FILES thread_priority.hpp warning.hpp DESTINATION ${INCLUDE_DIR}/uhd/utils + COMPONENT headers ) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index dbfa234b6..a30b380c4 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -121,4 +121,5 @@ INSTALL(TARGETS uhd LIBRARY DESTINATION ${LIBRARY_DIR} # .so file ARCHIVE DESTINATION ${LIBRARY_DIR} # .lib file RUNTIME DESTINATION ${LIBRARY_DIR} # .dll file + COMPONENT libraries ) diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index 79b20cd47..821b2eb9e 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -44,7 +44,7 @@ FOREACH(test_source ${test_sources}) ADD_EXECUTABLE(${test_name} ${test_source}) TARGET_LINK_LIBRARIES(${test_name} uhd) ADD_TEST(${test_name} ${test_name}) - INSTALL(TARGETS ${test_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/tests) + INSTALL(TARGETS ${test_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/tests COMPONENT tests) ENDFOREACH(test_source) ######################################################################## @@ -52,7 +52,3 @@ ENDFOREACH(test_source) ######################################################################## ADD_LIBRARY(module_test MODULE module_test.cpp) TARGET_LINK_LIBRARIES(module_test uhd) - -INSTALL(TARGETS - RUNTIME DESTINATION ${PKG_DATA_DIR}/tests -) diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 53527c03d..3c18324a5 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(util_source ${util_runtime_sources}) GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE) ADD_EXECUTABLE(${util_name} ${util_source}) TARGET_LINK_LIBRARIES(${util_name} uhd) - INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${RUNTIME_DIR}) + INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${RUNTIME_DIR} COMPONENT utilities) ENDFOREACH(util_source) ######################################################################## @@ -50,7 +50,7 @@ FOREACH(util_source ${util_share_sources}) GET_FILENAME_COMPONENT(util_name ${util_source} NAME_WE) ADD_EXECUTABLE(${util_name} ${util_source}) TARGET_LINK_LIBRARIES(${util_name} uhd) - INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/utils) + INSTALL(TARGETS ${util_name} RUNTIME DESTINATION ${PKG_DATA_DIR}/utils COMPONENT utilities) ENDFOREACH(util_source) IF(ENABLE_USRP2) @@ -60,5 +60,6 @@ IF(ENABLE_USRP2) usrp2_card_burner_gui.py usrp_n2xx_net_burner.py DESTINATION ${PKG_DATA_DIR}/utils + COMPONENT utilities ) ENDIF(ENABLE_USRP2) -- cgit v1.2.3 From 55b4ca73b44735523e5ab3348735a64cbf19cf30 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 22 Mar 2011 10:37:33 -0700 Subject: uhd: setup UHD_VERSION and CPACK_PACKAGE_FILE_NAME --- host/Modules/UHDPackage.cmake | 8 ++++++++ host/Modules/UHDVersion.cmake | 1 + images/CMakeLists.txt | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index ed705148a..6e0af31ba 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -18,6 +18,14 @@ ######################################################################## INCLUDE(UHDVersion) #sets version information +######################################################################## +# Setup package file name +######################################################################## +SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}") +IF(DEFINED UHD_PACKAGE_SUFFIX) #append optional suffix (usually system type) + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${UHD_PACKAGE_SUFFIX}) +ENDIF(DEFINED UHD_PACKAGE_SUFFIX) + ######################################################################## # Setup CPack General ######################################################################## diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index b0b2ae475..0061dffbc 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -24,6 +24,7 @@ INCLUDE(UHDPython) #requires python for parsing SET(UHD_VERSION_MAJOR 003) #API compatibility number SET(UHD_VERSION_MINOR 0) #Timestamp of git commit SET(UHD_VERSION_PATCH 0) #Short hash of git commit +SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}.${UHD_VERSION_PATCH}") ######################################################################## # Find GIT to get repo information diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index baac333ea..f93b28ca4 100644 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -32,7 +32,7 @@ SET(CPACK_PACKAGE_CONTACT "support@ettus.com") SET(CPACK_PACKAGE_VERSION_MAJOR ${UHD_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH}) -SET(CPACK_PACKAGE_FILE_NAME "UHD-images-${UHD_VERSION_MAJOR}-${UHD_VERSION_MINOR}-${UHD_VERSION_PATCH}") +SET(CPACK_PACKAGE_FILE_NAME "UHD-images-${UHD_VERSION}") SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") INCLUDE(CPack) #include after setting vars MESSAGE(STATUS "Version: ${CPACK_PACKAGE_VERSION}") -- cgit v1.2.3 From 52d66cca9d4930f49dd95696b2075d92662bc85e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 22 Mar 2011 11:57:44 -0700 Subject: uhd: work on debian package requirements in cpack setup --- host/CMakeLists.txt | 4 ++-- host/Modules/UHDPackage.cmake | 15 +++------------ 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 590f1b138..4160e8186 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -110,8 +110,8 @@ IF(MSVC) ENDIF(BOOST_ALL_DYN_LINK) ENDIF(MSVC) -SET(Boost_ADDITIONAL_VERSIONS "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44") -FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) +SET(Boost_ADDITIONAL_VERSIONS "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44" "1.45.0" "1.45" "1.46.0" "1.46") +FIND_PACKAGE(Boost 1.36 COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 6e0af31ba..9c0aa0de8 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -23,7 +23,7 @@ INCLUDE(UHDVersion) #sets version information ######################################################################## SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}") IF(DEFINED UHD_PACKAGE_SUFFIX) #append optional suffix (usually system type) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${UHD_PACKAGE_SUFFIX}) + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${UHD_PACKAGE_SUFFIX}") ENDIF(DEFINED UHD_PACKAGE_SUFFIX) ######################################################################## @@ -66,22 +66,13 @@ SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxyg ######################################################################## # Setup CPack Debian ######################################################################## -SET(BOOST_MIN_VERSION 1.36) #used in setup for boost -STRING(REPLACE "," ", " CPACK_DEBIAN_PACKAGE_DEPENDS - "libboost-date-time-dev (>= ${BOOST_MIN_VERSION})," - "libboost-filesystem-dev (>= ${BOOST_MIN_VERSION})," - "libboost-program-options-dev (>= ${BOOST_MIN_VERSION})," - "libboost-regex-dev (>= ${BOOST_MIN_VERSION})," - "libboost-system-dev (>= ${BOOST_MIN_VERSION})," - "libboost-test-dev (>= ${BOOST_MIN_VERSION})," - "libboost-thread-dev (>= ${BOOST_MIN_VERSION})" -) +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libusb-1.0-0, libboost-dev") SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") ######################################################################## # Setup CPack RPM ######################################################################## -SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${BOOST_MIN_VERSION}") +SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel") ######################################################################## INCLUDE(CPack) #include after setting vars -- cgit v1.2.3 From c7bd55e2e117173b643113282507ec3d4b227377 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 22 Mar 2011 12:10:59 -0700 Subject: uhd: added libusb1 to CPACK_RPM_PACKAGE_REQUIRES --- host/Modules/UHDPackage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 9c0aa0de8..a4da03177 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -72,7 +72,7 @@ SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") ######################################################################## # Setup CPack RPM ######################################################################## -SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel") +SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, libusb1") ######################################################################## INCLUDE(CPack) #include after setting vars -- cgit v1.2.3 From 585b0455e8176d8e1abc2722f2a0e56eb89e1c58 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 22 Mar 2011 19:21:59 -0700 Subject: uhd: try to be smart when setting up cpack when UHD_PACKAGE_MODE=AUTO --- host/Modules/UHDPackage.cmake | 36 ++++++++++++++++++++++++++++++++---- host/Modules/UHDVersion.cmake | 4 +++- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index a4da03177..03483e042 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -21,10 +21,38 @@ INCLUDE(UHDVersion) #sets version information ######################################################################## # Setup package file name ######################################################################## -SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}") -IF(DEFINED UHD_PACKAGE_SUFFIX) #append optional suffix (usually system type) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-${UHD_PACKAGE_SUFFIX}") -ENDIF(DEFINED UHD_PACKAGE_SUFFIX) +IF(UHD_PACKAGE_MODE STREQUAL AUTO) + FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) + FIND_PROGRAM(UNAME_EXECUTABLE uname) + IF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) + + #extract system information by executing the commands + EXECUTE_PROCESS( + COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id + OUTPUT_VARIABLE _os_name OUTPUT_STRIP_TRAILING_WHITESPACE + ) + EXECUTE_PROCESS( + COMMAND ${LSB_RELEASE_EXECUTABLE} --short --release + OUTPUT_VARIABLE _os_version OUTPUT_STRIP_TRAILING_WHITESPACE + ) + EXECUTE_PROCESS( + COMMAND ${UNAME_EXECUTABLE} --machine + OUTPUT_VARIABLE _machine OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + #set generator type for recognized systems + IF(${_os_name} STREQUAL Ubuntu) + SET(CPACK_GENERATOR DEB) + ENDIF() + IF(${_os_name} STREQUAL Fedora) + SET(CPACK_GENERATOR RPM) + ENDIF() + + #set a more sensible package name for this system + SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}-${_os_name}-${_os_version}-${_machine}") + + ENDIF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) +ENDIF(UHD_PACKAGE_MODE STREQUAL AUTO) ######################################################################## # Setup CPack General diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index 0061dffbc..9b20bb98a 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -24,7 +24,6 @@ INCLUDE(UHDPython) #requires python for parsing SET(UHD_VERSION_MAJOR 003) #API compatibility number SET(UHD_VERSION_MINOR 0) #Timestamp of git commit SET(UHD_VERSION_PATCH 0) #Short hash of git commit -SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}.${UHD_VERSION_PATCH}") ######################################################################## # Find GIT to get repo information @@ -61,3 +60,6 @@ IF(GIT_FOUND) ) SET(UHD_VERSION_PATCH ${_git_rev}) ENDIF(GIT_FOUND) + +######################################################################## +SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}.${UHD_VERSION_PATCH}") -- cgit v1.2.3 From 95b966a599c0030921dc6b530ca8c94633d905f6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 23 Mar 2011 18:48:30 -0700 Subject: uhd: update copyright headers with automated script --- host/Modules/UHDComponent.cmake | 2 +- host/Modules/UHDPackage.cmake | 2 +- host/Modules/UHDPython.cmake | 2 +- host/include/uhd/types/serial.hpp | 2 +- host/include/uhd/types/time_spec.hpp | 2 +- host/include/uhd/usrp/gps_ctrl.hpp | 2 +- host/include/uhd/usrp/tune_helper.hpp | 2 +- host/lib/device.cpp | 2 +- host/lib/ic_reg_maps/common.py | 2 +- host/lib/ic_reg_maps/gen_ad9522_regs.py | 2 +- host/lib/transport/if_addrs.cpp | 2 +- host/lib/usrp/CMakeLists.txt | 2 +- host/lib/usrp/dboard_base.cpp | 2 +- host/lib/usrp/dsp_utils.cpp | 2 +- host/lib/usrp/gps_ctrl.cpp | 2 +- host/lib/usrp/tune_helper.cpp | 2 +- host/lib/usrp/usrp1/clock_ctrl.hpp | 2 +- host/lib/usrp/usrp1/usrp1_ctrl.cpp | 2 +- host/lib/usrp/usrp1/usrp1_ctrl.hpp | 2 +- host/lib/usrp/usrp1/usrp1_iface.cpp | 2 +- host/lib/usrp/usrp1/usrp1_iface.hpp | 2 +- host/lib/usrp/usrp2/CMakeLists.txt | 2 +- host/lib/usrp/usrp2/clock_ctrl.cpp | 2 +- host/lib/usrp/usrp2/usrp2_iface.hpp | 2 +- host/lib/usrp/usrp_e100/clock_ctrl.hpp | 2 +- host/lib/usrp/usrp_e100/usrp_e100_iface.hpp | 2 +- host/lib/utils/images.cpp | 2 +- host/tests/addr_test.cpp | 2 +- host/tests/byteswap_test.cpp | 2 +- host/tests/dict_test.cpp | 2 +- host/tests/module_test.cpp | 2 +- host/tests/subdev_spec_test.cpp | 2 +- host/tests/time_spec_test.cpp | 2 +- host/tests/tune_helper_test.cpp | 2 +- host/tests/vrt_test.cpp | 2 +- host/tests/warning_test.cpp | 2 +- 36 files changed, 36 insertions(+), 36 deletions(-) diff --git a/host/Modules/UHDComponent.cmake b/host/Modules/UHDComponent.cmake index 4ea55bbb9..52b7450d5 100644 --- a/host/Modules/UHDComponent.cmake +++ b/host/Modules/UHDComponent.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 03483e042..8ca8995cd 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/Modules/UHDPython.cmake b/host/Modules/UHDPython.cmake index 345e0187d..90a778609 100644 --- a/host/Modules/UHDPython.cmake +++ b/host/Modules/UHDPython.cmake @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/include/uhd/types/serial.hpp b/host/include/uhd/types/serial.hpp index ef6125933..8281fd3ec 100644 --- a/host/include/uhd/types/serial.hpp +++ b/host/include/uhd/types/serial.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/include/uhd/types/time_spec.hpp b/host/include/uhd/types/time_spec.hpp index 2046fbd3f..02de20ea1 100644 --- a/host/include/uhd/types/time_spec.hpp +++ b/host/include/uhd/types/time_spec.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/include/uhd/usrp/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp index 74f984ee0..21d400b3b 100644 --- a/host/include/uhd/usrp/gps_ctrl.hpp +++ b/host/include/uhd/usrp/gps_ctrl.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/include/uhd/usrp/tune_helper.hpp b/host/include/uhd/usrp/tune_helper.hpp index e97ab0298..0d468a4e2 100644 --- a/host/include/uhd/usrp/tune_helper.hpp +++ b/host/include/uhd/usrp/tune_helper.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/device.cpp b/host/lib/device.cpp index 0002bee6e..1b3daa103 100644 --- a/host/lib/device.cpp +++ b/host/lib/device.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/ic_reg_maps/common.py b/host/lib/ic_reg_maps/common.py index a509936b4..24f5bf8be 100644 --- a/host/lib/ic_reg_maps/common.py +++ b/host/lib/ic_reg_maps/common.py @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/lib/ic_reg_maps/gen_ad9522_regs.py b/host/lib/ic_reg_maps/gen_ad9522_regs.py index 86605c34a..1512da811 100755 --- a/host/lib/ic_reg_maps/gen_ad9522_regs.py +++ b/host/lib/ic_reg_maps/gen_ad9522_regs.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/lib/transport/if_addrs.cpp b/host/lib/transport/if_addrs.cpp index b7c8ad844..83a1ee56f 100644 --- a/host/lib/transport/if_addrs.cpp +++ b/host/lib/transport/if_addrs.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index 59dabbd58..018beb417 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/dboard_base.cpp b/host/lib/usrp/dboard_base.cpp index 999dd9ffc..e14c9d144 100644 --- a/host/lib/usrp/dboard_base.cpp +++ b/host/lib/usrp/dboard_base.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/dsp_utils.cpp b/host/lib/usrp/dsp_utils.cpp index a3a557060..2686e895b 100644 --- a/host/lib/usrp/dsp_utils.cpp +++ b/host/lib/usrp/dsp_utils.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index e0ab6de90..ff8e9cee6 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp index ced80c187..9637301ad 100644 --- a/host/lib/usrp/tune_helper.cpp +++ b/host/lib/usrp/tune_helper.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp1/clock_ctrl.hpp b/host/lib/usrp/usrp1/clock_ctrl.hpp index 645472f02..339d547e6 100644 --- a/host/lib/usrp/usrp1/clock_ctrl.hpp +++ b/host/lib/usrp/usrp1/clock_ctrl.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.cpp b/host/lib/usrp/usrp1/usrp1_ctrl.cpp index 3fa6cb8b7..22e9fd1ce 100644 --- a/host/lib/usrp/usrp1/usrp1_ctrl.cpp +++ b/host/lib/usrp/usrp1/usrp1_ctrl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp1/usrp1_ctrl.hpp b/host/lib/usrp/usrp1/usrp1_ctrl.hpp index ee68f8401..970ca2951 100644 --- a/host/lib/usrp/usrp1/usrp1_ctrl.hpp +++ b/host/lib/usrp/usrp1/usrp1_ctrl.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index 0c37610ce..ea7c1cea5 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp1/usrp1_iface.hpp b/host/lib/usrp/usrp1/usrp1_iface.hpp index fdb7464ce..2ebcdbacc 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.hpp +++ b/host/lib/usrp/usrp1/usrp1_iface.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index e8811a8fb..49be9ac7d 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp2/clock_ctrl.cpp b/host/lib/usrp/usrp2/clock_ctrl.cpp index abda53bf2..7572ed6b1 100644 --- a/host/lib/usrp/usrp2/clock_ctrl.cpp +++ b/host/lib/usrp/usrp2/clock_ctrl.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index df53ec66a..08f3955f1 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.hpp b/host/lib/usrp/usrp_e100/clock_ctrl.hpp index 1f9960ce4..623fbc73b 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.hpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp index cb0ca2dd4..d9fe96db7 100644 --- a/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp +++ b/host/lib/usrp/usrp_e100/usrp_e100_iface.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 2b6c02772..a124cc208 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/addr_test.cpp b/host/tests/addr_test.cpp index d4b45aa1a..01a7ab607 100644 --- a/host/tests/addr_test.cpp +++ b/host/tests/addr_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/byteswap_test.cpp b/host/tests/byteswap_test.cpp index 3d50c9bfa..7d94bbfba 100644 --- a/host/tests/byteswap_test.cpp +++ b/host/tests/byteswap_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/dict_test.cpp b/host/tests/dict_test.cpp index 0501a7878..7b388d090 100644 --- a/host/tests/dict_test.cpp +++ b/host/tests/dict_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/module_test.cpp b/host/tests/module_test.cpp index 47a0e1af9..af2f749a7 100644 --- a/host/tests/module_test.cpp +++ b/host/tests/module_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/subdev_spec_test.cpp b/host/tests/subdev_spec_test.cpp index 8817d5eee..aa0b9a119 100644 --- a/host/tests/subdev_spec_test.cpp +++ b/host/tests/subdev_spec_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/time_spec_test.cpp b/host/tests/time_spec_test.cpp index 070392f93..e57bbced1 100644 --- a/host/tests/time_spec_test.cpp +++ b/host/tests/time_spec_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/tune_helper_test.cpp b/host/tests/tune_helper_test.cpp index aabaaaf6e..51d216825 100644 --- a/host/tests/tune_helper_test.cpp +++ b/host/tests/tune_helper_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/vrt_test.cpp b/host/tests/vrt_test.cpp index 9e131a10b..066f1493b 100644 --- a/host/tests/vrt_test.cpp +++ b/host/tests/vrt_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by diff --git a/host/tests/warning_test.cpp b/host/tests/warning_test.cpp index db19955de..3394f84d4 100644 --- a/host/tests/warning_test.cpp +++ b/host/tests/warning_test.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From a82830bf030c01d40226900ab0cb87c2811f82d5 Mon Sep 17 00:00:00 2001 From: Matt Ettus Date: Wed, 23 Mar 2011 19:35:29 -0700 Subject: u2p: N200 Makefile --- usrp2/top/u2plus/Makefile.N200 | 98 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 usrp2/top/u2plus/Makefile.N200 diff --git a/usrp2/top/u2plus/Makefile.N200 b/usrp2/top/u2plus/Makefile.N200 new file mode 100644 index 000000000..9175f9304 --- /dev/null +++ b/usrp2/top/u2plus/Makefile.N200 @@ -0,0 +1,98 @@ +# +# Copyright 2008 Ettus Research LLC +# + +################################################## +# Project Setup +################################################## +TOP_MODULE = u2plus +BUILD_DIR = $(abspath build$(ISE)-N200) + +################################################## +# Include other makefiles +################################################## + +include ../Makefile.common +include ../../fifo/Makefile.srcs +include ../../control_lib/Makefile.srcs +include ../../sdr_lib/Makefile.srcs +include ../../serdes/Makefile.srcs +include ../../simple_gemac/Makefile.srcs +include ../../timing/Makefile.srcs +include ../../opencores/Makefile.srcs +include ../../vrt/Makefile.srcs +include ../../udp/Makefile.srcs +include ../../coregen/Makefile.srcs +include ../../extramfifo/Makefile.srcs + + +################################################## +# Project Properties +################################################## +export PROJECT_PROPERTIES := \ +family "Spartan-3A DSP" \ +device xc3sd1800a \ +package fg676 \ +speed -5 \ +top_level_module_type "HDL" \ +synthesis_tool "XST (VHDL/Verilog)" \ +simulator "ISE Simulator (VHDL/Verilog)" \ +"Preferred Language" "Verilog" \ +"Enable Message Filtering" FALSE \ +"Display Incremental Messages" FALSE + +################################################## +# Sources +################################################## +TOP_SRCS = \ +u2plus_core.v \ +u2plus.v \ +u2plus.ucf + +SOURCES = $(abspath $(TOP_SRCS)) $(FIFO_SRCS) \ +$(CONTROL_LIB_SRCS) $(SDR_LIB_SRCS) $(SERDES_SRCS) \ +$(SIMPLE_GEMAC_SRCS) $(TIMING_SRCS) $(OPENCORES_SRCS) \ +$(VRT_SRCS) $(UDP_SRCS) $(COREGEN_SRCS) $(EXTRAM_SRCS) + +################################################## +# Process Properties +################################################## +SYNTHESIZE_PROPERTIES = \ +"Number of Clock Buffers" 8 \ +"Pack I/O Registers into IOBs" Yes \ +"Optimization Effort" High \ +"Optimize Instantiated Primitives" TRUE \ +"Register Balancing" Yes \ +"Use Clock Enable" Auto \ +"Use Synchronous Reset" Auto \ +"Use Synchronous Set" Auto + +TRANSLATE_PROPERTIES = \ +"Macro Search Path" "$(shell pwd)/../../coregen/" + +MAP_PROPERTIES = \ +"Allow Logic Optimization Across Hierarchy" TRUE \ +"Map to Input Functions" 4 \ +"Optimization Strategy (Cover Mode)" Speed \ +"Pack I/O Registers/Latches into IOBs" "For Inputs and Outputs" \ +"Perform Timing-Driven Packing and Placement" TRUE \ +"Map Effort Level" High \ +"Extra Effort" Normal \ +"Combinatorial Logic Optimization" TRUE \ +"Register Duplication" TRUE + +PLACE_ROUTE_PROPERTIES = \ +"Place & Route Effort Level (Overall)" High + +STATIC_TIMING_PROPERTIES = \ +"Number of Paths in Error/Verbose Report" 10 \ +"Report Type" "Error Report" + +GEN_PROG_FILE_PROPERTIES = \ +"Configuration Rate" 6 \ +"Create Binary Configuration File" TRUE \ +"Done (Output Events)" 5 \ +"Enable Bitstream Compression" TRUE \ +"Enable Outputs (Output Events)" 6 + +SIM_MODEL_PROPERTIES = "" -- cgit v1.2.3 From ed020d7698994070edd1d6f6584e90ea3df3e0b6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Mar 2011 11:50:55 -0700 Subject: uhd: added USRP-N200 build support to images Makefile --- images/Makefile | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/images/Makefile b/images/Makefile index cfc783ee4..652b127d8 100644 --- a/images/Makefile +++ b/images/Makefile @@ -90,16 +90,18 @@ ifdef HAS_ZPU_GCC _usrp2_fw_dir = $(TOP_FW_DIR)/zpu _usrp2_fw_bin = $(BUILT_IMAGES_DIR)/usrp2_fw.bin -_usrp_n2xx_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n2xx_fw.bin -IMAGES_LIST += $(_usrp2_fw_bin) +_usrp_n200_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n200_fw.bin +_usrp_n210_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n210_fw.bin +IMAGES_LIST += $(_usrp2_fw_bin) $(_usrp_n200_fw_bin) $(_usrp_n210_fw_bin) -$(_usrp2_fw_bin) $(_usrp_n2xx_fw_bin): $(GLOBAL_DEPS) +$(_usrp2_fw_bin) $(_usrp_n200_fw_bin) $(_usrp_n210_fw_bin): $(GLOBAL_DEPS) cd $(_usrp2_fw_dir) && rm -rf build cd $(_usrp2_fw_dir) && mkdir build cd $(_usrp2_fw_dir)/build && cmake ../ cd $(_usrp2_fw_dir)/build && make cp $(_usrp2_fw_dir)/build/usrp2/usrp2_txrx_uhd.bin $(_usrp2_fw_bin) - cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n2xx_fw_bin) + cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n200_fw_bin) + cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n210_fw_bin) endif @@ -119,6 +121,22 @@ $(_usrp2_fpga_bin): $(GLOBAL_DEPS) endif +######################################################################## +# USRP-N200 fpga +######################################################################## +ifdef HAS_XTCLSH + +_usrp_n200_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u2plus +_usrp_n200_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n200_fpga.bin +IMAGES_LIST += $(_usrp_n210_fpga_bin) + +$(_usrp_n200_fpga_bin): $(GLOBAL_DEPS) + cd $(_usrp_n200_fpga_dir) && make -f Makefile.N200 clean + cd $(_usrp_n200_fpga_dir) && make -f Makefile.N200 bin + cp $(_usrp_n200_fpga_dir)/build-N200/u2plus.bin $@ + +endif + ######################################################################## # USRP-N210 fpga ######################################################################## -- cgit v1.2.3 From 8a14b6c26f88aadf9d077798a7888badfde95587 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Mar 2011 13:42:53 -0700 Subject: usrp2: modified firmware build rules to chain the dependencies (better for make -j4) --- images/Makefile | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/images/Makefile b/images/Makefile index 652b127d8..cadf4b71f 100644 --- a/images/Makefile +++ b/images/Makefile @@ -94,14 +94,18 @@ _usrp_n200_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n200_fw.bin _usrp_n210_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n210_fw.bin IMAGES_LIST += $(_usrp2_fw_bin) $(_usrp_n200_fw_bin) $(_usrp_n210_fw_bin) -$(_usrp2_fw_bin) $(_usrp_n200_fw_bin) $(_usrp_n210_fw_bin): $(GLOBAL_DEPS) +$(_usrp2_fw_bin): $(GLOBAL_DEPS) cd $(_usrp2_fw_dir) && rm -rf build cd $(_usrp2_fw_dir) && mkdir build cd $(_usrp2_fw_dir)/build && cmake ../ cd $(_usrp2_fw_dir)/build && make - cp $(_usrp2_fw_dir)/build/usrp2/usrp2_txrx_uhd.bin $(_usrp2_fw_bin) - cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n200_fw_bin) - cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $(_usrp_n210_fw_bin) + cp $(_usrp2_fw_dir)/build/usrp2/usrp2_txrx_uhd.bin $@ + +$(_usrp_n200_fw_bin): $(_usrp2_fw_bin) + cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $@ + +$(_usrp_n210_fw_bin): $(_usrp2_fw_bin) + cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $@ endif -- cgit v1.2.3 From 2249acd9f97e969f619fa87cb206fc9392b9b5fe Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Mar 2011 15:04:23 -0700 Subject: uhd: work on mac osx packaging Renamed README type files to have .txt extension (needed for CPACK_RESOURCE_FILE_*). Tweaks to the cpack setup on CPACK_RESOURCE_FILE_* and handling for when UHD_PACKAGE_MODE==AUTO. As of this commit, the mac packages do not contain the .dylib files (do not know why yet). --- host/AUTHORS | 30 ------------------------------ host/AUTHORS.txt | 40 ++++++++++++++++++++++++++++++++++++++++ host/CMakeLists.txt | 6 +++--- host/LICENSE | 12 ------------ host/LICENSE.txt | 12 ++++++++++++ host/Modules/UHDPackage.cmake | 12 ++++++++++-- host/README | 37 ------------------------------------- host/README.txt | 37 +++++++++++++++++++++++++++++++++++++ 8 files changed, 102 insertions(+), 84 deletions(-) delete mode 100644 host/AUTHORS create mode 100644 host/AUTHORS.txt delete mode 100644 host/LICENSE create mode 100644 host/LICENSE.txt delete mode 100644 host/README create mode 100644 host/README.txt diff --git a/host/AUTHORS b/host/AUTHORS deleted file mode 100644 index 512d4752e..000000000 --- a/host/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -Matt Ettus - matt@ettus.com - USRP1 FPGA code - USRP2 FPGA code - -Josh Blum - josh@ettus.com - driver framework - USRP2 firmware - USRP2 host code - Basic/LF host code - XCVR2450 host code - RFX Series host code - -Jason Abele - jason@ettus.com - RFX Series host code - WBX host code - -Eric Blossom - eb@comsec.com - USRP1 firmware - USRP2 firmware - -Tom Tsou - ttsou@vt.edu - UHD-USB framework - LIBUSB host code - USRP1 host code - USRP1 firmware - -Nick Foster - nick@ettus.com - LIBUSB host code - USRP1 host code - TVRX host code diff --git a/host/AUTHORS.txt b/host/AUTHORS.txt new file mode 100644 index 000000000..44b7516cd --- /dev/null +++ b/host/AUTHORS.txt @@ -0,0 +1,40 @@ +Matt Ettus - matt@ettus.com + USRP1 FPGA code + USRP2/N200 FPGA code + USRP-E100 FPGA code + +Josh Blum - josh@ettus.com + driver framework + USRP2/N200 firmware + USRP2/N200 host code + USRP-E100 host code + Basic/LF host code + XCVR2450 host code + RFX Series host code + +Jason Abele - jason@ettus.com + RFX Series host code + WBX host code + DBSRX host code + DBSRX2 host code + +Eric Blossom - eb@comsec.com + USRP1 firmware + USRP2 firmware + +Tom Tsou - ttsou@vt.edu + UHD-USB framework + LIBUSB host code + USRP1 host code + USRP1 firmware + +Nick Foster - nick@ettus.com + LIBUSB host code + USRP1 host code + TVRX host code + USRP-N200 firmware + USRP-N200 host code + +Philip Balister - philip@opensdr.com + USRP-E100 kernel module + USRP-E100 utilities diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 4160e8186..8516da401 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -163,9 +163,9 @@ INSTALL( # Install Package Docs ######################################################################## INSTALL(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/README - ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE - ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS + ${CMAKE_CURRENT_SOURCE_DIR}/README.txt + ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt + ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS.txt DESTINATION ${PKG_DOC_DIR} COMPONENT libraries ) diff --git a/host/LICENSE b/host/LICENSE deleted file mode 100644 index 9aa03b39b..000000000 --- a/host/LICENSE +++ /dev/null @@ -1,12 +0,0 @@ -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . diff --git a/host/LICENSE.txt b/host/LICENSE.txt new file mode 100644 index 000000000..9aa03b39b --- /dev/null +++ b/host/LICENSE.txt @@ -0,0 +1,12 @@ +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 8ca8995cd..65897ceef 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -52,6 +52,13 @@ IF(UHD_PACKAGE_MODE STREQUAL AUTO) SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}-${_os_name}-${_os_version}-${_machine}") ENDIF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) + + IF(APPLE) + SET(CPACK_GENERATOR PackageMaker) + ELSEIF(WIN32) + SET(CPACK_GENERATOR NSIS) + ENDIF() + ENDIF(UHD_PACKAGE_MODE STREQUAL AUTO) ######################################################################## @@ -63,8 +70,9 @@ SET(CPACK_PACKAGE_CONTACT "support@ettus.com") SET(CPACK_PACKAGE_VERSION_MAJOR ${UHD_VERSION_MAJOR}) SET(CPACK_PACKAGE_VERSION_MINOR ${UHD_VERSION_MINOR}) SET(CPACK_PACKAGE_VERSION_PATCH ${UHD_VERSION_PATCH}) -SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/README) -SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE) +SET(CPACK_RESOURCE_FILE_WELCOME ${CMAKE_SOURCE_DIR}/README.txt) +SET(CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/AUTHORS.txt) +SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/LICENSE.txt) ######################################################################## # Setup CPack Components diff --git a/host/README b/host/README deleted file mode 100644 index f3dcde53d..000000000 --- a/host/README +++ /dev/null @@ -1,37 +0,0 @@ -######################################################################## -# Ettus Research - Universal Hardware Driver -######################################################################## -The hardware driver for Ettus Research products. - -######################################################################## -# Supported USRP Motherboards -######################################################################## -USRP1 -USRP2 -USRP-N200 -USRP-N210 -USRP-E100 - -######################################################################## -# Supported USRP Daughterboards -######################################################################## -Basic RX -Basic TX -LF RX -LF TX -RFX Series -XCVR 2450 -WBX Series -DBSRX -DBSRX2 -TVRX - -######################################################################## -# Documentation -######################################################################## -Online documentation available at: -http://ettus-apps.sourcerepo.com/redmine/ettus/projects/uhd/wiki/ - -The build system can generate the html for the manual and Doxygen. -Docutils and Doxygen are required to build the html docs. -See the docs directory for the manual source (reStructuredText). diff --git a/host/README.txt b/host/README.txt new file mode 100644 index 000000000..b510493d5 --- /dev/null +++ b/host/README.txt @@ -0,0 +1,37 @@ +############################################### +# Ettus Research - Universal Hardware Driver +############################################### +The hardware driver for Ettus Research products. + +############################################### +# Supported USRP Motherboards +############################################### +USRP1 +USRP2 +USRP-N200 +USRP-N210 +USRP-E100 + +############################################### +# Supported USRP Daughterboards +############################################### +Basic RX +Basic TX +LF RX +LF TX +RFX Series +XCVR 2450 +WBX Series +DBSRX +DBSRX2 +TVRX + +############################################### +# Documentation +############################################### +Online documentation available at: +http://code.ettus.com/redmine/ettus/projects/uhd/wiki + +The build system can generate the html for the manual and Doxygen. +Docutils and Doxygen are required to build the html docs. +See the docs directory for the manual source (reStructuredText). -- cgit v1.2.3 From 9a52bc09e3561365c4600fdb9d3df172da014554 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 25 Mar 2011 16:07:26 -0700 Subject: usrp2: fix typo, now building n200 fpga images --- images/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/Makefile b/images/Makefile index cadf4b71f..74b1cd6e4 100644 --- a/images/Makefile +++ b/images/Makefile @@ -132,7 +132,7 @@ ifdef HAS_XTCLSH _usrp_n200_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/u2plus _usrp_n200_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n200_fpga.bin -IMAGES_LIST += $(_usrp_n210_fpga_bin) +IMAGES_LIST += $(_usrp_n200_fpga_bin) $(_usrp_n200_fpga_bin): $(GLOBAL_DEPS) cd $(_usrp_n200_fpga_dir) && make -f Makefile.N200 clean -- cgit v1.2.3 From 0ed7a9f2b0fbd23e68022289fd42af35535bcb39 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 26 Mar 2011 16:44:53 -0700 Subject: usrp2: fixed serial bootloader for N series --- firmware/zpu/usrp2p/bootloader/init_bootloader.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/firmware/zpu/usrp2p/bootloader/init_bootloader.c b/firmware/zpu/usrp2p/bootloader/init_bootloader.c index f8b432c46..66481eb25 100644 --- a/firmware/zpu/usrp2p/bootloader/init_bootloader.c +++ b/firmware/zpu/usrp2p/bootloader/init_bootloader.c @@ -37,15 +37,16 @@ void load_ihex(void) { //simple IHEX parser to load proper records into RAM. loa gets(buf); if(!ihex_parse(buf, &ihex_record)) { //RAM data record is valid - if(ihex_record.addr >= RAM_BASE) { //it's expecting to see FULLY RELOCATED IHX RECORDS. every address referenced to 0x8000, including vectors. - memcpy((void *) (ihex_record.addr), ihex_record.data, ihex_record.length); - puts("OK"); - } else if(ihex_record.type == 1) { //end of record + if(ihex_record.type == 1) { //end of record puts("OK"); //load main firmware start_program(); puts("ERROR: main image returned! Back in IHEX load mode."); - } else puts("NOK"); //RAM loads do not support extended segment address records (04) -- upper 16 bits are always "0". + } else { + const uint8_t *destination = (uint8_t *)ihex_record.addr + RAM_BASE; + memcpy((void *) destination, ihex_record.data, ihex_record.length); + puts("OK"); + } } else puts("NOK"); } } -- cgit v1.2.3 From 8d8c694baecccd3cff52c95cae8a7d2afae615d7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 26 Mar 2011 23:03:04 -0700 Subject: usrp2: created net burner gui wrapper for N series The gui looks and works much like the card burner gui. However, the possible devices are not enumerated. Handles errors, resetting, and showing progress. Added hooks to net burner for progress callbacks (progress meter). Changed --ip option to --addr (any resolvable address will work). Fixes issue with "timeout" on reset, by catching socket.timeout. Updated the manual to reflect using the gui app and --addr option. --- host/docs/usrp2.rst | 11 +- host/utils/usrp_n2xx_net_burner.py | 54 ++++++---- host/utils/usrp_n2xx_net_burner_gui.py | 188 +++++++++++++++++++++++++++++++++ 3 files changed, 226 insertions(+), 27 deletions(-) create mode 100644 host/utils/usrp_n2xx_net_burner_gui.py diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 70101bd87..912f7d2bd 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -58,17 +58,20 @@ Use the net burner tool (unix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: + sudo /share/uhd/utils/usrp_n2xx_net_burner_gui.py + + -- OR -- + cd /share/uhd/utils - ./usrp_n2xx_net_burner.py --ip= --fw= - ./usrp_n2xx_net_burner.py --ip= --fpga= + ./usrp_n2xx_net_burner.py --addr= --fw= + ./usrp_n2xx_net_burner.py --addr= --fpga= ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the net burner tool (Windows) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - /share/uhd/utils/usrp_n2xx_net_burner.py --ip= --fw= - /share/uhd/utils/usrp_n2xx_net_burner.py --ip= --fpga= + /share/uhd/utils/usrp_n2xx_net_burner_gui.py ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Device recovery and bricking diff --git a/host/utils/usrp_n2xx_net_burner.py b/host/utils/usrp_n2xx_net_burner.py index 6fdc9df20..c715f3364 100755 --- a/host/utils/usrp_n2xx_net_burner.py +++ b/host/utils/usrp_n2xx_net_burner.py @@ -118,31 +118,29 @@ def is_valid_fw_image(fw_image): # Burner class, holds a socket and send/recv routines ######################################################################## class burner_socket(object): - def __init__(self, ip): + def __init__(self, addr): self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self._sock.settimeout(UDP_TIMEOUT) - self._sock.connect((ip, UDP_FW_UPDATE_PORT)) + self._sock.connect((addr, UDP_FW_UPDATE_PORT)) + self.set_callbacks(lambda *a: None, lambda *a: None) + self.init_update() #check that the device is there - def send_and_recv(self, pkt): - try: self._sock.send(pkt) - except Exception, e: - print e - sys.exit(1) - - try: recv_pkt = self._sock.recv(UDP_MAX_XFER_BYTES) - except Exception, e: - print e - sys.exit(1) + def set_callbacks(self, progress_cb, status_cb): + self._progress_cb = progress_cb + self._status_cb = status_cb - return recv_pkt + def send_and_recv(self, pkt): + self._sock.send(pkt) + return self._sock.recv(UDP_MAX_XFER_BYTES) #just here to validate comms def init_update(self): out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_OHAI_LOL, seq(), 0, 0, "") - in_pkt = self.send_and_recv(out_pkt) + try: in_pkt = self.send_and_recv(out_pkt) + except socket.timeout: raise Exception, "No response from device" (proto_ver, pktid, rxseq, ip_addr) = unpack_flash_ip_fmt(in_pkt) if pktid == update_id_t.USRP2_FW_UPDATE_ID_OHAI_OMG: - print "USRP2P found." + print "USRP-N2XX found." else: raise Exception, "Invalid reply received from device." @@ -214,9 +212,11 @@ class burner_socket(object): def write_image(self, image, addr): print "Writing image" + self._status_cb("Writing") + writedata = image #we split the image into smaller (256B) bits and send them down the wire - while image: - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_WRITE_TEH_FLASHES_LOL, seq(), addr, FLASH_DATA_PACKET_SIZE, image[:FLASH_DATA_PACKET_SIZE]) + while writedata: + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_WRITE_TEH_FLASHES_LOL, seq(), addr, FLASH_DATA_PACKET_SIZE, writedata[:FLASH_DATA_PACKET_SIZE]) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) @@ -224,11 +224,13 @@ class burner_socket(object): if pktid != update_id_t.USRP2_FW_UPDATE_ID_WROTE_TEH_FLASHES_OMG: raise Exception, "Invalid reply %c from device." % (chr(pktid)) - image = image[FLASH_DATA_PACKET_SIZE:] + writedata = writedata[FLASH_DATA_PACKET_SIZE:] addr += FLASH_DATA_PACKET_SIZE + self._progress_cb(float(len(image)-len(writedata))/len(image)) def verify_image(self, image, addr): print "Verifying data" + self._status_cb("Verifying") readsize = len(image) readdata = str() while readsize > 0: @@ -245,6 +247,7 @@ class burner_socket(object): readdata += data[:thisreadsize] readsize -= FLASH_DATA_PACKET_SIZE addr += FLASH_DATA_PACKET_SIZE + self._progress_cb(float(len(readdata))/len(image)) print "Read back %i bytes" % len(readdata) # print readdata @@ -253,7 +256,7 @@ class burner_socket(object): # print "out: %i in: %i" % (ord(image[i]), ord(readdata[i])) if readdata != image: - print "Verify failed. Image did not write correctly." + raise Exception, "Verify failed. Image did not write correctly." else: print "Success." @@ -285,13 +288,15 @@ class burner_socket(object): def reset_usrp(self): out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_RESET_MAH_COMPUTORZ_LOL, seq(), 0, 0, "") - in_pkt = self.send_and_recv(out_pkt) + try: in_pkt = self.send_and_recv(out_pkt) + except socket.timeout: return (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid == update_id_t.USRP2_FW_UPDATE_ID_RESETTIN_TEH_COMPUTORZ_OMG: raise Exception, "Device failed to reset." def erase_image(self, addr, length): + self._status_cb("Erasing") #get flash info first out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_ERASE_TEH_FLASHES_LOL, seq(), addr, length, "") in_pkt = self.send_and_recv(out_pkt) @@ -302,6 +307,7 @@ class burner_socket(object): raise Exception, "Invalid reply %c from device." % (chr(pktid)) print "Erasing %i bytes at %i" % (length, addr) + start_time = time.time() #now wait for it to finish while(True): @@ -313,6 +319,8 @@ class burner_socket(object): if pktid == update_id_t.USRP2_FW_UPDATE_ID_IM_DONE_ERASING_OMG: break elif pktid != update_id_t.USRP2_FW_UPDATE_ID_NOPE_NOT_DONE_ERASING_OMG: raise Exception, "Invalid reply %c from device." % (chr(pktid)) + time.sleep(0.01) #decrease network overhead by waiting a bit before polling + self._progress_cb(min(1.0, (time.time() - start_time)/(length/80e3))) ######################################################################## @@ -320,7 +328,7 @@ class burner_socket(object): ######################################################################## def get_options(): parser = optparse.OptionParser() - parser.add_option("--ip", type="string", help="USRP2P firmware address", default='') + parser.add_option("--addr", type="string", help="USRP-N2XX device address", default='') parser.add_option("--fw", type="string", help="firmware image path (optional)", default='') parser.add_option("--fpga", type="string", help="fpga image path (optional)", default='') parser.add_option("--reset", action="store_true", help="reset the device after writing", default=False) @@ -335,7 +343,7 @@ def get_options(): ######################################################################## if __name__=='__main__': options = get_options() - if not options.ip: raise Exception, 'no ip address specified' + if not options.addr: raise Exception, 'no address specified' if not options.fpga and not options.fw and not options.reset: raise Exception, 'Must specify either a firmware image or FPGA image, and/or reset.' @@ -345,7 +353,7 @@ if __name__=='__main__': response = raw_input("""Type "yes" to continue, or anything else to quit: """) if response != "yes": sys.exit(0) - burner = burner_socket(ip=options.ip) + burner = burner_socket(addr=options.addr) if options.read: if options.fw: diff --git a/host/utils/usrp_n2xx_net_burner_gui.py b/host/utils/usrp_n2xx_net_burner_gui.py new file mode 100644 index 000000000..7fcb7d121 --- /dev/null +++ b/host/utils/usrp_n2xx_net_burner_gui.py @@ -0,0 +1,188 @@ +#!/usr/bin/env python +# +# Copyright 2011 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +import threading +import usrp_n2xx_net_burner #import implementation +import Tkinter, tkFileDialog, tkFont, tkMessageBox +import os + +class BinFileEntry(Tkinter.Frame): + """ + Simple file entry widget for getting the file path of bin files. + Combines a label, entry, and button with file dialog callback. + """ + + def __init__(self, root, what, def_path=''): + self._what = what + Tkinter.Frame.__init__(self, root) + Tkinter.Label(self, text=what+":").pack(side=Tkinter.LEFT) + self._entry = Tkinter.Entry(self, width=50) + self._entry.insert(Tkinter.END, def_path) + self._entry.pack(side=Tkinter.LEFT) + Tkinter.Button(self, text="...", command=self._button_cb).pack(side=Tkinter.LEFT) + + def _button_cb(self): + filename = tkFileDialog.askopenfilename( + parent=self, + filetypes=[('bin files', '*.bin'), ('all files', '*.*')], + title="Select bin file for %s"%self._what, + initialdir=os.path.dirname(self.get_filename()), + ) + + # open file on your own + if filename: + self._entry.delete(0, Tkinter.END) + self._entry.insert(0, filename) + + def get_filename(self): + return self._entry.get() + +class ProgressBar(Tkinter.Canvas): + """ + A simple implementation of a progress bar. + Draws rectangle that fills from left to right. + """ + + def __init__(self, root, width=500, height=20): + self._width = width + self._height = height + Tkinter.Canvas.__init__(self, root, relief="sunken", borderwidth=2, width=self._width-2, height=self._height-2) + self._last_fill_pixels = None + self.set(0.0) + + def set(self, frac): + """ + Update the progress where fraction is between 0.0 and 1.0 + """ + #determine the number of pixels to draw + fill_pixels = int(round(self._width*frac)) + if fill_pixels == self._last_fill_pixels: return + self._last_fill_pixels = fill_pixels + + #draw a rectangle representing the progress + if frac: self.create_rectangle(0, 0, fill_pixels, self._height, fill="#357EC7") + else: self.create_rectangle(0, 0, self._width, self._height, fill="#E8E8E8") + +class SectionLabel(Tkinter.Label): + """ + Make a text label with bold font. + """ + + def __init__(self, root, text): + Tkinter.Label.__init__(self, root, text=text) + + #set the font bold + f = tkFont.Font(font=self['font']) + f['weight'] = 'bold' + self['font'] = f.name + +class USRPN2XXNetBurnerApp(Tkinter.Frame): + """ + The top level gui application for the usrp-n2xx network burner. + Creates entry widgets and button with callback to write images. + """ + + def __init__(self, root, addr, fw, fpga): + + Tkinter.Frame.__init__(self, root) + + #pack the file entry widgets + SectionLabel(self, text="Select Images").pack(pady=5) + self._fw_img_entry = BinFileEntry(self, "Firmware Image", def_path=fw) + self._fw_img_entry.pack() + self._fpga_img_entry = BinFileEntry(self, "FPGA Image", def_path=fpga) + self._fpga_img_entry.pack() + + #pack the destination entry widget + SectionLabel(self, text="Select Address").pack(pady=5) + self._addr_entry = Tkinter.Entry(self, width=30) + self._addr_entry.insert(Tkinter.END, addr) + self._addr_entry.pack() + + #the do it button + SectionLabel(self, text="").pack(pady=5) + button = Tkinter.Button(self, text="Burn Images", command=self._burn) + self._enable_input = lambda: button.configure(state=Tkinter.NORMAL) + self._disable_input = lambda: button.configure(state=Tkinter.DISABLED) + button.pack() + + #a progress bar to monitor the status + progress_frame = Tkinter.Frame(self) + progress_frame.pack() + self._status = Tkinter.StringVar() + Tkinter.Label(progress_frame, textvariable=self._status).pack(side=Tkinter.LEFT) + self._pbar = ProgressBar(progress_frame) + self._pbar.pack(side=Tkinter.RIGHT, expand=True) + + def _burn(self): + self._disable_input() + threading.Thread(target=self._burn_bg).start() + + def _burn_bg(self): + #grab strings from the gui + fw = self._fw_img_entry.get_filename() + fpga = self._fpga_img_entry.get_filename() + addr = self._addr_entry.get() + + #check input + if not addr: + tkMessageBox.showerror('Error:', 'No address specified!') + return + if not fw and not fpga: + tkMessageBox.showerror('Error:', 'No images specified!') + return + if fw and not os.path.exists(fw): + tkMessageBox.showerror('Error:', 'Firmware image not found!') + return + if fpga and not os.path.exists(fpga): + tkMessageBox.showerror('Error:', 'FPGA image not found!') + return + + try: + #make a new burner object and attempt the burner operation + burner = usrp_n2xx_net_burner.burner_socket(addr=addr) + + for (image_type, fw_img, fpga_img) in (('FPGA', '', fpga), ('Firmware', fw, '')): + #setup callbacks that update the gui + def status_cb(status): + self._pbar.set(0.0) #status change, reset the progress + self._status.set("%s %s "%(status.title(), image_type)) + burner.set_callbacks(progress_cb=self._pbar.set, status_cb=status_cb) + burner.burn_fw(fw=fw_img, fpga=fpga_img, reset=False, safe=False) + + if tkMessageBox.askyesno("Burn was successful!", "Reset the device?"): + burner.reset_usrp() + + except Exception, e: + tkMessageBox.showerror('Verbose:', 'Error: %s'%str(e)) + + #reset the progress bar + self._pbar.set(0.0) + self._status.set("") + self._enable_input() + +######################################################################## +# main +######################################################################## +if __name__=='__main__': + options = usrp_n2xx_net_burner.get_options() + root = Tkinter.Tk() + root.title('USRP-N2XX Net Burner') + USRPN2XXNetBurnerApp(root, addr=options.addr, fw=options.fw, fpga=options.fpga).pack() + root.mainloop() + exit() -- cgit v1.2.3 From ae8fd1009794cd80ee79fcf56a6bddb609bb32b5 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 26 Mar 2011 23:10:47 -0700 Subject: usrp2: added usrp_n2xx_net_burner_gui to build system installation --- host/utils/CMakeLists.txt | 1 + host/utils/usrp_n2xx_net_burner_gui.py | 0 2 files changed, 1 insertion(+) mode change 100644 => 100755 host/utils/usrp_n2xx_net_burner_gui.py diff --git a/host/utils/CMakeLists.txt b/host/utils/CMakeLists.txt index 3c18324a5..98b5d41fb 100644 --- a/host/utils/CMakeLists.txt +++ b/host/utils/CMakeLists.txt @@ -59,6 +59,7 @@ IF(ENABLE_USRP2) usrp2_card_burner.py usrp2_card_burner_gui.py usrp_n2xx_net_burner.py + usrp_n2xx_net_burner_gui.py DESTINATION ${PKG_DATA_DIR}/utils COMPONENT utilities ) diff --git a/host/utils/usrp_n2xx_net_burner_gui.py b/host/utils/usrp_n2xx_net_burner_gui.py old mode 100644 new mode 100755 -- cgit v1.2.3 From d078d4f5d17088b9f366c62f5b3eca7b167e665c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 27 Mar 2011 05:03:39 -0700 Subject: uhd: work on versioning technique for the releases --- host/Modules/UHDVersion.cmake | 25 +++++++++++++++++-------- host/lib/CMakeLists.txt | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index 9b20bb98a..440ce6698 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -17,19 +17,28 @@ ######################################################################## INCLUDE(UHDPython) #requires python for parsing +FIND_PACKAGE(Git QUIET) ######################################################################## # Setup Version Numbers +# - increment major on api compatibility changes +# - increment minor on feature-level changes +# - increment patch on for bug fixes and docs ######################################################################## -SET(UHD_VERSION_MAJOR 003) #API compatibility number -SET(UHD_VERSION_MINOR 0) #Timestamp of git commit -SET(UHD_VERSION_PATCH 0) #Short hash of git commit +SET(UHD_VERSION_MAJOR 003) +SET(UHD_VERSION_MINOR 000) +SET(UHD_VERSION_PATCH 000) ######################################################################## -# Find GIT to get repo information +# Version information discovery through git log ######################################################################## -FIND_PACKAGE(Git QUIET) -IF(GIT_FOUND) +IF(UHD_PACKAGE_MODE STREQUAL AUTO) + SET(UHD_VERSION_DISCOVERY FALSE) +ELSE() + SET(UHD_VERSION_DISCOVERY GIT_FOUND) +ENDIF() + +IF(UHD_VERSION_DISCOVERY) #grab the git log entry for the current head EXECUTE_PROCESS( @@ -50,7 +59,7 @@ IF(GIT_FOUND) COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d%H%M%S', time.gmtime(${_git_timestamp}))" OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE ) - SET(UHD_VERSION_MINOR ${_git_date}) + #SET(UHD_VERSION_MINOR ${_git_date}) #grab the git ref id for the current head EXECUTE_PROCESS( @@ -59,7 +68,7 @@ IF(GIT_FOUND) OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE ) SET(UHD_VERSION_PATCH ${_git_rev}) -ENDIF(GIT_FOUND) +ENDIF(UHD_VERSION_DISCOVERY) ######################################################################## SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}.${UHD_VERSION_PATCH}") diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index a30b380c4..cb75979e8 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -112,7 +112,8 @@ LIBUHD_APPEND_SOURCES( ADD_LIBRARY(uhd SHARED ${libuhd_sources}) TARGET_LINK_LIBRARIES(uhd ${Boost_LIBRARIES} ${libuhd_libs}) SET_TARGET_PROPERTIES(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS") -SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION ${UHD_VERSION_MAJOR}) +SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION "${UHD_VERSION_MAJOR}") +SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}") IF(DEFINED LIBUHD_OUTPUT_NAME) SET_TARGET_PROPERTIES(uhd PROPERTIES OUTPUT_NAME ${LIBUHD_OUTPUT_NAME}) ENDIF(DEFINED LIBUHD_OUTPUT_NAME) -- cgit v1.2.3 From c6c4b01e09efc037aa44dbf8cdba1c705747bd2f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sun, 27 Mar 2011 15:04:01 -0700 Subject: uhd: swapped UHD_PACKAGE_MODE with UHD_RELEASE_MODE (boolean) --- host/Modules/UHDPackage.cmake | 4 ++-- host/Modules/UHDVersion.cmake | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 65897ceef..65637ab16 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -21,7 +21,7 @@ INCLUDE(UHDVersion) #sets version information ######################################################################## # Setup package file name ######################################################################## -IF(UHD_PACKAGE_MODE STREQUAL AUTO) +IF(UHD_RELEASE_MODE) FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) FIND_PROGRAM(UNAME_EXECUTABLE uname) IF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) @@ -59,7 +59,7 @@ IF(UHD_PACKAGE_MODE STREQUAL AUTO) SET(CPACK_GENERATOR NSIS) ENDIF() -ENDIF(UHD_PACKAGE_MODE STREQUAL AUTO) +ENDIF(UHD_RELEASE_MODE) ######################################################################## # Setup CPack General diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index 440ce6698..dbc39b5a9 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -32,7 +32,7 @@ SET(UHD_VERSION_PATCH 000) ######################################################################## # Version information discovery through git log ######################################################################## -IF(UHD_PACKAGE_MODE STREQUAL AUTO) +IF(UHD_RELEASE_MODE) SET(UHD_VERSION_DISCOVERY FALSE) ELSE() SET(UHD_VERSION_DISCOVERY GIT_FOUND) -- cgit v1.2.3 From 69d19fedd3fd7945a21daac0ae14c06fee78ee91 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Mar 2011 13:44:36 -0700 Subject: uhd: various packing fixes (lib suffix, and library components) 1) setup lib suffix for fedora 64 2) specify component for all library target types (should fix missing library files problem) --- host/Modules/UHDPackage.cmake | 5 +++++ host/lib/CMakeLists.txt | 9 ++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 65637ab16..e7aa386f6 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -48,6 +48,11 @@ IF(UHD_RELEASE_MODE) SET(CPACK_GENERATOR RPM) ENDIF() + #when the library suffix should be 64 (applies to redhat linux family) + IF(EXISTS "/etc/redhat-release" AND _machine MATCHES "64$") + SET(LIB_SUFFIX 64) + ENDIF() + #set a more sensible package name for this system SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}-${_os_name}-${_os_version}-${_machine}") diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index cb75979e8..d095255ea 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -113,14 +113,13 @@ ADD_LIBRARY(uhd SHARED ${libuhd_sources}) TARGET_LINK_LIBRARIES(uhd ${Boost_LIBRARIES} ${libuhd_libs}) SET_TARGET_PROPERTIES(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS") SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION "${UHD_VERSION_MAJOR}") -SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}") +SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION}") IF(DEFINED LIBUHD_OUTPUT_NAME) SET_TARGET_PROPERTIES(uhd PROPERTIES OUTPUT_NAME ${LIBUHD_OUTPUT_NAME}) ENDIF(DEFINED LIBUHD_OUTPUT_NAME) INSTALL(TARGETS uhd - LIBRARY DESTINATION ${LIBRARY_DIR} # .so file - ARCHIVE DESTINATION ${LIBRARY_DIR} # .lib file - RUNTIME DESTINATION ${LIBRARY_DIR} # .dll file - COMPONENT libraries + LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .so file + ARCHIVE DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .lib file + RUNTIME DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .dll file ) -- cgit v1.2.3 From 2ce39c4de5f98cb51eeb6498c6c3d23c873d0ebc Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Mar 2011 16:53:28 -0700 Subject: uhd: expand UHD_RELEASE_MODE setup to all debian and redhats --- host/Modules/UHDPackage.cmake | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index e7aa386f6..1bae55b4c 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -22,6 +22,20 @@ INCLUDE(UHDVersion) #sets version information # Setup package file name ######################################################################## IF(UHD_RELEASE_MODE) + + #set generator type for recognized systems + IF(APPLE) + SET(CPACK_GENERATOR PackageMaker) + ELSEIF(WIN32) + SET(CPACK_GENERATOR NSIS) + ELSEIF(UNIX AND EXISTS "/etc/debian_version") + SET(CPACK_GENERATOR DEB) + ELSEIF(UNIX AND EXISTS "/etc/redhat-release") + SET(CPACK_GENERATOR RPM) + ELSE() + SET(CPACK_GENERATOR TGZ) + ENDIF() + FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) FIND_PROGRAM(UNAME_EXECUTABLE uname) IF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) @@ -40,16 +54,8 @@ IF(UHD_RELEASE_MODE) OUTPUT_VARIABLE _machine OUTPUT_STRIP_TRAILING_WHITESPACE ) - #set generator type for recognized systems - IF(${_os_name} STREQUAL Ubuntu) - SET(CPACK_GENERATOR DEB) - ENDIF() - IF(${_os_name} STREQUAL Fedora) - SET(CPACK_GENERATOR RPM) - ENDIF() - #when the library suffix should be 64 (applies to redhat linux family) - IF(EXISTS "/etc/redhat-release" AND _machine MATCHES "64$") + IF(CPACK_GENERATOR STREQUAL RPM AND _machine MATCHES "64$") SET(LIB_SUFFIX 64) ENDIF() @@ -58,12 +64,6 @@ IF(UHD_RELEASE_MODE) ENDIF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) - IF(APPLE) - SET(CPACK_GENERATOR PackageMaker) - ELSEIF(WIN32) - SET(CPACK_GENERATOR NSIS) - ENDIF() - ENDIF(UHD_RELEASE_MODE) ######################################################################## -- cgit v1.2.3 From 834bcbad6e632d872a5867801b2e4a5c9a5f95cd Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Mar 2011 18:38:47 -0700 Subject: uhd: set LIB_SUFFIX automatically (all 64-bit redhats) Check for and define DEBIAN and REDHAT detection vars. Added LIB_SUFFIX check in top level cmakelists. Use CMAKE_SYSTEM_PROCESSOR rather than exec uname -m. Cleans up release mode logic. --- host/CMakeLists.txt | 4 ++++ host/Modules/UHDPackage.cmake | 35 ++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 8516da401..db100129f 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -33,6 +33,10 @@ INCLUDE(UHDPackage) #setup cpack ######################################################################## # Install Dirs ######################################################################## +#when the library suffix should be 64 (applies to redhat linux family) +IF(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") + SET(LIB_SUFFIX 64) +ENDIF() SET(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") SET(RUNTIME_DIR bin) SET(LIBRARY_DIR lib${LIB_SUFFIX}) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 1bae55b4c..ef1a82c9a 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -18,6 +18,17 @@ ######################################################################## INCLUDE(UHDVersion) #sets version information +######################################################################## +# Setup additional defines for OS types +######################################################################## +IF(UNIX AND EXISTS "/etc/debian_version") + SET(DEBIAN TRUE) +ENDIF() + +IF(UNIX AND EXISTS "/etc/redhat-release") + SET(REDHAT TRUE) +ENDIF() + ######################################################################## # Setup package file name ######################################################################## @@ -28,41 +39,31 @@ IF(UHD_RELEASE_MODE) SET(CPACK_GENERATOR PackageMaker) ELSEIF(WIN32) SET(CPACK_GENERATOR NSIS) - ELSEIF(UNIX AND EXISTS "/etc/debian_version") + ELSEIF(DEBIAN) SET(CPACK_GENERATOR DEB) - ELSEIF(UNIX AND EXISTS "/etc/redhat-release") + ELSEIF(REDHAT) SET(CPACK_GENERATOR RPM) ELSE() SET(CPACK_GENERATOR TGZ) ENDIF() FIND_PROGRAM(LSB_RELEASE_EXECUTABLE lsb_release) - FIND_PROGRAM(UNAME_EXECUTABLE uname) - IF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) + IF(LSB_RELEASE_EXECUTABLE) #extract system information by executing the commands EXECUTE_PROCESS( COMMAND ${LSB_RELEASE_EXECUTABLE} --short --id - OUTPUT_VARIABLE _os_name OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE LSB_ID OUTPUT_STRIP_TRAILING_WHITESPACE ) EXECUTE_PROCESS( COMMAND ${LSB_RELEASE_EXECUTABLE} --short --release - OUTPUT_VARIABLE _os_version OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE ) - EXECUTE_PROCESS( - COMMAND ${UNAME_EXECUTABLE} --machine - OUTPUT_VARIABLE _machine OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - #when the library suffix should be 64 (applies to redhat linux family) - IF(CPACK_GENERATOR STREQUAL RPM AND _machine MATCHES "64$") - SET(LIB_SUFFIX 64) - ENDIF() #set a more sensible package name for this system - SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}-${_os_name}-${_os_version}-${_machine}") + SET(CPACK_PACKAGE_FILE_NAME "UHD-${UHD_VERSION}-${LSB_ID}-${LSB_RELEASE}-${CMAKE_SYSTEM_PROCESSOR}") - ENDIF(LSB_RELEASE_EXECUTABLE AND UNAME_EXECUTABLE) + ENDIF(LSB_RELEASE_EXECUTABLE) ENDIF(UHD_RELEASE_MODE) -- cgit v1.2.3 From 1ff8aaeaab91919e0c67c85ba6bb74fba96eefe8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Mar 2011 21:17:09 -0700 Subject: uhd: revert VERSION setting for libuhd, macosx does not like patch level --- host/lib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index d095255ea..54f4893e3 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -113,7 +113,7 @@ ADD_LIBRARY(uhd SHARED ${libuhd_sources}) TARGET_LINK_LIBRARIES(uhd ${Boost_LIBRARIES} ${libuhd_libs}) SET_TARGET_PROPERTIES(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS") SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION "${UHD_VERSION_MAJOR}") -SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION}") +SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}") IF(DEFINED LIBUHD_OUTPUT_NAME) SET_TARGET_PROPERTIES(uhd PROPERTIES OUTPUT_NAME ${LIBUHD_OUTPUT_NAME}) ENDIF(DEFINED LIBUHD_OUTPUT_NAME) -- cgit v1.2.3 From 2d1bd00bf04274358aed15b5652e67187424a424 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 28 Mar 2011 23:41:01 -0700 Subject: usb: changes to allow for static linking of libusb on windows --- host/lib/transport/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index a5bf9c5f1..656ca9987 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -31,6 +31,10 @@ IF(ENABLE_USB) MESSAGE(STATUS "USB support enabled via libusb.") INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR}) LIBUHD_APPEND_LIBS(${LIBUSB_LIBRARIES}) + IF(WIN32) + #needed when statically linking libusb + LIBUHD_APPEND_LIBS(Setupapi.lib) + ENDIF(WIN32) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp -- cgit v1.2.3 From 9d91d5518751d37b32c86fe4f0c17f0b480fd0bb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 29 Mar 2011 11:22:57 -0700 Subject: usb: tweaks to the build guide (libusb + windows) --- host/docs/build.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/host/docs/build.rst b/host/docs/build.rst index de7c544f2..b81e25de1 100644 --- a/host/docs/build.rst +++ b/host/docs/build.rst @@ -165,12 +165,13 @@ LibUSB cmake notes On Windows, cmake does not have the advantage of pkg-config, so we must manually tell cmake how to locate the LibUSB header and lib. -From the cmake gui, select "Advanded View": - +* From the cmake gui, select "Advanded View" * Set LIBUSB_INCLUDE_DIR to the directory with "libusb.h". * Set LIBUSB_LIBRARIES to the full path for "libusb-1.0.lib". -Then check the boxes to enable USRP1 support, click configure and generate. + * Recommend the static libusb-1.0.lib to simplify runtime dependencies. + +* Check the box to enable USB support, click configure and generate. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Build the project in MSVC -- cgit v1.2.3 From a2a78451d196a7f52a3e2a3bda94f52d127313d0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 29 Mar 2011 11:38:38 -0700 Subject: usrp-e100: set the ticks-per-second every time we change clock rate --- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 1 + host/lib/usrp/usrp_e100/mboard_impl.cpp | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index aba630d88..b0bf20b67 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -287,6 +287,7 @@ public: if (_out_rate == rate) return; if (rate == 61.44e6) set_clock_settings_with_external_vcxo(rate); else set_clock_settings_with_internal_vco(rate); + _iface->poke32(UE_REG_TIME64_TPS, boost::uint32_t(get_fpga_clock_rate())); } double get_fpga_clock_rate(void){ diff --git a/host/lib/usrp/usrp_e100/mboard_impl.cpp b/host/lib/usrp/usrp_e100/mboard_impl.cpp index cec4fd0ad..29e3c5da2 100644 --- a/host/lib/usrp/usrp_e100/mboard_impl.cpp +++ b/host/lib/usrp/usrp_e100/mboard_impl.cpp @@ -36,11 +36,6 @@ void usrp_e100_impl::mboard_init(void){ boost::bind(&usrp_e100_impl::mboard_set, this, _1, _2) ); - //set the ticks per seconds into the vita time control - _iface->poke32(UE_REG_TIME64_TPS, - boost::uint32_t(_clock_ctrl->get_fpga_clock_rate()) - ); - //init the clock config _clock_config = clock_config_t::internal(); update_clock_config(); -- cgit v1.2.3 From 32357927bdc52b0cc7cd7b6d18457932aaa79682 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 29 Mar 2011 13:42:40 -0700 Subject: uhd: remove build information in the version string (just major.minor.patch) Add the build info as an additional string to the get_version function(). --- host/CMakeLists.txt | 2 +- host/Modules/UHDVersion.cmake | 14 ++++++++------ host/lib/constants.hpp.in | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index db100129f..244793b9e 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -211,5 +211,5 @@ ADD_SUBDIRECTORY(usrp_e_utils) # Print Summary ######################################################################## UHD_PRINT_COMPONENT_SUMMARY() -MESSAGE(STATUS "Building version: ${CPACK_PACKAGE_VERSION}") +MESSAGE(STATUS "Building version: ${CPACK_PACKAGE_VERSION}-${UHD_BUILD_INFO}") MESSAGE(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index dbc39b5a9..78bf7f690 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -33,12 +33,14 @@ SET(UHD_VERSION_PATCH 000) # Version information discovery through git log ######################################################################## IF(UHD_RELEASE_MODE) - SET(UHD_VERSION_DISCOVERY FALSE) + SET(UHD_BUILD_INFO_DISCOVERY FALSE) + SET(UHD_BUILD_INFO "release") ELSE() - SET(UHD_VERSION_DISCOVERY GIT_FOUND) + SET(UHD_BUILD_INFO_DISCOVERY GIT_FOUND) + SET(UHD_BUILD_INFO "unknown") ENDIF() -IF(UHD_VERSION_DISCOVERY) +IF(UHD_BUILD_INFO_DISCOVERY) #grab the git log entry for the current head EXECUTE_PROCESS( @@ -59,7 +61,6 @@ IF(UHD_VERSION_DISCOVERY) COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d%H%M%S', time.gmtime(${_git_timestamp}))" OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE ) - #SET(UHD_VERSION_MINOR ${_git_date}) #grab the git ref id for the current head EXECUTE_PROCESS( @@ -67,8 +68,9 @@ IF(UHD_VERSION_DISCOVERY) COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE ) - SET(UHD_VERSION_PATCH ${_git_rev}) -ENDIF(UHD_VERSION_DISCOVERY) + + SET(UHD_BUILD_INFO ${_git_rev}) +ENDIF(UHD_BUILD_INFO_DISCOVERY) ######################################################################## SET(UHD_VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}.${UHD_VERSION_PATCH}") diff --git a/host/lib/constants.hpp.in b/host/lib/constants.hpp.in index 4aedb6d4a..d62dda1cb 100644 --- a/host/lib/constants.hpp.in +++ b/host/lib/constants.hpp.in @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ #define INCLUDED_LIBUHD_CONSTANTS_HPP //these should be pre-processor macros to avoid static initialization issues -#define UHD_VERSION_STRING "@CPACK_PACKAGE_VERSION@" +#define UHD_VERSION_STRING "@UHD_VERSION@-@UHD_BUILD_INFO@" #define LOCAL_PKG_DATA_DIR "@LOCAL_PKG_DATA_DIR@" #define INSTALLER_PKG_DATA_DIR "@INSTALLER_PKG_DATA_DIR@" -- cgit v1.2.3 From 48f6e1f8aae24ee4ff3b15232cfc335b0210ed11 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 29 Mar 2011 17:27:17 -0700 Subject: usrp1: ignore claimed interfaces, avoids the problem of discovery when one device is claimed --- host/lib/usrp/usrp1/usrp1_impl.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp index 7005c59f2..a99777775 100644 --- a/host/lib/usrp/usrp1/usrp1_impl.cpp +++ b/host/lib/usrp/usrp1/usrp1_impl.cpp @@ -86,7 +86,11 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) } //std::cout << "USRP1 firmware image: " << usrp1_fw_image << std::endl; - usrp_ctrl::make(usb_control::make(handle))->usrp_load_firmware(usrp1_fw_image); + usb_control::sptr control; + try{control = usb_control::make(handle);} + catch(const uhd::exception &){continue;} //ignore claimed + + usrp_ctrl::make(control)->usrp_load_firmware(usrp1_fw_image); } //get descriptors again with serial number, but using the initialized VID/PID now since we have firmware @@ -94,7 +98,11 @@ static device_addrs_t usrp1_find(const device_addr_t &hint) pid = USRP1_PRODUCT_ID; BOOST_FOREACH(usb_device_handle::sptr handle, usb_device_handle::get_device_list(vid, pid)) { - usrp1_iface::sptr iface = usrp1_iface::make(usrp_ctrl::make(usb_control::make(handle))); + usb_control::sptr control; + try{control = usb_control::make(handle);} + catch(const uhd::exception &){continue;} //ignore claimed + + usrp1_iface::sptr iface = usrp1_iface::make(usrp_ctrl::make(control)); device_addr_t new_addr; new_addr["type"] = "usrp1"; new_addr["name"] = iface->mb_eeprom["name"]; -- cgit v1.2.3 From 1d29ee1086620b7dc51dcdbcaaef2690d2e95dc6 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 30 Mar 2011 16:48:09 -0700 Subject: usrp1: switch usrp1 iface to use spi read (transact never worked) It detects the number of header bytes by searching for non-zero bytes. --- host/lib/usrp/usrp1/usrp1_iface.cpp | 46 +++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp index ea7c1cea5..8f10df751 100644 --- a/host/lib/usrp/usrp1/usrp1_iface.cpp +++ b/host/lib/usrp/usrp1/usrp1_iface.cpp @@ -175,24 +175,31 @@ public: UHD_ASSERT_THROW((num_bits <= 32) && !(num_bits % 8)); size_t num_bytes = num_bits / 8; - // Byteswap on num_bytes - unsigned char buff[4] = { 0 }; - for (size_t i = 1; i <= num_bytes; i++) - buff[num_bytes - i] = (bits >> ((i - 1) * 8)) & 0xff; - if (readback) { - boost::uint8_t w_len_h = which_slave & 0xff; - boost::uint8_t w_len_l = num_bytes & 0xff; - - int ret = _ctrl_transport->usrp_control_read( - VRQ_SPI_TRANSACT, - (buff[0] << 8) | (buff[1] << 0), - (buff[2] << 8) | (buff[3] << 0), - buff, - (w_len_h << 8) | (w_len_l << 0)); - - if (ret < 0) throw uhd::io_error("USRP1: failed SPI readback transaction"); - + unsigned char buff[4] = { + (bits >> 0) & 0xff, (bits >> 8) & 0xff, + (bits >> 16) & 0xff, (bits >> 24) & 0xff + }; + //conditions where there are two header bytes + if (num_bytes >= 3 and buff[num_bytes-1] != 0 and buff[num_bytes-2] != 0 and buff[num_bytes-3] == 0){ + if (int(num_bytes-2) != _ctrl_transport->usrp_control_read( + VRQ_SPI_READ, (buff[num_bytes-1] << 8) | (buff[num_bytes-2] << 0), + (which_slave << 8) | SPI_FMT_MSB | SPI_FMT_HDR_2, + buff, num_bytes-2 + )) throw uhd::io_error("USRP1: failed SPI readback transaction"); + } + + //conditions where there is one header byte + else if (num_bytes >= 2 and buff[num_bytes-1] != 0 and buff[num_bytes-2] == 0){ + if (int(num_bytes-1) != _ctrl_transport->usrp_control_read( + VRQ_SPI_READ, buff[num_bytes-1], + (which_slave << 8) | SPI_FMT_MSB | SPI_FMT_HDR_1, + buff, num_bytes-1 + )) throw uhd::io_error("USRP1: failed SPI readback transaction"); + } + else{ + throw uhd::io_error("USRP1: invalid input data for SPI readback"); + } boost::uint32_t val = (((boost::uint32_t)buff[0]) << 0) | (((boost::uint32_t)buff[1]) << 8) | (((boost::uint32_t)buff[2]) << 16) | @@ -200,6 +207,11 @@ public: return val; } else { + // Byteswap on num_bytes + unsigned char buff[4] = { 0 }; + for (size_t i = 1; i <= num_bytes; i++) + buff[num_bytes - i] = (bits >> ((i - 1) * 8)) & 0xff; + boost::uint8_t w_index_h = which_slave & 0xff; boost::uint8_t w_index_l = (SPI_FMT_MSB | SPI_FMT_HDR_0) & 0xff; -- cgit v1.2.3 From 0f64366dee3fb8e4556509b2de0f47fa8053313e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 30 Mar 2011 16:50:02 -0700 Subject: usrp1: reverted spi transaction changes to the usrp1 firmware (broken and not needed) --- firmware/fx2/common/spi.c | 95 +------------------------------------ firmware/fx2/common/spi.h | 7 --- firmware/fx2/common/usrp_commands.h | 7 --- firmware/fx2/usrp1/usrp_main.c | 10 +--- 4 files changed, 3 insertions(+), 116 deletions(-) diff --git a/firmware/fx2/common/spi.c b/firmware/fx2/common/spi.c index 0c4f63d5a..04a1d8477 100644 --- a/firmware/fx2/common/spi.c +++ b/firmware/fx2/common/spi.c @@ -97,18 +97,13 @@ count_bits8 (unsigned char v) static void write_byte_msb (unsigned char v); -unsigned char -transact_byte_msb (unsigned char v); - static void write_bytes_msb (const xdata unsigned char *buf, unsigned char len); static void read_bytes_msb (xdata unsigned char *buf, unsigned char len); -static void -transact_bytes_msb (xdata unsigned char *buf, unsigned char len); - + // returns non-zero if successful, else 0 unsigned char spi_read (unsigned char header_hi, unsigned char header_lo, @@ -219,93 +214,7 @@ spi_write (unsigned char header_hi, unsigned char header_lo, return 1; // success } -unsigned char -spi_transact (unsigned char data0, unsigned char data1, - unsigned char data2, unsigned char data3, - unsigned char enables, xdata unsigned char *buf, - unsigned char len) -{ - if (count_bits8 (enables) > 1) - return 0; // error, too many enables set - - if (len > 4) - return 0; - - setup_enables (enables); - - buf[0] = data0; - buf[1] = data1; - buf[2] = data2; - buf[3] = data3; - - if (len != 0) - transact_bytes_msb(buf, len); - - disable_all (); - return 1; // success -} - -static unsigned char -transact_byte_msb (unsigned char v) -{ - v = (v << 1) | (v >> 7); // rotate left (MSB into bottom bit) - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; // read into bottom bit - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - v = (v << 1) | (v >> 7); - bitS_OUT = v & 0x1; - bitS_CLK = 1; - v |= bitS_IN; - bitS_CLK = 0; - - return v; -} - -static void -transact_bytes_msb (xdata unsigned char *buf, unsigned char len) -{ - while (len-- != 0){ - *buf++ = transact_byte_msb (*buf); - } -} +// ---------------------------------------------------------------- static void write_byte_msb (unsigned char v) diff --git a/firmware/fx2/common/spi.h b/firmware/fx2/common/spi.h index 5342b82b8..12bc5e544 100644 --- a/firmware/fx2/common/spi.h +++ b/firmware/fx2/common/spi.h @@ -39,12 +39,5 @@ spi_write (unsigned char header_hi, unsigned char header_lo, unsigned char enables, unsigned char format, const xdata unsigned char *buf, unsigned char len); -// returns non-zero if successful, else 0 -unsigned char -spi_transact (unsigned char data0, unsigned char data1, - unsigned char data2, unsigned char data3, - unsigned char enables, xdata unsigned char *buf, - unsigned char len); - #endif /* INCLUDED_SPI_H */ diff --git a/firmware/fx2/common/usrp_commands.h b/firmware/fx2/common/usrp_commands.h index 02778c7e3..20c28e264 100644 --- a/firmware/fx2/common/usrp_commands.h +++ b/firmware/fx2/common/usrp_commands.h @@ -54,13 +54,6 @@ // wIndexL: format // len: how much to read -#define VRQ_SPI_TRANSACT 0x83 // wValueH: OUT byte 0 - // wValueL: OUT byte 1 - // wIndexH: OUT byte 2 - // wIndexL: OUT byte 3 - // wLengthH: enables - // wLengthL: transaction length - // OUT commands #define VRQ_SET_LED 0x01 // wValueL off/on {0,1}; wIndexL: which {0,1} diff --git a/firmware/fx2/usrp1/usrp_main.c b/firmware/fx2/usrp1/usrp_main.c index 3eb8c001f..802516c0b 100644 --- a/firmware/fx2/usrp1/usrp_main.c +++ b/firmware/fx2/usrp1/usrp_main.c @@ -118,7 +118,7 @@ app_vendor_cmd (void) EP0BCH = 0; EP0BCL = wLengthL; break; - + case VRQ_SPI_READ: if (!spi_read (wValueH, wValueL, wIndexH, wIndexL, EP0BUF, wLengthL)) return 0; @@ -127,14 +127,6 @@ app_vendor_cmd (void) EP0BCL = wLengthL; break; - case VRQ_SPI_TRANSACT: - if (!spi_transact (wValueH, wValueL, wIndexH, wIndexL, wLengthH, EP0BUF, wLengthL)) - return 0; - - EP0BCH = 0; - EP0BCL = wLengthL; - break; - default: return 0; } -- cgit v1.2.3 From 6f70d17b206226823dc6108410d0608373300f58 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 30 Mar 2011 16:51:01 -0700 Subject: usrp1: fixed codec ctrl aux adc read (didnt start conversions) + cleaned-up logic --- host/lib/usrp/usrp1/codec_ctrl.cpp | 73 +++++++++++++++----------------------- 1 file changed, 29 insertions(+), 44 deletions(-) diff --git a/host/lib/usrp/usrp1/codec_ctrl.cpp b/host/lib/usrp/usrp1/codec_ctrl.cpp index 1b4411002..9df29da0e 100644 --- a/host/lib/usrp/usrp1/codec_ctrl.cpp +++ b/host/lib/usrp/usrp1/codec_ctrl.cpp @@ -71,7 +71,6 @@ private: usrp1_clock_ctrl::sptr _clock_ctrl; int _spi_slave; ad9862_regs_t _ad9862_regs; - aux_adc_t _last_aux_adc_a, _last_aux_adc_b; void send_reg(boost::uint8_t addr); void recv_reg(boost::uint8_t addr); @@ -134,6 +133,10 @@ usrp1_codec_ctrl_impl::usrp1_codec_ctrl_impl(usrp1_iface::sptr iface, this->send_reg(addr); } + //always start conversions for aux ADC + _ad9862_regs.start_a = 1; + _ad9862_regs.start_b = 1; + //aux adc clock _ad9862_regs.clk_4 = ad9862_regs_t::CLK_4_1_4; this->send_reg(34); @@ -206,55 +209,37 @@ static double aux_adc_to_volts(boost::uint8_t high, boost::uint8_t low) return double(((boost::uint16_t(high) << 2) | low)*3.3)/0x3ff; } -double usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which) -{ - //check to see if the switch needs to be set - bool write_switch = false; - switch(which) { - +double usrp1_codec_ctrl_impl::read_aux_adc(aux_adc_t which){ + switch(which){ case AUX_ADC_A1: + _ad9862_regs.select_a = ad9862_regs_t::SELECT_A_AUX_ADC1; + this->send_reg(34); //start conversion and select mux + this->recv_reg(28); //read the value (2 bytes, 2 reads) + this->recv_reg(29); + return aux_adc_to_volts(_ad9862_regs.aux_adc_a1_9_2, _ad9862_regs.aux_adc_a1_1_0); + case AUX_ADC_A2: - if (which != _last_aux_adc_a) { - _ad9862_regs.select_a = (which == AUX_ADC_A1)? - ad9862_regs_t::SELECT_A_AUX_ADC1: ad9862_regs_t::SELECT_A_AUX_ADC2; - _last_aux_adc_a = which; - write_switch = true; - } - break; + _ad9862_regs.select_a = ad9862_regs_t::SELECT_A_AUX_ADC2; + this->send_reg(34); //start conversion and select mux + this->recv_reg(26); //read the value (2 bytes, 2 reads) + this->recv_reg(27); + return aux_adc_to_volts(_ad9862_regs.aux_adc_a2_9_2, _ad9862_regs.aux_adc_a2_1_0); case AUX_ADC_B1: - case AUX_ADC_B2: - if (which != _last_aux_adc_b) { - _ad9862_regs.select_b = (which == AUX_ADC_B1)? - ad9862_regs_t::SELECT_B_AUX_ADC1: ad9862_regs_t::SELECT_B_AUX_ADC2; - _last_aux_adc_b = which; - write_switch = true; - } - break; + _ad9862_regs.select_b = ad9862_regs_t::SELECT_B_AUX_ADC1; + this->send_reg(34); //start conversion and select mux + this->recv_reg(32); //read the value (2 bytes, 2 reads) + this->recv_reg(33); + return aux_adc_to_volts(_ad9862_regs.aux_adc_b1_9_2, _ad9862_regs.aux_adc_b1_1_0); + case AUX_ADC_B2: + _ad9862_regs.select_b = ad9862_regs_t::SELECT_B_AUX_ADC2; + this->send_reg(34); //start conversion and select mux + this->recv_reg(30); //read the value (2 bytes, 2 reads) + this->recv_reg(31); + return aux_adc_to_volts(_ad9862_regs.aux_adc_b2_9_2, _ad9862_regs.aux_adc_b2_1_0); } - - //write the switch if it changed - if(write_switch) this->send_reg(34); - - //map aux adcs to register values to read - static const uhd::dict aux_dac_to_addr = boost::assign::map_list_of - (AUX_ADC_A2, 26) (AUX_ADC_A1, 28) - (AUX_ADC_B2, 30) (AUX_ADC_B1, 32) - ; - - //read the value - this->recv_reg(aux_dac_to_addr[which]+0); - this->recv_reg(aux_dac_to_addr[which]+1); - - //return the value scaled to volts - switch(which) { - case AUX_ADC_A1: return aux_adc_to_volts(_ad9862_regs.aux_adc_a1_9_2, _ad9862_regs.aux_adc_a1_1_0); - case AUX_ADC_A2: return aux_adc_to_volts(_ad9862_regs.aux_adc_a2_9_2, _ad9862_regs.aux_adc_a2_1_0); - case AUX_ADC_B1: return aux_adc_to_volts(_ad9862_regs.aux_adc_b1_9_2, _ad9862_regs.aux_adc_b1_1_0); - case AUX_ADC_B2: return aux_adc_to_volts(_ad9862_regs.aux_adc_b2_9_2, _ad9862_regs.aux_adc_b2_1_0); - } - UHD_ASSERT_THROW(false); + UHD_THROW_INVALID_CODE_PATH(); } /*********************************************************************** -- cgit v1.2.3 From 9f72695e33093498e5957900e97817b78dba76c3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 31 Mar 2011 12:30:31 -0700 Subject: uhd: added UHD_IMAGES_DIR option to include images in the package --- host/CMakeLists.txt | 9 +++++++++ images/Makefile | 18 +----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 244793b9e..97b084572 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -207,6 +207,15 @@ ENDIF(ENABLE_UTILS) ADD_SUBDIRECTORY(usrp_e_utils) +######################################################################## +# Handle pre-built images +######################################################################## +IF(DEFINED UHD_IMAGES_DIR AND EXISTS "${UHD_IMAGES_DIR}") + FILE(GLOB _image_files "${UHD_IMAGES_DIR}/*.*") + MESSAGE(STATUS "Using images: ${_image_files}") + INSTALL(FILES ${_image_files} DESTINATION ${PKG_DATA_DIR}/images) +ENDIF(DEFINED UHD_IMAGES_DIR AND EXISTS "${UHD_IMAGES_DIR}") + ######################################################################## # Print Summary ######################################################################## diff --git a/images/Makefile b/images/Makefile index 74b1cd6e4..71b46d14e 100644 --- a/images/Makefile +++ b/images/Makefile @@ -1,5 +1,5 @@ # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -198,19 +198,3 @@ images: $(IMAGES_LIST) clean: $(RM) -rf $(BUILT_IMAGES_DIR) $(RM) -rf $(CMAKE_BUILD_DIR) - -#packages that a linux machine can build -linux-packages: - mkdir -p $(CMAKE_BUILD_DIR) - - cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=TGZ $(TOP_DIR) - make -C $(CMAKE_BUILD_DIR) package - - cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=ZIP $(TOP_DIR) - make -C $(CMAKE_BUILD_DIR) package - - cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=DEB $(TOP_DIR) - make -C $(CMAKE_BUILD_DIR) package - - cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=RPM $(TOP_DIR) - make -C $(CMAKE_BUILD_DIR) package -- cgit v1.2.3 From f64dad9d95550aaf8ed56ab4f107b2e7632921eb Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Thu, 31 Mar 2011 12:36:42 -0700 Subject: Correct RFX400 div2 logic, makes RFX400 TX work --- host/lib/usrp/dboard/db_rfx.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 4d8222a52..725b5cc03 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -294,6 +294,9 @@ double rfx_xcvr::set_lo_freq( target_freq = _freq_range.clip(target_freq); if (_div2[unit]) target_freq *= 2; + //rfx400 rx is a special case with div2 in mixer, so adf4360 must output fundamental + bool is_rx_rfx400 = ((get_rx_id() == 0x0024) && unit != dboard_iface::UNIT_TX); + //map prescalers to the register enums static const uhd::dict prescaler_to_enum = map_list_of (8, adf4360_regs_t::PRESCALER_VALUE_8_9) @@ -341,8 +344,8 @@ double rfx_xcvr::set_lo_freq( } done_loop: if (rfx_debug) std::cerr << boost::format( - "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d" - ) % R % BS % P % B % A << std::endl; + "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d" + ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) << std::endl; //load the register values adf4360_regs_t regs; @@ -361,7 +364,7 @@ double rfx_xcvr::set_lo_freq( regs.a_counter = A; regs.b_counter = B; regs.cp_gain_1 = adf4360_regs_t::CP_GAIN_1_SET1; - regs.divide_by_2_output = (_div2[unit] && (get_rx_id() != 0x0024)) ? // Special case RFX400 RX Mixer divides by two + regs.divide_by_2_output = (_div2[unit] && (!is_rx_rfx400)) ? // Special case RFX400 RX Mixer divides by two adf4360_regs_t::DIVIDE_BY_2_OUTPUT_DIV2 : adf4360_regs_t::DIVIDE_BY_2_OUTPUT_FUND ; regs.divide_by_2_prescaler = adf4360_regs_t::DIVIDE_BY_2_PRESCALER_FUND; -- cgit v1.2.3 From 1c5076ea68345e74de35cad43e4a4b4adf68fa15 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 31 Mar 2011 15:00:56 -0700 Subject: uhd: implemented boost barriers on all code that creates threads The barrier ensures that the thread must spawn before the caller exits. Some of the code already used a mutex to accomplish this, however cygwin chokes when a mutex is locked twice by the same thread. Mutex implementations were replaced with the barrier implementation. Also the barrier implementation is far cleaner. --- host/lib/transport/libusb1_zero_copy.cpp | 8 ++++++-- host/lib/usrp/usrp1/soft_time_ctrl.cpp | 14 ++++++++------ host/lib/usrp/usrp2/io_impl.cpp | 25 ++++++++++++------------- host/lib/usrp/usrp_e100/io_impl.cpp | 16 +++++++++++----- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 9f38ce97b..fe6936c7e 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -191,9 +192,11 @@ public: //spawn the event handler threads size_t concurrency = hints.cast("concurrency_hint", 1); + boost::barrier spawn_barrier(concurrency+1); for (size_t i = 0; i < concurrency; i++) _thread_group.create_thread( - boost::bind(&libusb_zero_copy_impl::run_event_loop, this) + boost::bind(&libusb_zero_copy_impl::run_event_loop, this, boost::ref(spawn_barrier)) ); + spawn_barrier.wait(); } ~libusb_zero_copy_impl(void){ @@ -263,7 +266,8 @@ private: boost::thread_group _thread_group; bool _threads_running; - void run_event_loop(void){ + void run_event_loop(boost::barrier &spawn_barrier){ + spawn_barrier.wait(); set_thread_priority_safe(); libusb_context *context = libusb::session::get_global_session()->get_context(); _threads_running = true; diff --git a/host/lib/usrp/usrp1/soft_time_ctrl.cpp b/host/lib/usrp/usrp1/soft_time_ctrl.cpp index e1b671811..1bab34e7b 100644 --- a/host/lib/usrp/usrp1/soft_time_ctrl.cpp +++ b/host/lib/usrp/usrp1/soft_time_ctrl.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -43,10 +44,11 @@ public: _stream_on_off(stream_on_off) { //synchronously spawn a new thread - _update_mutex.lock(); //lock mutex before spawned - _thread_group.create_thread(boost::bind(&soft_time_ctrl_impl::recv_cmd_dispatcher, this)); - _update_mutex.lock(); //lock blocks until spawned - _update_mutex.unlock(); //unlock mutex before done + boost::barrier spawn_barrier(2); + _thread_group.create_thread(boost::bind( + &soft_time_ctrl_impl::recv_cmd_dispatcher, this, boost::ref(spawn_barrier)) + ); + spawn_barrier.wait(); //initialize the time to something this->set_time(time_spec_t(0.0)); @@ -175,8 +177,8 @@ public: _stream_mode = cmd.stream_mode; } - void recv_cmd_dispatcher(void){ - _update_mutex.unlock(); + void recv_cmd_dispatcher(boost::barrier &spawn_barrier){ + spawn_barrier.wait(); try{ boost::any cmd; while (true){ diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 340e9d155..07cbd2432 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -25,7 +25,8 @@ #include #include #include -#include +#include +#include #include using namespace uhd; @@ -209,11 +210,10 @@ struct usrp2_impl::io_impl{ vrt_packet_handler::send_state packet_handler_send_state; //methods and variables for the pirate crew - void recv_pirate_loop(usrp2_mboard_impl::sptr, zero_copy_if::sptr, size_t); + void recv_pirate_loop(boost::barrier &, usrp2_mboard_impl::sptr, zero_copy_if::sptr, size_t); boost::thread_group recv_pirate_crew; bool recv_pirate_crew_raiding; bounded_buffer async_msg_fifo; - boost::mutex spawn_mutex; }; /*********************************************************************** @@ -223,13 +223,15 @@ struct usrp2_impl::io_impl{ * - put async message packets into queue **********************************************************************/ void usrp2_impl::io_impl::recv_pirate_loop( - usrp2_mboard_impl::sptr mboard, zero_copy_if::sptr err_xport, size_t index + boost::barrier &spawn_barrier, + usrp2_mboard_impl::sptr mboard, + zero_copy_if::sptr err_xport, + size_t index ){ + spawn_barrier.wait(); set_thread_priority_safe(); recv_pirate_crew_raiding = true; - spawn_mutex.unlock(); - //store a reference to the flow control monitor (offset by max dsps) flow_control_monitor &fc_mon = *(this->fc_mons[index*usrp2_mboard_impl::MAX_NUM_DSPS]); @@ -286,19 +288,16 @@ void usrp2_impl::io_init(void){ _io_impl = UHD_PIMPL_MAKE(io_impl, (dsp_xports)); //create a new pirate thread for each zc if (yarr!!) + boost::barrier spawn_barrier(_mboards.size()+1); for (size_t i = 0; i < _mboards.size(); i++){ - //lock the unlocked mutex (non-blocking) - _io_impl->spawn_mutex.lock(); //spawn a new pirate to plunder the recv booty _io_impl->recv_pirate_crew.create_thread(boost::bind( &usrp2_impl::io_impl::recv_pirate_loop, - _io_impl.get(), _mboards.at(i), err_xports.at(i), i + _io_impl.get(), boost::ref(spawn_barrier), + _mboards.at(i), err_xports.at(i), i )); - //block here until the spawned thread unlocks - _io_impl->spawn_mutex.lock(); - //exit loop iteration in an unlocked condition - _io_impl->spawn_mutex.unlock(); } + spawn_barrier.wait(); //update mapping here since it didnt b4 when io init not called first update_xport_channel_mapping(); diff --git a/host/lib/usrp/usrp_e100/io_impl.cpp b/host/lib/usrp/usrp_e100/io_impl.cpp index fc6aaeaee..cbab5a761 100644 --- a/host/lib/usrp/usrp_e100/io_impl.cpp +++ b/host/lib/usrp/usrp_e100/io_impl.cpp @@ -23,7 +23,8 @@ #include "../../transport/vrt_packet_handler.hpp" #include #include -#include +#include +#include #include using namespace uhd; @@ -93,7 +94,7 @@ struct usrp_e100_impl::io_impl{ bool continuous_streaming; //a pirate's life is the life for me! - void recv_pirate_loop(usrp_e100_clock_ctrl::sptr); + void recv_pirate_loop(boost::barrier &, usrp_e100_clock_ctrl::sptr); bounded_buffer recv_pirate_booty; bounded_buffer async_msg_fifo; boost::thread_group recv_pirate_crew; @@ -105,8 +106,10 @@ struct usrp_e100_impl::io_impl{ * - while raiding, loot for recv buffers * - put booty into the alignment buffer **********************************************************************/ -void usrp_e100_impl::io_impl::recv_pirate_loop(usrp_e100_clock_ctrl::sptr clock_ctrl) -{ +void usrp_e100_impl::io_impl::recv_pirate_loop( + boost::barrier &spawn_barrier, usrp_e100_clock_ctrl::sptr clock_ctrl +){ + spawn_barrier.wait(); set_thread_priority_safe(); recv_pirate_crew_raiding = true; @@ -201,9 +204,12 @@ void usrp_e100_impl::io_init(void){ _iface->poke32(UE_REG_CTRL_TX_POLICY, UE_FLAG_CTRL_TX_POLICY_NEXT_PACKET); //spawn a pirate, yarrr! + boost::barrier spawn_barrier(2); _io_impl->recv_pirate_crew.create_thread(boost::bind( - &usrp_e100_impl::io_impl::recv_pirate_loop, _io_impl.get(), _clock_ctrl + &usrp_e100_impl::io_impl::recv_pirate_loop, _io_impl.get(), + boost::ref(spawn_barrier), _clock_ctrl )); + spawn_barrier.wait(); } void usrp_e100_impl::issue_stream_cmd(const stream_cmd_t &stream_cmd){ -- cgit v1.2.3 From 1721352e905e10dbff48d44b66b1684020a103d7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 10:27:54 -0700 Subject: uhd: install dlls into runtime path, updated docs --- host/docs/build.rst | 4 +--- host/docs/index.rst | 4 +--- host/lib/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/host/docs/build.rst b/host/docs/build.rst index b81e25de1..c645817ab 100644 --- a/host/docs/build.rst +++ b/host/docs/build.rst @@ -197,9 +197,7 @@ Open the Visual Studio Command Prompt Shorcut: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Setup the PATH environment variable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -* Add the boost library path to %PATH% (usually c:\\program files\\boost\\\\lib) -* Add the uhd library path to %PATH% (usually c:\\program files\\uhd\\lib) -* Add the libusb library to %PATH% (if using usb support) +* Add the uhd bin path to %PATH% (usually c:\\program files\\uhd\\bin) **Note:** The interface for editing environment variable paths in Windows is very poor. diff --git a/host/docs/index.rst b/host/docs/index.rst index 734300164..467d5f385 100644 --- a/host/docs/index.rst +++ b/host/docs/index.rst @@ -4,9 +4,7 @@ UHD - Universal Hardware Driver The UHD is the universal hardware driver for Ettus Research products. The goal of the UHD is to provide a host driver and api for current and future Ettus Research products. -Users will be able to use the UHD driver standalone/without gnuradio. -Also, a dual license option will be available for those who build against the UHD -but cannot release their software products under the GPL. +Users will be able to use the UHD driver standalone or with 3rd party applications. ------------------------------------------------------------------------ Contents diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 54f4893e3..f8886566a 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -121,5 +121,5 @@ ENDIF(DEFINED LIBUHD_OUTPUT_NAME) INSTALL(TARGETS uhd LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .so file ARCHIVE DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .lib file - RUNTIME DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .dll file + RUNTIME DESTINATION ${RUNTIME_DIR} COMPONENT libraries # .dll file ) -- cgit v1.2.3 From 592af4a86be7309a858e04d1e930d8ac6932db18 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 10:28:58 -0700 Subject: uhd: disable visibility=hidden on non-dll platforms (cygwin) --- host/CMakeLists.txt | 6 ++++-- host/include/uhd/config.hpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 244793b9e..606742865 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -72,8 +72,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX) ADD_DEFINITIONS(-Wextra) #ADD_DEFINITIONS(-pedantic) #ADD_DEFINITIONS(-ansi) - #only export symbols that are declared to be part of the uhd api: - UHD_ADD_OPTIONAL_CXX_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN) + IF(NOT WIN32) + #only export symbols that are declared to be part of the uhd api (non dll platforms) + UHD_ADD_OPTIONAL_CXX_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN) + ENDIF(NOT WIN32) ENDIF(CMAKE_COMPILER_IS_GNUCXX) IF(MSVC) diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index 1a04680e9..fdb168950 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -49,7 +49,7 @@ typedef ptrdiff_t ssize_t; #endif //BOOST_MSVC //define cross platform attribute macros -#if defined(BOOST_MSVC) || defined(BOOST_HAS_DECLSPEC) +#if defined(BOOST_HAS_DECLSPEC) #define UHD_EXPORT __declspec(dllexport) #define UHD_IMPORT __declspec(dllimport) #define UHD_INLINE __forceinline -- cgit v1.2.3 From 6e61e3e495d716e9a82415cbbd83e2133a181a25 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 10:42:56 -0700 Subject: uhd: increment patch number for next release --- host/Modules/UHDVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index 78bf7f690..eb25db488 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -27,7 +27,7 @@ FIND_PACKAGE(Git QUIET) ######################################################################## SET(UHD_VERSION_MAJOR 003) SET(UHD_VERSION_MINOR 000) -SET(UHD_VERSION_PATCH 000) +SET(UHD_VERSION_PATCH 001) ######################################################################## # Version information discovery through git log -- cgit v1.2.3 From 3a1f6c51429cfc195c08f4e327e4e83bf997f911 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 12:02:43 -0700 Subject: uhd: added images and readme installer component --- host/CMakeLists.txt | 4 ++-- host/Modules/UHDPackage.cmake | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 290ffdc7d..3808481bf 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -173,7 +173,7 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt ${CMAKE_CURRENT_SOURCE_DIR}/AUTHORS.txt DESTINATION ${PKG_DOC_DIR} - COMPONENT libraries + COMPONENT readme ) ######################################################################## @@ -215,7 +215,7 @@ ADD_SUBDIRECTORY(usrp_e_utils) IF(DEFINED UHD_IMAGES_DIR AND EXISTS "${UHD_IMAGES_DIR}") FILE(GLOB _image_files "${UHD_IMAGES_DIR}/*.*") MESSAGE(STATUS "Using images: ${_image_files}") - INSTALL(FILES ${_image_files} DESTINATION ${PKG_DATA_DIR}/images) + INSTALL(FILES ${_image_files} DESTINATION ${PKG_DATA_DIR}/images COMPONENT images) ENDIF(DEFINED UHD_IMAGES_DIR AND EXISTS "${UHD_IMAGES_DIR}") ######################################################################## diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index ef1a82c9a..7fee51741 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -90,6 +90,7 @@ SET(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") SET(CPACK_COMPONENT_TESTS_GROUP "Runtime") SET(CPACK_COMPONENT_MANUAL_GROUP "Documentation") SET(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") +SET(CPACK_COMPONENT_README_GROUP "Documentation") SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") @@ -98,12 +99,26 @@ SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples") SET(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Unit Tests") SET(CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Manual") SET(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") +SET(CPACK_COMPONENT_README_DISPLAY_NAME "Readme") +SET(CPACK_COMPONENT_IMAGES_DISPLAY_NAME "Images") + +SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic link library") +SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ development headers") +SET(CPACK_COMPONENT_UTILITIES_DESCRIPTION "Utility executables and python scripts") +SET(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example executables") +SET(CPACK_COMPONENT_TESTS_DESCRIPTION "Unit test executables") +SET(CPACK_COMPONENT_MANUAL_DESCRIPTION "Manual/application notes (rst and html)") +SET(CPACK_COMPONENT_DOXYGEN_DESCRIPTION "API documentation (html)") +SET(CPACK_COMPONENT_README_DESCRIPTION "Readme files (txt)") +SET(CPACK_COMPONENT_IMAGES_DESCRIPTION "FPGA and firmware images") + +SET(CPACK_COMPONENT_README_REQUIRED TRUE) SET(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) SET(CPACK_COMPONENT_TESTS_DEPENDS libraries) -SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxygen) +SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxygen readme images) ######################################################################## # Setup CPack Debian -- cgit v1.2.3 From 81e891f3f38259e7450b454933c979f2d8c93d65 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 12:06:08 -0700 Subject: uhd: setup INSTALLER_PKG_DATA_DIR for windows systems --- host/lib/CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index f8886566a..e65a2d2ba 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -79,7 +79,7 @@ INCLUDE_SUBDIRECTORY(usrp) INCLUDE_SUBDIRECTORY(utils) ######################################################################## -# Append to the list of sources for lib uhd +# Setup compiled-in constants for data directories ######################################################################## FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} LOCAL_PKG_DATA_DIR) STRING(REPLACE "\\" "\\\\" LOCAL_PKG_DATA_DIR ${LOCAL_PKG_DATA_DIR}) @@ -88,9 +88,12 @@ MESSAGE(STATUS "Local package data directory: ${LOCAL_PKG_DATA_DIR}") IF(UNIX) #on unix systems, installers will use this directory for the package data FILE(TO_NATIVE_PATH /usr/${PKG_DATA_DIR} INSTALLER_PKG_DATA_DIR) - STRING(REPLACE "\\" "\\\\" INSTALLER_PKG_DATA_DIR ${INSTALLER_PKG_DATA_DIR}) - MESSAGE(STATUS "Installer package data directory: ${INSTALLER_PKG_DATA_DIR}") -ENDIF(UNIX) +ELSE() + #for the NSIS installer, this will be the default path for package data + FILE(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX} ${UHD_VERSION}/${PKG_DATA_DIR}" INSTALLER_PKG_DATA_DIR) +ENDIF() +STRING(REPLACE "\\" "\\\\" INSTALLER_PKG_DATA_DIR ${INSTALLER_PKG_DATA_DIR}) +MESSAGE(STATUS "Installer package data directory: ${INSTALLER_PKG_DATA_DIR}") CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp.in @@ -98,6 +101,9 @@ CONFIGURE_FILE( @ONLY) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +######################################################################## +# Append to the list of sources for lib uhd +######################################################################## LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_BINARY_DIR}/constants.hpp ${CMAKE_CURRENT_SOURCE_DIR}/device.cpp -- cgit v1.2.3 From 83c608e17de45fd5372f05b54f343c721e25ad82 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 1 Apr 2011 15:54:51 -0700 Subject: uhd: define LINUX in build system to simplify some checks --- host/Modules/UHDPackage.cmake | 4 ++++ host/lib/usrp/usrp_e100/CMakeLists.txt | 6 +----- host/usrp_e_utils/CMakeLists.txt | 6 +----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 7fee51741..7ac677d28 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -29,6 +29,10 @@ IF(UNIX AND EXISTS "/etc/redhat-release") SET(REDHAT TRUE) ENDIF() +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX TRUE) +ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + ######################################################################## # Setup package file name ######################################################################## diff --git a/host/lib/usrp/usrp_e100/CMakeLists.txt b/host/lib/usrp/usrp_e100/CMakeLists.txt index acbac177e..d0e20a3d8 100644 --- a/host/lib/usrp/usrp_e100/CMakeLists.txt +++ b/host/lib/usrp/usrp_e100/CMakeLists.txt @@ -22,11 +22,7 @@ ######################################################################## # Conditionally configure the USRP-E100 support ######################################################################## -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(LINUX_TARGET TRUE) -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - -LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD;LINUX_TARGET" OFF) +LIBUHD_REGISTER_COMPONENT("USRP-E100" ENABLE_USRP_E100 OFF "ENABLE_LIBUHD;LINUX" OFF) IF(ENABLE_USRP_E100) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/host/usrp_e_utils/CMakeLists.txt b/host/usrp_e_utils/CMakeLists.txt index f3537e542..e7d6ae4b8 100644 --- a/host/usrp_e_utils/CMakeLists.txt +++ b/host/usrp_e_utils/CMakeLists.txt @@ -18,11 +18,7 @@ ######################################################################## # USRP embedded utilities that get installed into the share path ######################################################################## -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(LINUX_TARGET TRUE) -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - -LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX_TARGET" OFF) +LIBUHD_REGISTER_COMPONENT("USRP-E Utils" ENABLE_USRP_E_UTILS OFF "LINUX" OFF) IF(ENABLE_USRP_E_UTILS) ENABLE_LANGUAGE(C) -- cgit v1.2.3 From 721194ec0f832dd9fa7b905bb9ac7b0a06da975e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 2 Apr 2011 15:22:16 -0700 Subject: images: create a tag file to associate the version number w/ images --- images/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/images/CMakeLists.txt b/images/CMakeLists.txt index f93b28ca4..dd6702e04 100644 --- a/images/CMakeLists.txt +++ b/images/CMakeLists.txt @@ -40,4 +40,6 @@ MESSAGE(STATUS "Version: ${CPACK_PACKAGE_VERSION}") ######################################################################## # Install Images ######################################################################## +#tag the images with a version number (something identifiable) +FILE(WRITE ${CMAKE_SOURCE_DIR}/images/${CPACK_PACKAGE_VERSION}.tag ${UHD_BUILD_INFO}) INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/images DESTINATION share/uhd) -- cgit v1.2.3 From 7cd216e967161a0d3a4d7b9bc03583d270ce4de3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 4 Apr 2011 13:10:06 -0700 Subject: uhd: specify msvc for implementations known only to work on msvc --- host/CMakeLists.txt | 9 +++++++-- host/Modules/UHDPackage.cmake | 12 ++++++------ host/include/uhd/config.hpp | 2 +- host/include/uhd/utils/byteswap.ipp | 6 +++--- host/lib/transport/CMakeLists.txt | 4 ++-- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 3808481bf..7df04995c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -80,16 +80,21 @@ ENDIF(CMAKE_COMPILER_IS_GNUCXX) IF(MSVC) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/msvc) - ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) #minimum version required is windows xp - ADD_DEFINITIONS(-DNOMINMAX) #disables stupidity and enables std::min and std::max ADD_DEFINITIONS( #stop all kinds of compatibility warnings -D_SCL_SECURE_NO_WARNINGS + -D_SCL_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE + -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE ) ENDIF(MSVC) +IF(WIN32) + ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) #minimum version required is windows xp + ADD_DEFINITIONS(-DNOMINMAX) #disables stupidity and enables std::min and std::max +ENDIF(WIN32) + ######################################################################## # Setup Boost ######################################################################## diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 7ac677d28..4986e314c 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -21,18 +21,18 @@ INCLUDE(UHDVersion) #sets version information ######################################################################## # Setup additional defines for OS types ######################################################################## -IF(UNIX AND EXISTS "/etc/debian_version") +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + SET(LINUX TRUE) +ENDIF() + +IF(LINUX AND EXISTS "/etc/debian_version") SET(DEBIAN TRUE) ENDIF() -IF(UNIX AND EXISTS "/etc/redhat-release") +IF(LINUX AND EXISTS "/etc/redhat-release") SET(REDHAT TRUE) ENDIF() -IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(LINUX TRUE) -ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - ######################################################################## # Setup package file name ######################################################################## diff --git a/host/include/uhd/config.hpp b/host/include/uhd/config.hpp index fdb168950..6fd2932cf 100644 --- a/host/include/uhd/config.hpp +++ b/host/include/uhd/config.hpp @@ -49,7 +49,7 @@ typedef ptrdiff_t ssize_t; #endif //BOOST_MSVC //define cross platform attribute macros -#if defined(BOOST_HAS_DECLSPEC) +#if defined(BOOST_MSVC) #define UHD_EXPORT __declspec(dllexport) #define UHD_IMPORT __declspec(dllimport) #define UHD_INLINE __forceinline diff --git a/host/include/uhd/utils/byteswap.ipp b/host/include/uhd/utils/byteswap.ipp index a070a7cf5..c090dee55 100644 --- a/host/include/uhd/utils/byteswap.ipp +++ b/host/include/uhd/utils/byteswap.ipp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -21,8 +21,8 @@ /*********************************************************************** * Platform-specific implementation details for byteswap below: **********************************************************************/ -#if defined(UHD_PLATFORM_WIN32) //http://msdn.microsoft.com/en-us/library/a3140177%28VS.80%29.aspx - #include +#if defined(BOOST_MSVC) //http://msdn.microsoft.com/en-us/library/a3140177%28VS.80%29.aspx + #include UHD_INLINE boost::uint16_t uhd::byteswap(boost::uint16_t x){ return _byteswap_ushort(x); diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 656ca9987..a7179d561 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -31,10 +31,10 @@ IF(ENABLE_USB) MESSAGE(STATUS "USB support enabled via libusb.") INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR}) LIBUHD_APPEND_LIBS(${LIBUSB_LIBRARIES}) - IF(WIN32) + IF(MSVC) #needed when statically linking libusb LIBUHD_APPEND_LIBS(Setupapi.lib) - ENDIF(WIN32) + ENDIF(MSVC) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp -- cgit v1.2.3 From 1ba366a94ef70980fb5db5dd0142c3d3596ef9aa Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 4 Apr 2011 16:09:02 -0700 Subject: usb: newer libusb1 does not need to link with setupapi.lib --- host/lib/transport/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index a7179d561..a5bf9c5f1 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -31,10 +31,6 @@ IF(ENABLE_USB) MESSAGE(STATUS "USB support enabled via libusb.") INCLUDE_DIRECTORIES(${LIBUSB_INCLUDE_DIR}) LIBUHD_APPEND_LIBS(${LIBUSB_LIBRARIES}) - IF(MSVC) - #needed when statically linking libusb - LIBUHD_APPEND_LIBS(Setupapi.lib) - ENDIF(MSVC) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_control.cpp ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp -- cgit v1.2.3 From dcd555636c282ac0454b463c91d360ce062e316d Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 4 Apr 2011 16:22:38 -0700 Subject: uhd: set CPACK_PACKAGE_INSTALL_DIRECTORY on NSIS so we dont get an inconsistent version suffix --- host/Modules/UHDPackage.cmake | 4 ++++ host/lib/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 4986e314c..bf31df3b3 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -69,6 +69,10 @@ IF(UHD_RELEASE_MODE) ENDIF(LSB_RELEASE_EXECUTABLE) + IF(${CPACK_GENERATOR} STREQUAL NSIS) + SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CMAKE_PROJECT_NAME}") + ENDIF() + ENDIF(UHD_RELEASE_MODE) ######################################################################## diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index e65a2d2ba..8ca7c7dca 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -90,7 +90,7 @@ IF(UNIX) FILE(TO_NATIVE_PATH /usr/${PKG_DATA_DIR} INSTALLER_PKG_DATA_DIR) ELSE() #for the NSIS installer, this will be the default path for package data - FILE(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX} ${UHD_VERSION}/${PKG_DATA_DIR}" INSTALLER_PKG_DATA_DIR) + FILE(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR}" INSTALLER_PKG_DATA_DIR) ENDIF() STRING(REPLACE "\\" "\\\\" INSTALLER_PKG_DATA_DIR ${INSTALLER_PKG_DATA_DIR}) MESSAGE(STATUS "Installer package data directory: ${INSTALLER_PKG_DATA_DIR}") -- cgit v1.2.3 From 6a2fbe07e7674794a883a7062ce2225781cf5193 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 4 Apr 2011 16:51:17 -0700 Subject: uhd: a few minor changes to get uhd building under mingw or cygwin --- host/lib/CMakeLists.txt | 8 ++++++++ host/tests/CMakeLists.txt | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 8ca7c7dca..268f05df6 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -68,6 +68,14 @@ MACRO(INCLUDE_SUBDIRECTORY subdir) LIST(REMOVE_AT _cmake_binary_dirs 0) ENDMACRO(INCLUDE_SUBDIRECTORY) +######################################################################## +# Cygwin special +######################################################################## +IF(CYGWIN) + ADD_DEFINITIONS(-D__USE_W32_SOCKETS) #boost asio says we need this + LIBUHD_APPEND_LIBS(ws2_32) +ENDIF(CYGWIN) + ######################################################################## # Include subdirectories (different than add) ######################################################################## diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index 821b2eb9e..f08fe669b 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -50,5 +50,7 @@ ENDFOREACH(test_source) ######################################################################## # demo of a loadable module ######################################################################## -ADD_LIBRARY(module_test MODULE module_test.cpp) -TARGET_LINK_LIBRARIES(module_test uhd) +IF(MSVC OR APPLE OR LINUX) + ADD_LIBRARY(module_test MODULE module_test.cpp) + TARGET_LINK_LIBRARIES(module_test uhd) +ENDIF() -- cgit v1.2.3 From af2ab1c688d641e82060016aa772432de6445633 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 15:32:41 -0700 Subject: uhd: replace with in docs for clarity --- host/docs/build.rst | 2 +- host/docs/dboards.rst | 4 ++-- host/docs/general.rst | 2 +- host/docs/identification.rst | 2 +- host/docs/images.rst | 4 ++-- host/docs/usrp2.rst | 18 +++++++++--------- host/docs/usrp_e1xx.rst | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/host/docs/build.rst b/host/docs/build.rst index c645817ab..063b2b371 100644 --- a/host/docs/build.rst +++ b/host/docs/build.rst @@ -116,7 +116,7 @@ Generate Makefiles with cmake Additionally, configuration variables can be passed into cmake via the command line. The following common-use configuration variables are listed below: -* For a custom install prefix: -DCMAKE_INSTALL_PREFIX= +* For a custom install prefix: -DCMAKE_INSTALL_PREFIX= * To install libs into lib64: cmake -DLIB_SUFFIX=64 Example usage: diff --git a/host/docs/dboards.rst b/host/docs/dboards.rst index 7f205c404..419456df2 100644 --- a/host/docs/dboards.rst +++ b/host/docs/dboards.rst @@ -182,7 +182,7 @@ If you lose R193, you can use anything from 0 to 10 ohms there. With the daughterboard plugged-in, run the following commands: :: - cd /share/uhd/utils + cd /share/uhd/utils ./usrp_burn_db_eeprom --id=0x000d --unit=RX --args= --slot= * are device address arguments (optional if only one USRP is on your machine) @@ -209,7 +209,7 @@ These are all 0-ohm, so if you lose one, just short across the appropriate pads With the daughterboard plugged-in, run the following commands: :: - cd /share/uhd/utils + cd /share/uhd/utils ./usrp_burn_db_eeprom --id= --unit=RX --args= --slot= ./usrp_burn_db_eeprom --id= --unit=TX --args= --slot= diff --git a/host/docs/general.rst b/host/docs/general.rst index 2894fbf88..73b820c84 100644 --- a/host/docs/general.rst +++ b/host/docs/general.rst @@ -52,5 +52,5 @@ Support for dynamically loadable modules For a module to be loaded at runtime, it must be: * found in the UHD_MODULE_PATH environment variable, -* installed into the /share/uhd/modules directory, +* installed into the /share/uhd/modules directory, * or installed into /usr/share/uhd/modules directory (unix only). diff --git a/host/docs/identification.rst b/host/docs/identification.rst index 90484744c..deda61531 100644 --- a/host/docs/identification.rst +++ b/host/docs/identification.rst @@ -107,7 +107,7 @@ Set a custom name Run the following commands: :: - cd /share/uhd/utils + cd /share/uhd/utils ./usrp_burn_mb_eeprom --args= --key=name --val=lab1_xcvr ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/host/docs/images.rst b/host/docs/images.rst index f5be88a65..adfa6d530 100644 --- a/host/docs/images.rst +++ b/host/docs/images.rst @@ -54,8 +54,8 @@ When installing images from an archive, there are two options: **Option 1:** Unpack the archive into the UHD installation prefix. -The UHD will always search /share/uhd/images for image files. -Where was set by the CMAKE_INSTALL_PREFIX at configure-time. +The UHD will always search /share/uhd/images for image files. +Where was set by the CMAKE_INSTALL_PREFIX at configure-time. **Option 2:** diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index 912f7d2bd..161170f2c 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -25,11 +25,11 @@ Use the card burner tool (unix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - sudo /share/uhd/utils/usrp2_card_burner_gui.py + sudo /share/uhd/utils/usrp2_card_burner_gui.py -- OR -- - cd /share/uhd/utils + cd /share/uhd/utils sudo ./usrp2_card_burner.py --dev=/dev/sd --fpga= sudo ./usrp2_card_burner.py --dev=/dev/sd --fw= @@ -42,7 +42,7 @@ Use the card burner tool (windows) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - /share/uhd/utils/usrp2_card_burner_gui.py + /share/uhd/utils/usrp2_card_burner_gui.py ------------------------------------------------------------------------ @@ -58,11 +58,11 @@ Use the net burner tool (unix) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - sudo /share/uhd/utils/usrp_n2xx_net_burner_gui.py + sudo /share/uhd/utils/usrp_n2xx_net_burner_gui.py -- OR -- - cd /share/uhd/utils + cd /share/uhd/utils ./usrp_n2xx_net_burner.py --addr= --fw= ./usrp_n2xx_net_burner.py --addr= --fpga= @@ -71,7 +71,7 @@ Use the net burner tool (Windows) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :: - /share/uhd/utils/usrp_n2xx_net_burner_gui.py + /share/uhd/utils/usrp_n2xx_net_burner_gui.py ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Device recovery and bricking @@ -145,7 +145,7 @@ and the network must be setup properly as described above. Run the following commands: :: - cd /share/uhd/utils + cd /share/uhd/utils ./usrp_burn_mb_eeprom --args= --key=ip-addr --val=192.168.10.3 **Method 2 (Linux Only):** @@ -154,7 +154,7 @@ It uses raw ethernet packets to bypass the IP/UDP layer to communicate with the Run the following commands: :: - cd /share/uhd/utils + cd /share/uhd/utils sudo ./usrp2_recovery.py --ifc=eth0 --new-ip=192.168.10.3 ------------------------------------------------------------------------ @@ -343,5 +343,5 @@ Test the PPS input with the following app: :: - cd /share/uhd/examples + cd /share/uhd/examples ./test_pps_input --args= diff --git a/host/docs/usrp_e1xx.rst b/host/docs/usrp_e1xx.rst index ffcd370dd..fb5848bad 100644 --- a/host/docs/usrp_e1xx.rst +++ b/host/docs/usrp_e1xx.rst @@ -61,5 +61,5 @@ can talk directly to the clock generator over a SPI interface. Run the following commands to restore the clock generator to a usable state: :: - cd /share/uhd/usrp_e_utilities + cd /share/uhd/usrp_e_utilities ./usrp-e-utility --fpga=../images/usrp_e100_pt_fpga.bin --reclk -- cgit v1.2.3 From dbfbc497a8e0a144e0db2b8daa0f4baba5284775 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 16:32:48 -0700 Subject: uhd: tweaks for cygwin/mingw, always link winsock2, findusb1, __USE_W32_SOCKETS --- host/CMakeLists.txt | 4 ++++ host/Modules/FindUSB1.cmake | 6 +++--- host/lib/CMakeLists.txt | 8 -------- host/lib/transport/CMakeLists.txt | 4 ++++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 7df04995c..552fe492c 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -90,6 +90,10 @@ IF(MSVC) ) ENDIF(MSVC) +IF(CYGWIN) + ADD_DEFINITIONS(-D__USE_W32_SOCKETS) #boost asio says we need this +ENDIF(CYGWIN) + IF(WIN32) ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) #minimum version required is windows xp ADD_DEFINITIONS(-DNOMINMAX) #disables stupidity and enables std::min and std::max diff --git a/host/Modules/FindUSB1.cmake b/host/Modules/FindUSB1.cmake index ebcac99eb..efb2e288b 100644 --- a/host/Modules/FindUSB1.cmake +++ b/host/Modules/FindUSB1.cmake @@ -17,12 +17,12 @@ if (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) set(LIBUSB_FOUND TRUE) else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES) - IF (NOT WIN32) # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls find_package(PkgConfig) - pkg_check_modules(PC_LIBUSB libusb-1.0) - ENDIF(NOT WIN32) + IF(PKG_CONFIG_FOUND) + pkg_check_modules(PC_LIBUSB libusb-1.0) + ENDIF(PKG_CONFIG_FOUND) FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS}) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 268f05df6..8ca7c7dca 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -68,14 +68,6 @@ MACRO(INCLUDE_SUBDIRECTORY subdir) LIST(REMOVE_AT _cmake_binary_dirs 0) ENDMACRO(INCLUDE_SUBDIRECTORY) -######################################################################## -# Cygwin special -######################################################################## -IF(CYGWIN) - ADD_DEFINITIONS(-D__USE_W32_SOCKETS) #boost asio says we need this - LIBUHD_APPEND_LIBS(ws2_32) -ENDIF(CYGWIN) - ######################################################################## # Include subdirectories (different than add) ######################################################################## diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index a5bf9c5f1..30f8db48a 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -79,6 +79,10 @@ SET_SOURCE_FILES_PROPERTIES( PROPERTIES COMPILE_DEFINITIONS "${IF_ADDRS_DEFS}" ) +IF(WIN32 AND UNIX) #MinGW/Cygwin needs winsock2 + LIBUHD_APPEND_LIBS(ws2_32) +ENDIF() + ######################################################################## # Append to the list of sources for lib uhd ######################################################################## -- cgit v1.2.3 From 0722225484cf3cd72db9220285e63accd7310eee Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 17:19:17 -0700 Subject: usrp2: ran 2to3 on python apps and make corrections for old imports to work --- host/utils/usrp2_card_burner.py | 38 ++++++++------- host/utils/usrp2_card_burner_gui.py | 87 ++++++++++++++++++---------------- host/utils/usrp2_recovery.py | 12 ++--- host/utils/usrp_n2xx_net_burner.py | 68 +++++++++++++------------- host/utils/usrp_n2xx_net_burner_gui.py | 75 ++++++++++++++++------------- 5 files changed, 149 insertions(+), 131 deletions(-) mode change 100755 => 100644 host/utils/usrp2_card_burner.py mode change 100755 => 100644 host/utils/usrp2_card_burner_gui.py mode change 100755 => 100644 host/utils/usrp2_recovery.py mode change 100755 => 100644 host/utils/usrp_n2xx_net_burner.py mode change 100755 => 100644 host/utils/usrp_n2xx_net_burner_gui.py diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py old mode 100755 new mode 100644 index 1db5e59ce..cb3cc53f6 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,11 @@ import platform import tempfile import subprocess -import urllib +try: + import urllib.request +except ImportError: + import urllib + urllib.request = urllib import optparse import math import os @@ -47,15 +51,15 @@ def command(*args): ) ret = p.wait() verbose = p.stdout.read() - if ret != 0: raise Exception, verbose + if ret != 0: raise Exception(verbose) return verbose def get_dd_path(): if platform.system() == 'Windows': dd_path = os.path.join(tempfile.gettempdir(), 'dd.exe') if not os.path.exists(dd_path): - print 'Downloading dd.exe to %s'%dd_path - dd_bin = urllib.urlopen('http://www.ettus.com/downloads/dd.exe').read() + print('Downloading dd.exe to %s'%dd_path) + dd_bin = urllib.request.urlopen('http://www.ettus.com/downloads/dd.exe').read() open(dd_path, 'wb').write(dd_bin) return dd_path return 'dd' @@ -80,7 +84,7 @@ def get_raw_device_hints(): return info.split(key)[-1].split()[0] def get_info_list(output): in_info = False - for line in output.splitlines(): + for line in str(output).splitlines(): if line.startswith('\\\\'): in_info = True; info = '' elif in_info and not line.strip(): in_info = False; yield info if in_info: info += '\n'+line.strip() @@ -97,7 +101,7 @@ def get_raw_device_hints(): if key in info: return extract_info_value(info, key) return info.splitlines()[0].strip() - return sorted(set(map(extract_info_name, filter(is_info_valid, get_info_list(command(get_dd_path(), '--list')))))) + return sorted(set(map(extract_info_name, list(filter(is_info_valid, get_info_list(command(get_dd_path(), '--list'))))))) #################################################################### # Platform Linux: parse procfs /proc/partitions @@ -120,15 +124,15 @@ def get_raw_device_hints(): # Platform Mac OS X: parse diskutil list and info commands #################################################################### if platform.system() == 'Darwin': - devs = map(lambda d: d.split()[0], filter(lambda l: l.startswith('/dev'), command('diskutil', 'list').splitlines())) + devs = [d.split()[0] for d in [l for l in command('diskutil', 'list').splitlines() if l.startswith('/dev')]] def output_to_info(output): - return dict([map(str.strip, pair.lower().split(':')) for pair in filter(lambda l: ':' in l, output.splitlines())]) + return dict([list(map(str.strip, pair.lower().split(':'))) for pair in [l for l in output.splitlines() if ':' in l]]) def is_dev_valid(dev): info = output_to_info(command('diskutil', 'info', dev)) try: - if info.has_key('internal'): assert info['internal'] == 'no' - if info.has_key('ejectable'): assert info['ejectable'] == 'yes' - if info.has_key('total size'): + if 'internal' in info: assert info['internal'] == 'no' + if 'ejectable' in info: assert info['ejectable'] == 'yes' + if 'total size' in info: size_match = re.match('^.*\((\d+)\s*bytes\).*$', info['total size']) if size_match: assert int(size_match.groups()[0]) <= MAX_SD_CARD_SIZE return True @@ -196,7 +200,7 @@ def write_image(image_file, device_file, offset): def write_and_verify(image_file, device_file, offset): if os.path.getsize(image_file) > MAX_FILE_SIZE: - raise Exception, 'Image file larger than %d bytes!'%MAX_FILE_SIZE + raise Exception('Image file larger than %d bytes!'%MAX_FILE_SIZE) return '%s\n%s'%( write_image( image_file=image_file, @@ -231,8 +235,8 @@ def get_options(): (options, args) = parser.parse_args() if options.list: - print 'Possible raw devices:' - print ' ' + '\n '.join(get_raw_device_hints()) + print('Possible raw devices:') + print(' ' + '\n '.join(get_raw_device_hints())) exit() return options @@ -242,5 +246,5 @@ def get_options(): ######################################################################## if __name__=='__main__': options = get_options() - if not options.dev: raise Exception, 'no raw device path specified' - print burn_sd_card(dev=options.dev, fw=options.fw, fpga=options.fpga) + if not options.dev: raise Exception('no raw device path specified') + print(burn_sd_card(dev=options.dev, fw=options.fw, fpga=options.fpga)) diff --git a/host/utils/usrp2_card_burner_gui.py b/host/utils/usrp2_card_burner_gui.py old mode 100755 new mode 100644 index 58b7a514a..2941629b9 --- a/host/utils/usrp2_card_burner_gui.py +++ b/host/utils/usrp2_card_burner_gui.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,10 +17,17 @@ # import usrp2_card_burner #import implementation -import Tkinter, tkFileDialog, tkFont, tkMessageBox +try: + import tkinter, tkinter.filedialog, tkinter.font, tkinter.messagebox +except ImportError: + import tkFileDialog, tkFont, tkMessageBox + import Tkinter as tkinter + tkinter.filedialog = tkFileDialog + tkinter.font = tkFont + tkinter.messagebox = tkMessageBox import os -class BinFileEntry(Tkinter.Frame): +class BinFileEntry(tkinter.Frame): """ Simple file entry widget for getting the file path of bin files. Combines a label, entry, and button with file dialog callback. @@ -28,15 +35,15 @@ class BinFileEntry(Tkinter.Frame): def __init__(self, root, what, def_path=''): self._what = what - Tkinter.Frame.__init__(self, root) - Tkinter.Label(self, text=what+":").pack(side=Tkinter.LEFT) - self._entry = Tkinter.Entry(self, width=50) - self._entry.insert(Tkinter.END, def_path) - self._entry.pack(side=Tkinter.LEFT) - Tkinter.Button(self, text="...", command=self._button_cb).pack(side=Tkinter.LEFT) + tkinter.Frame.__init__(self, root) + tkinter.Label(self, text=what+":").pack(side=tkinter.LEFT) + self._entry = tkinter.Entry(self, width=50) + self._entry.insert(tkinter.END, def_path) + self._entry.pack(side=tkinter.LEFT) + tkinter.Button(self, text="...", command=self._button_cb).pack(side=tkinter.LEFT) def _button_cb(self): - filename = tkFileDialog.askopenfilename( + filename = tkinter.filedialog.askopenfilename( parent=self, filetypes=[('bin files', '*.bin'), ('all files', '*.*')], title="Select bin file for %s"%self._what, @@ -45,65 +52,65 @@ class BinFileEntry(Tkinter.Frame): # open file on your own if filename: - self._entry.delete(0, Tkinter.END) + self._entry.delete(0, tkinter.END) self._entry.insert(0, filename) def get_filename(self): return self._entry.get() -class DeviceEntryWidget(Tkinter.Frame): +class DeviceEntryWidget(tkinter.Frame): """ Simple entry widget for getting the raw device name. Combines a label, entry, and helpful text box with hints. """ def __init__(self, root, text=''): - Tkinter.Frame.__init__(self, root) + tkinter.Frame.__init__(self, root) - Tkinter.Button(self, text="Rescan for Devices", command=self._reload_cb).pack() + tkinter.Button(self, text="Rescan for Devices", command=self._reload_cb).pack() - self._hints = Tkinter.Listbox(self) + self._hints = tkinter.Listbox(self) self._hints.bind("<>", self._listbox_cb) self._reload_cb() - self._hints.pack(expand=Tkinter.YES, fill=Tkinter.X) + self._hints.pack(expand=tkinter.YES, fill=tkinter.X) - frame = Tkinter.Frame(self) + frame = tkinter.Frame(self) frame.pack() - Tkinter.Label(frame, text="Raw Device:").pack(side=Tkinter.LEFT) - self._entry = Tkinter.Entry(frame, width=50) - self._entry.insert(Tkinter.END, text) - self._entry.pack(side=Tkinter.LEFT) + tkinter.Label(frame, text="Raw Device:").pack(side=tkinter.LEFT) + self._entry = tkinter.Entry(frame, width=50) + self._entry.insert(tkinter.END, text) + self._entry.pack(side=tkinter.LEFT) def _reload_cb(self): - self._hints.delete(0, Tkinter.END) + self._hints.delete(0, tkinter.END) for hint in usrp2_card_burner.get_raw_device_hints(): - self._hints.insert(Tkinter.END, hint) + self._hints.insert(tkinter.END, hint) def _listbox_cb(self, event): try: sel = self._hints.get(self._hints.curselection()[0]) - self._entry.delete(0, Tkinter.END) + self._entry.delete(0, tkinter.END) self._entry.insert(0, sel) - except Exception, e: print e + except Exception as e: print(e) def get_devname(self): return self._entry.get() -class SectionLabel(Tkinter.Label): +class SectionLabel(tkinter.Label): """ Make a text label with bold font. """ def __init__(self, root, text): - Tkinter.Label.__init__(self, root, text=text) + tkinter.Label.__init__(self, root, text=text) #set the font bold - f = tkFont.Font(font=self['font']) + f = tkinter.font.Font(font=self['font']) f['weight'] = 'bold' self['font'] = f.name -class USRP2CardBurnerApp(Tkinter.Frame): +class USRP2CardBurnerApp(tkinter.Frame): """ The top level gui application for the usrp2 sd card burner. Creates entry widgets and button with callback to write images. @@ -111,7 +118,7 @@ class USRP2CardBurnerApp(Tkinter.Frame): def __init__(self, root, dev, fw, fpga): - Tkinter.Frame.__init__(self, root) + tkinter.Frame.__init__(self, root) #pack the file entry widgets SectionLabel(self, text="Select Images").pack(pady=5) @@ -127,8 +134,8 @@ class USRP2CardBurnerApp(Tkinter.Frame): #the do it button SectionLabel(self, text="").pack(pady=5) - Tkinter.Label(self, text="Warning! This tool can overwrite your hard drive. Use with caution.").pack() - Tkinter.Button(self, text="Burn SD Card", command=self._burn).pack() + tkinter.Label(self, text="Warning! This tool can overwrite your hard drive. Use with caution.").pack() + tkinter.Button(self, text="Burn SD Card", command=self._burn).pack() def _burn(self): #grab strings from the gui @@ -138,31 +145,31 @@ class USRP2CardBurnerApp(Tkinter.Frame): #check input if not dev: - tkMessageBox.showerror('Error:', 'No device specified!') + tkinter.messagebox.showerror('Error:', 'No device specified!') return if not fw and not fpga: - tkMessageBox.showerror('Error:', 'No images specified!') + tkinter.messagebox.showerror('Error:', 'No images specified!') return if fw and not os.path.exists(fw): - tkMessageBox.showerror('Error:', 'Firmware image not found!') + tkinter.messagebox.showerror('Error:', 'Firmware image not found!') return if fpga and not os.path.exists(fpga): - tkMessageBox.showerror('Error:', 'FPGA image not found!') + tkinter.messagebox.showerror('Error:', 'FPGA image not found!') return #burn the sd card try: verbose = usrp2_card_burner.burn_sd_card(dev=dev, fw=fw, fpga=fpga) - tkMessageBox.showinfo('Verbose:', verbose) - except Exception, e: - tkMessageBox.showerror('Verbose:', 'Error: %s'%str(e)) + tkinter.messagebox.showinfo('Verbose:', verbose) + except Exception as e: + tkinter.messagebox.showerror('Verbose:', 'Error: %s'%str(e)) ######################################################################## # main ######################################################################## if __name__=='__main__': options = usrp2_card_burner.get_options() - root = Tkinter.Tk() + root = tkinter.Tk() root.title('USRP2 SD Card Burner') USRP2CardBurnerApp(root, dev=options.dev, fw=options.fw, fpga=options.fpga).pack() root.mainloop() diff --git a/host/utils/usrp2_recovery.py b/host/utils/usrp2_recovery.py old mode 100755 new mode 100644 index 5654e93d3..c7578d3a0 --- a/host/utils/usrp2_recovery.py +++ b/host/utils/usrp2_recovery.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2010 Ettus Research LLC +# Copyright 2010-2011 Ettus Research LLC # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -39,7 +39,7 @@ RECOVERY_ETHERTYPE = 0xbeee IP_RECOVERY_CODE = 'addr' def mac_addr_repr_to_binary_string(mac_addr): - return ''.join(map(lambda x: chr(int(x, 16)), mac_addr.split(':'))) + return ''.join([chr(int(x, 16)) for x in mac_addr.split(':')]) if __name__ == '__main__': parser = optparse.OptionParser(usage='usage: %prog [options]\n'+__doc__) @@ -48,12 +48,12 @@ if __name__ == '__main__': (options, args) = parser.parse_args() #create the raw socket - print "Opening raw socket on interface:", options.ifc + print("Opening raw socket on interface:", options.ifc) soc = socket.socket(socket.PF_PACKET, socket.SOCK_RAW) soc.bind((options.ifc, RECOVERY_ETHERTYPE)) #create the recovery packet - print "Loading packet with ip address:", options.new_ip + print("Loading packet with ip address:", options.new_ip) packet = struct.pack( '!6s6sH4s4s', mac_addr_repr_to_binary_string(BCAST_MAC_ADDR), @@ -63,6 +63,6 @@ if __name__ == '__main__': socket.inet_aton(options.new_ip), ) - print "Sending packet (%d bytes)"%len(packet) + print("Sending packet (%d bytes)"%len(packet)) soc.send(packet) - print "Done" + print("Done") diff --git a/host/utils/usrp_n2xx_net_burner.py b/host/utils/usrp_n2xx_net_burner.py old mode 100755 new mode 100644 index c715f3364..58d18fd2d --- a/host/utils/usrp_n2xx_net_burner.py +++ b/host/utils/usrp_n2xx_net_burner.py @@ -137,12 +137,12 @@ class burner_socket(object): def init_update(self): out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_OHAI_LOL, seq(), 0, 0, "") try: in_pkt = self.send_and_recv(out_pkt) - except socket.timeout: raise Exception, "No response from device" + except socket.timeout: raise Exception("No response from device") (proto_ver, pktid, rxseq, ip_addr) = unpack_flash_ip_fmt(in_pkt) if pktid == update_id_t.USRP2_FW_UPDATE_ID_OHAI_OMG: - print "USRP-N2XX found." + print("USRP-N2XX found.") else: - raise Exception, "Invalid reply received from device." + raise Exception("Invalid reply received from device.") # print "Incoming:\n\tVer: %i\n\tID: %c\n\tSeq: %i\n\tIP: %i\n" % (proto_ver, chr(pktid), rxseq, ip_addr) @@ -153,14 +153,14 @@ class burner_socket(object): (proto_ver, pktid, rxseq, sector_size_bytes, memory_size_bytes) = unpack_flash_info_fmt(in_pkt) if pktid != update_id_t.USRP2_FW_UPDATE_ID_HERES_TEH_FLASH_INFO_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) return (memory_size_bytes, sector_size_bytes) def burn_fw(self, fw, fpga, reset, safe): (flash_size, sector_size) = self.get_flash_info() - print "Flash size: %i\nSector size: %i\n\n" % (flash_size, sector_size) + print("Flash size: %i\nSector size: %i\n\n" % (flash_size, sector_size)) if fpga: if safe: image_location = SAFE_FPGA_IMAGE_LOCATION_ADDR @@ -170,20 +170,20 @@ class burner_socket(object): fpga_image = fpga_file.read() if len(fpga_image) > FPGA_IMAGE_SIZE_BYTES: - print "Error: FPGA image file too large." + print("Error: FPGA image file too large.") return 0 if not is_valid_fpga_image(fpga_image): - print "Error: Invalid FPGA image file." + print("Error: Invalid FPGA image file.") return 0 - print "Begin FPGA write: this should take about 1 minute..." + print("Begin FPGA write: this should take about 1 minute...") start_time = time.time() self.erase_image(image_location, FPGA_IMAGE_SIZE_BYTES) self.write_image(fpga_image, image_location) self.verify_image(fpga_image, image_location) - print "Time elapsed: %f seconds"%(time.time() - start_time) - print "\n\n" + print("Time elapsed: %f seconds"%(time.time() - start_time)) + print("\n\n") if fw: if safe: image_location = SAFE_FW_IMAGE_LOCATION_ADDR @@ -193,25 +193,25 @@ class burner_socket(object): fw_image = fw_file.read() if len(fw_image) > FW_IMAGE_SIZE_BYTES: - print "Error: Firmware image file too large." + print("Error: Firmware image file too large.") return 0 if not is_valid_fw_image(fw_image): - print "Error: Invalid firmware image file." + print("Error: Invalid firmware image file.") return 0 - print "Begin firmware write: this should take about 1 second..." + print("Begin firmware write: this should take about 1 second...") start_time = time.time() self.erase_image(image_location, FW_IMAGE_SIZE_BYTES) self.write_image(fw_image, image_location) self.verify_image(fw_image, image_location) - print "Time elapsed: %f seconds"%(time.time() - start_time) - print "\n\n" + print("Time elapsed: %f seconds"%(time.time() - start_time)) + print("\n\n") if reset: self.reset_usrp() def write_image(self, image, addr): - print "Writing image" + print("Writing image") self._status_cb("Writing") writedata = image #we split the image into smaller (256B) bits and send them down the wire @@ -222,14 +222,14 @@ class burner_socket(object): (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid != update_id_t.USRP2_FW_UPDATE_ID_WROTE_TEH_FLASHES_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) writedata = writedata[FLASH_DATA_PACKET_SIZE:] addr += FLASH_DATA_PACKET_SIZE self._progress_cb(float(len(image)-len(writedata))/len(image)) def verify_image(self, image, addr): - print "Verifying data" + print("Verifying data") self._status_cb("Verifying") readsize = len(image) readdata = str() @@ -242,26 +242,26 @@ class burner_socket(object): (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid != update_id_t.USRP2_FW_UPDATE_ID_KK_READ_TEH_FLASHES_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) readdata += data[:thisreadsize] readsize -= FLASH_DATA_PACKET_SIZE addr += FLASH_DATA_PACKET_SIZE self._progress_cb(float(len(readdata))/len(image)) - print "Read back %i bytes" % len(readdata) + print("Read back %i bytes" % len(readdata)) # print readdata # for i in range(256, 512): # print "out: %i in: %i" % (ord(image[i]), ord(readdata[i])) if readdata != image: - raise Exception, "Verify failed. Image did not write correctly." + raise Exception("Verify failed. Image did not write correctly.") else: - print "Success." + print("Success.") def read_image(self, image, size, addr): - print "Reading image" + print("Reading image") readsize = size readdata = str() while readsize > 0: @@ -273,13 +273,13 @@ class burner_socket(object): (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid != update_id_t.USRP2_FW_UPDATE_ID_KK_READ_TEH_FLASHES_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) readdata += data[:thisreadsize] readsize -= FLASH_DATA_PACKET_SIZE addr += FLASH_DATA_PACKET_SIZE - print "Read back %i bytes" % len(readdata) + print("Read back %i bytes" % len(readdata)) #write to disk f = open(image, 'w') @@ -293,7 +293,7 @@ class burner_socket(object): (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid == update_id_t.USRP2_FW_UPDATE_ID_RESETTIN_TEH_COMPUTORZ_OMG: - raise Exception, "Device failed to reset." + raise Exception("Device failed to reset.") def erase_image(self, addr, length): self._status_cb("Erasing") @@ -304,9 +304,9 @@ class burner_socket(object): (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) if pktid != update_id_t.USRP2_FW_UPDATE_ID_ERASING_TEH_FLASHES_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) - print "Erasing %i bytes at %i" % (length, addr) + print("Erasing %i bytes at %i" % (length, addr)) start_time = time.time() #now wait for it to finish @@ -318,7 +318,7 @@ class burner_socket(object): if pktid == update_id_t.USRP2_FW_UPDATE_ID_IM_DONE_ERASING_OMG: break elif pktid != update_id_t.USRP2_FW_UPDATE_ID_NOPE_NOT_DONE_ERASING_OMG: - raise Exception, "Invalid reply %c from device." % (chr(pktid)) + raise Exception("Invalid reply %c from device." % (chr(pktid))) time.sleep(0.01) #decrease network overhead by waiting a bit before polling self._progress_cb(min(1.0, (time.time() - start_time)/(length/80e3))) @@ -343,14 +343,14 @@ def get_options(): ######################################################################## if __name__=='__main__': options = get_options() - if not options.addr: raise Exception, 'no address specified' + if not options.addr: raise Exception('no address specified') - if not options.fpga and not options.fw and not options.reset: raise Exception, 'Must specify either a firmware image or FPGA image, and/or reset.' + if not options.fpga and not options.fw and not options.reset: raise Exception('Must specify either a firmware image or FPGA image, and/or reset.') if options.overwrite_safe and not options.read: print("Are you REALLY, REALLY sure you want to overwrite the safe image? This is ALMOST ALWAYS a terrible idea.") print("If your image is faulty, your USRP2+ will become a brick until reprogrammed via JTAG.") - response = raw_input("""Type "yes" to continue, or anything else to quit: """) + response = input("""Type "yes" to continue, or anything else to quit: """) if response != "yes": sys.exit(0) burner = burner_socket(addr=options.addr) @@ -359,7 +359,7 @@ if __name__=='__main__': if options.fw: file = options.fw if os.path.isfile(file): - response = raw_input("File already exists -- overwrite? (y/n) ") + response = input("File already exists -- overwrite? (y/n) ") if response != "y": sys.exit(0) size = FW_IMAGE_SIZE_BYTES addr = SAFE_FW_IMAGE_LOCATION_ADDR if options.overwrite_safe else PROD_FW_IMAGE_LOCATION_ADDR @@ -368,7 +368,7 @@ if __name__=='__main__': if options.fpga: file = options.fpga if os.path.isfile(file): - response = raw_input("File already exists -- overwrite? (y/n) ") + response = input("File already exists -- overwrite? (y/n) ") if response != "y": sys.exit(0) size = FPGA_IMAGE_SIZE_BYTES addr = SAFE_FPGA_IMAGE_LOCATION_ADDR if options.overwrite_safe else PROD_FPGA_IMAGE_LOCATION_ADDR diff --git a/host/utils/usrp_n2xx_net_burner_gui.py b/host/utils/usrp_n2xx_net_burner_gui.py old mode 100755 new mode 100644 index 7fcb7d121..50551e24a --- a/host/utils/usrp_n2xx_net_burner_gui.py +++ b/host/utils/usrp_n2xx_net_burner_gui.py @@ -18,10 +18,17 @@ import threading import usrp_n2xx_net_burner #import implementation -import Tkinter, tkFileDialog, tkFont, tkMessageBox +try: + import tkinter, tkinter.filedialog, tkinter.font, tkinter.messagebox +except ImportError: + import tkFileDialog, tkFont, tkMessageBox + import Tkinter as tkinter + tkinter.filedialog = tkFileDialog + tkinter.font = tkFont + tkinter.messagebox = tkMessageBox import os -class BinFileEntry(Tkinter.Frame): +class BinFileEntry(tkinter.Frame): """ Simple file entry widget for getting the file path of bin files. Combines a label, entry, and button with file dialog callback. @@ -29,15 +36,15 @@ class BinFileEntry(Tkinter.Frame): def __init__(self, root, what, def_path=''): self._what = what - Tkinter.Frame.__init__(self, root) - Tkinter.Label(self, text=what+":").pack(side=Tkinter.LEFT) - self._entry = Tkinter.Entry(self, width=50) - self._entry.insert(Tkinter.END, def_path) - self._entry.pack(side=Tkinter.LEFT) - Tkinter.Button(self, text="...", command=self._button_cb).pack(side=Tkinter.LEFT) + tkinter.Frame.__init__(self, root) + tkinter.Label(self, text=what+":").pack(side=tkinter.LEFT) + self._entry = tkinter.Entry(self, width=50) + self._entry.insert(tkinter.END, def_path) + self._entry.pack(side=tkinter.LEFT) + tkinter.Button(self, text="...", command=self._button_cb).pack(side=tkinter.LEFT) def _button_cb(self): - filename = tkFileDialog.askopenfilename( + filename = tkinter.filedialog.askopenfilename( parent=self, filetypes=[('bin files', '*.bin'), ('all files', '*.*')], title="Select bin file for %s"%self._what, @@ -46,13 +53,13 @@ class BinFileEntry(Tkinter.Frame): # open file on your own if filename: - self._entry.delete(0, Tkinter.END) + self._entry.delete(0, tkinter.END) self._entry.insert(0, filename) def get_filename(self): return self._entry.get() -class ProgressBar(Tkinter.Canvas): +class ProgressBar(tkinter.Canvas): """ A simple implementation of a progress bar. Draws rectangle that fills from left to right. @@ -61,7 +68,7 @@ class ProgressBar(Tkinter.Canvas): def __init__(self, root, width=500, height=20): self._width = width self._height = height - Tkinter.Canvas.__init__(self, root, relief="sunken", borderwidth=2, width=self._width-2, height=self._height-2) + tkinter.Canvas.__init__(self, root, relief="sunken", borderwidth=2, width=self._width-2, height=self._height-2) self._last_fill_pixels = None self.set(0.0) @@ -78,20 +85,20 @@ class ProgressBar(Tkinter.Canvas): if frac: self.create_rectangle(0, 0, fill_pixels, self._height, fill="#357EC7") else: self.create_rectangle(0, 0, self._width, self._height, fill="#E8E8E8") -class SectionLabel(Tkinter.Label): +class SectionLabel(tkinter.Label): """ Make a text label with bold font. """ def __init__(self, root, text): - Tkinter.Label.__init__(self, root, text=text) + tkinter.Label.__init__(self, root, text=text) #set the font bold - f = tkFont.Font(font=self['font']) + f = tkinter.font.Font(font=self['font']) f['weight'] = 'bold' self['font'] = f.name -class USRPN2XXNetBurnerApp(Tkinter.Frame): +class USRPN2XXNetBurnerApp(tkinter.Frame): """ The top level gui application for the usrp-n2xx network burner. Creates entry widgets and button with callback to write images. @@ -99,7 +106,7 @@ class USRPN2XXNetBurnerApp(Tkinter.Frame): def __init__(self, root, addr, fw, fpga): - Tkinter.Frame.__init__(self, root) + tkinter.Frame.__init__(self, root) #pack the file entry widgets SectionLabel(self, text="Select Images").pack(pady=5) @@ -110,24 +117,24 @@ class USRPN2XXNetBurnerApp(Tkinter.Frame): #pack the destination entry widget SectionLabel(self, text="Select Address").pack(pady=5) - self._addr_entry = Tkinter.Entry(self, width=30) - self._addr_entry.insert(Tkinter.END, addr) + self._addr_entry = tkinter.Entry(self, width=30) + self._addr_entry.insert(tkinter.END, addr) self._addr_entry.pack() #the do it button SectionLabel(self, text="").pack(pady=5) - button = Tkinter.Button(self, text="Burn Images", command=self._burn) - self._enable_input = lambda: button.configure(state=Tkinter.NORMAL) - self._disable_input = lambda: button.configure(state=Tkinter.DISABLED) + button = tkinter.Button(self, text="Burn Images", command=self._burn) + self._enable_input = lambda: button.configure(state=tkinter.NORMAL) + self._disable_input = lambda: button.configure(state=tkinter.DISABLED) button.pack() #a progress bar to monitor the status - progress_frame = Tkinter.Frame(self) + progress_frame = tkinter.Frame(self) progress_frame.pack() - self._status = Tkinter.StringVar() - Tkinter.Label(progress_frame, textvariable=self._status).pack(side=Tkinter.LEFT) + self._status = tkinter.StringVar() + tkinter.Label(progress_frame, textvariable=self._status).pack(side=tkinter.LEFT) self._pbar = ProgressBar(progress_frame) - self._pbar.pack(side=Tkinter.RIGHT, expand=True) + self._pbar.pack(side=tkinter.RIGHT, expand=True) def _burn(self): self._disable_input() @@ -141,16 +148,16 @@ class USRPN2XXNetBurnerApp(Tkinter.Frame): #check input if not addr: - tkMessageBox.showerror('Error:', 'No address specified!') + tkinter.messagebox.showerror('Error:', 'No address specified!') return if not fw and not fpga: - tkMessageBox.showerror('Error:', 'No images specified!') + tkinter.messagebox.showerror('Error:', 'No images specified!') return if fw and not os.path.exists(fw): - tkMessageBox.showerror('Error:', 'Firmware image not found!') + tkinter.messagebox.showerror('Error:', 'Firmware image not found!') return if fpga and not os.path.exists(fpga): - tkMessageBox.showerror('Error:', 'FPGA image not found!') + tkinter.messagebox.showerror('Error:', 'FPGA image not found!') return try: @@ -165,11 +172,11 @@ class USRPN2XXNetBurnerApp(Tkinter.Frame): burner.set_callbacks(progress_cb=self._pbar.set, status_cb=status_cb) burner.burn_fw(fw=fw_img, fpga=fpga_img, reset=False, safe=False) - if tkMessageBox.askyesno("Burn was successful!", "Reset the device?"): + if tkinter.messagebox.askyesno("Burn was successful!", "Reset the device?"): burner.reset_usrp() - except Exception, e: - tkMessageBox.showerror('Verbose:', 'Error: %s'%str(e)) + except Exception as e: + tkinter.messagebox.showerror('Verbose:', 'Error: %s'%str(e)) #reset the progress bar self._pbar.set(0.0) @@ -181,7 +188,7 @@ class USRPN2XXNetBurnerApp(Tkinter.Frame): ######################################################################## if __name__=='__main__': options = usrp_n2xx_net_burner.get_options() - root = Tkinter.Tk() + root = tkinter.Tk() root.title('USRP-N2XX Net Burner') USRPN2XXNetBurnerApp(root, addr=options.addr, fw=options.fw, fpga=options.fpga).pack() root.mainloop() -- cgit v1.2.3 From cbc62e4aee472eaf19b2f148092ce0137dbe917b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 19:02:38 -0700 Subject: usrp_n2xx_net_burner: remove thread from gui tkinter is far too confused to handle threading and events the calls to update in the progress/sttus callbacks keep the gui refreshed --- host/utils/usrp_n2xx_net_burner_gui.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/host/utils/usrp_n2xx_net_burner_gui.py b/host/utils/usrp_n2xx_net_burner_gui.py index 50551e24a..3b414a918 100644 --- a/host/utils/usrp_n2xx_net_burner_gui.py +++ b/host/utils/usrp_n2xx_net_burner_gui.py @@ -16,7 +16,6 @@ # along with this program. If not, see . # -import threading import usrp_n2xx_net_burner #import implementation try: import tkinter, tkinter.filedialog, tkinter.font, tkinter.messagebox @@ -138,9 +137,7 @@ class USRPN2XXNetBurnerApp(tkinter.Frame): def _burn(self): self._disable_input() - threading.Thread(target=self._burn_bg).start() - def _burn_bg(self): #grab strings from the gui fw = self._fw_img_entry.get_filename() fpga = self._fpga_img_entry.get_filename() @@ -169,7 +166,11 @@ class USRPN2XXNetBurnerApp(tkinter.Frame): def status_cb(status): self._pbar.set(0.0) #status change, reset the progress self._status.set("%s %s "%(status.title(), image_type)) - burner.set_callbacks(progress_cb=self._pbar.set, status_cb=status_cb) + self.update() + def progress_cb(progress): + self._pbar.set(progress) + self.update() + burner.set_callbacks(progress_cb=progress_cb, status_cb=status_cb) burner.burn_fw(fw=fw_img, fpga=fpga_img, reset=False, safe=False) if tkinter.messagebox.askyesno("Burn was successful!", "Reset the device?"): -- cgit v1.2.3 From 3a588c594717e61b8d23fe5fb018068cc6adb21f Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 19:53:24 -0700 Subject: usrp_n2xx_net_burner: working on python3 (string is not the same as bytes) --- host/utils/usrp_n2xx_net_burner.py | 45 ++++++++++++++------------------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/host/utils/usrp_n2xx_net_burner.py b/host/utils/usrp_n2xx_net_burner.py index 58d18fd2d..0b64f2008 100644 --- a/host/utils/usrp_n2xx_net_burner.py +++ b/host/utils/usrp_n2xx_net_burner.py @@ -92,7 +92,7 @@ def unpack_flash_info_fmt(s): def unpack_flash_ip_fmt(s): return struct.unpack(FLASH_IP_FMT, s) #(proto_ver, pktid, seq, ip_addr) -def pack_flash_args_fmt(proto_ver, pktid, seq, flash_addr, length, data): +def pack_flash_args_fmt(proto_ver, pktid, seq, flash_addr, length, data=bytes()): return struct.pack(FLASH_ARGS_FMT, proto_ver, pktid, seq, flash_addr, length, data) def pack_flash_info_fmt(proto_ver, pktid, seq, sector_size_bytes, memory_size_bytes): @@ -100,19 +100,12 @@ def pack_flash_info_fmt(proto_ver, pktid, seq, sector_size_bytes, memory_size_by def is_valid_fpga_image(fpga_image): for i in range(0,63): - if ord(fpga_image[i]) == 0xFF: - continue - if ord(fpga_image[i]) == 0xAA and ord(fpga_image[i+1]) == 0x99: - return 1 - - return 0 + if fpga_image[i:i+1] == bytes(b'\xFF'): continue + if fpga_image[i:i+2] == bytes(b'\xAA\x99'): return True + return False def is_valid_fw_image(fw_image): - for i in range(0,4): - if ord(fw_image[i]) != 0x0B: - return 0; - - return 1 + return fw_image[:4] == bytes(b'\x0B\x0B\x0B\x0B') ######################################################################## # Burner class, holds a socket and send/recv routines @@ -135,7 +128,7 @@ class burner_socket(object): #just here to validate comms def init_update(self): - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_OHAI_LOL, seq(), 0, 0, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_OHAI_LOL, seq(), 0, 0) try: in_pkt = self.send_and_recv(out_pkt) except socket.timeout: raise Exception("No response from device") (proto_ver, pktid, rxseq, ip_addr) = unpack_flash_ip_fmt(in_pkt) @@ -147,7 +140,7 @@ class burner_socket(object): # print "Incoming:\n\tVer: %i\n\tID: %c\n\tSeq: %i\n\tIP: %i\n" % (proto_ver, chr(pktid), rxseq, ip_addr) def get_flash_info(self): - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_WATS_TEH_FLASH_INFO_LOL, seq(), 0, 0, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_WATS_TEH_FLASH_INFO_LOL, seq(), 0, 0) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, sector_size_bytes, memory_size_bytes) = unpack_flash_info_fmt(in_pkt) @@ -170,12 +163,10 @@ class burner_socket(object): fpga_image = fpga_file.read() if len(fpga_image) > FPGA_IMAGE_SIZE_BYTES: - print("Error: FPGA image file too large.") - return 0 + raise Exception("Error: FPGA image file too large.") if not is_valid_fpga_image(fpga_image): - print("Error: Invalid FPGA image file.") - return 0 + raise Exception("Error: Invalid FPGA image file.") print("Begin FPGA write: this should take about 1 minute...") start_time = time.time() @@ -193,12 +184,10 @@ class burner_socket(object): fw_image = fw_file.read() if len(fw_image) > FW_IMAGE_SIZE_BYTES: - print("Error: Firmware image file too large.") - return 0 + raise Exception("Error: Firmware image file too large.") if not is_valid_fw_image(fw_image): - print("Error: Invalid firmware image file.") - return 0 + raise Exception("Error: Invalid firmware image file.") print("Begin firmware write: this should take about 1 second...") start_time = time.time() @@ -232,11 +221,11 @@ class burner_socket(object): print("Verifying data") self._status_cb("Verifying") readsize = len(image) - readdata = str() + readdata = bytes() while readsize > 0: if readsize < FLASH_DATA_PACKET_SIZE: thisreadsize = readsize else: thisreadsize = FLASH_DATA_PACKET_SIZE - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_READ_TEH_FLASHES_LOL, seq(), addr, thisreadsize, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_READ_TEH_FLASHES_LOL, seq(), addr, thisreadsize) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) @@ -267,7 +256,7 @@ class burner_socket(object): while readsize > 0: if readsize < FLASH_DATA_PACKET_SIZE: thisreadsize = readsize else: thisreadsize = FLASH_DATA_PACKET_SIZE - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_READ_TEH_FLASHES_LOL, seq(), addr, thisreadsize, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_READ_TEH_FLASHES_LOL, seq(), addr, thisreadsize) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) @@ -287,7 +276,7 @@ class burner_socket(object): f.close() def reset_usrp(self): - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_RESET_MAH_COMPUTORZ_LOL, seq(), 0, 0, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_RESET_MAH_COMPUTORZ_LOL, seq(), 0, 0) try: in_pkt = self.send_and_recv(out_pkt) except socket.timeout: return @@ -298,7 +287,7 @@ class burner_socket(object): def erase_image(self, addr, length): self._status_cb("Erasing") #get flash info first - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_ERASE_TEH_FLASHES_LOL, seq(), addr, length, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_ERASE_TEH_FLASHES_LOL, seq(), addr, length) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) @@ -311,7 +300,7 @@ class burner_socket(object): #now wait for it to finish while(True): - out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_R_U_DONE_ERASING_LOL, seq(), 0, 0, "") + out_pkt = pack_flash_args_fmt(USRP2_FW_PROTO_VERSION, update_id_t.USRP2_FW_UPDATE_ID_R_U_DONE_ERASING_LOL, seq(), 0, 0) in_pkt = self.send_and_recv(out_pkt) (proto_ver, pktid, rxseq, flash_addr, rxlength, data) = unpack_flash_args_fmt(in_pkt) -- cgit v1.2.3 From 60669a28d8862fd2a8ea324f947580485585b317 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 20:15:10 -0700 Subject: usrp2_card_burner: change the padding string to bytes --- host/utils/usrp2_card_burner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py index cb3cc53f6..f24fc4252 100644 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -179,8 +179,8 @@ def write_image(image_file, device_file, offset): img_data = open(image_file, 'rb').read() count = int_ceil_div(len(img_data), SECTOR_SIZE) pad_len = SECTOR_SIZE*count - len(img_data) - pad_str = ''.join([chr(0)]*pad_len) #zero-padding - open(tmp_file, 'wb').write(img_data + pad_str) + padding = bytes(b'\x00')*pad_len #zero-padding + open(tmp_file, 'wb').write(img_data + padding) #execute a dd subprocess verbose = command( -- cgit v1.2.3 From d07870f698e314a516939ca91de3d7307c9bade7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 5 Apr 2011 20:37:29 -0700 Subject: usb: mark libusb callbacks with LIBUSB_CALL to ensure correct calling convention --- host/lib/transport/libusb1_zero_copy.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index fe6936c7e..e42cab1d1 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -34,13 +34,23 @@ using namespace uhd::transport; static const size_t DEFAULT_NUM_XFERS = 16; //num xfers static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes +//! Define LIBUSB_CALL when its missing (non-windows) +#ifndef LIBUSB_CALL + #define LIBUSB_CALL +#endif /*LIBUSB_CALL*/ + +/*! + * All libusb callback functions should be marked with the LIBUSB_CALL macro + * to ensure that they are compiled with the same calling convention as libusb. + */ + //! helper function: handles all async callbacks -static void libusb_async_cb(libusb_transfer *lut){ +static void LIBUSB_CALL libusb_async_cb(libusb_transfer *lut){ (*static_cast *>(lut->user_data))(); } //! callback to free transfer upon cancellation -static void cancel_transfer_cb(libusb_transfer *lut){ +static void LIBUSB_CALL cancel_transfer_cb(libusb_transfer *lut){ if (lut->status == LIBUSB_TRANSFER_CANCELLED) libusb_free_transfer(lut); else std::cout << "libusb cancel_transfer unexpected status " << lut->status << std::endl; } -- cgit v1.2.3 From 529297b97df9b9d928c30bb7cdb51f14f3fb3ab0 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 6 Apr 2011 07:37:05 -0700 Subject: usrp2_card_burner: decode byte strings into ascii for parsing --- host/utils/usrp2_card_burner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py index f24fc4252..741c7e3e1 100644 --- a/host/utils/usrp2_card_burner.py +++ b/host/utils/usrp2_card_burner.py @@ -50,7 +50,7 @@ def command(*args): stderr=subprocess.STDOUT, ) ret = p.wait() - verbose = p.stdout.read() + verbose = p.stdout.read().decode('ascii') if ret != 0: raise Exception(verbose) return verbose @@ -84,7 +84,7 @@ def get_raw_device_hints(): return info.split(key)[-1].split()[0] def get_info_list(output): in_info = False - for line in str(output).splitlines(): + for line in output.splitlines(): if line.startswith('\\\\'): in_info = True; info = '' elif in_info and not line.strip(): in_info = False; yield info if in_info: info += '\n'+line.strip() @@ -108,7 +108,7 @@ def get_raw_device_hints(): #################################################################### if platform.system() == 'Linux': devs = list() - try: output = open('/proc/partitions', 'r').read() + try: output = open('/proc/partitions', 'r').read().decode('ascii') except: return devs for line in output.splitlines(): try: -- cgit v1.2.3 From cab1746e1c3582f8d44f2141cfcbb948aa6dd10c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 6 Apr 2011 08:01:40 -0700 Subject: usrp2: restore executable permission on python scripts --- host/utils/usrp2_card_burner.py | 0 host/utils/usrp2_card_burner_gui.py | 0 host/utils/usrp2_recovery.py | 0 host/utils/usrp_n2xx_net_burner.py | 0 host/utils/usrp_n2xx_net_burner_gui.py | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 host/utils/usrp2_card_burner.py mode change 100644 => 100755 host/utils/usrp2_card_burner_gui.py mode change 100644 => 100755 host/utils/usrp2_recovery.py mode change 100644 => 100755 host/utils/usrp_n2xx_net_burner.py mode change 100644 => 100755 host/utils/usrp_n2xx_net_burner_gui.py diff --git a/host/utils/usrp2_card_burner.py b/host/utils/usrp2_card_burner.py old mode 100644 new mode 100755 diff --git a/host/utils/usrp2_card_burner_gui.py b/host/utils/usrp2_card_burner_gui.py old mode 100644 new mode 100755 diff --git a/host/utils/usrp2_recovery.py b/host/utils/usrp2_recovery.py old mode 100644 new mode 100755 diff --git a/host/utils/usrp_n2xx_net_burner.py b/host/utils/usrp_n2xx_net_burner.py old mode 100644 new mode 100755 diff --git a/host/utils/usrp_n2xx_net_burner_gui.py b/host/utils/usrp_n2xx_net_burner_gui.py old mode 100644 new mode 100755 -- cgit v1.2.3 From 74fc8946688d53ccd5d067d3f86e26b990af1bd4 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 6 Apr 2011 09:55:54 -0700 Subject: uhd: always link winsock2 on windows, disable pthread SCHED_RR for cygwin --- host/lib/transport/CMakeLists.txt | 4 +++- host/lib/utils/CMakeLists.txt | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 30f8db48a..90360977a 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -79,7 +79,9 @@ SET_SOURCE_FILES_PROPERTIES( PROPERTIES COMPILE_DEFINITIONS "${IF_ADDRS_DEFS}" ) -IF(WIN32 AND UNIX) #MinGW/Cygwin needs winsock2 +#On windows, the boost asio implementation uses the winsock2 library. +#Note: we exclude the .lib extension for cygwin and mingw platforms. +IF(WIN32) LIBUHD_APPEND_LIBS(ws2_32) ENDIF() diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index c0d99b37e..26c02b5b4 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -36,6 +36,11 @@ CHECK_CXX_SOURCE_COMPILES(" " HAVE_PTHREAD_SETSCHEDPARAM ) +IF(CYGWIN) + #SCHED_RR non-operational on cygwin + SET(HAVE_PTHREAD_SETSCHEDPARAM False) +ENDIF(CYGWIN) + CHECK_CXX_SOURCE_COMPILES(" #include int main(){ -- cgit v1.2.3 From abb57f86617312ce41f7c5e0c86fda7e7826a09a Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 7 Apr 2011 15:45:03 -0500 Subject: usrp1: fix path to firmware files for fpga top level --- fpga/usrp1/toplevel/usrp_std/usrp_std.v | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fpga/usrp1/toplevel/usrp_std/usrp_std.v b/fpga/usrp1/toplevel/usrp_std/usrp_std.v index 8b29a9c21..83a89cb81 100644 --- a/fpga/usrp1/toplevel/usrp_std/usrp_std.v +++ b/fpga/usrp1/toplevel/usrp_std/usrp_std.v @@ -28,8 +28,8 @@ // Uncomment the following to include optional circuitry `include "config.vh" -`include "../../../firmware/include/fpga_regs_common.v" -`include "../../../firmware/include/fpga_regs_standard.v" +`include "../../../../firmware/fx2/common/fpga_regs_common.v" +`include "../../../../firmware/fx2/common/fpga_regs_standard.v" module usrp_std (output MYSTERY_SIGNAL, -- cgit v1.2.3 From ee705a42fb41bf92529a02c3087167e71d5e2630 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 7 Apr 2011 15:46:31 -0500 Subject: usrp-e100: reset dboard clocks on rate change, and dont cache in dboard iface --- host/lib/usrp/usrp_e100/clock_ctrl.cpp | 16 +++++++++++++++- host/lib/usrp/usrp_e100/clock_ctrl.hpp | 12 ++++++++++++ host/lib/usrp/usrp_e100/dboard_iface.cpp | 8 +++++--- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.cpp b/host/lib/usrp/usrp_e100/clock_ctrl.cpp index b0bf20b67..1ac2b804c 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.cpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.cpp @@ -287,6 +287,9 @@ public: if (_out_rate == rate) return; if (rate == 61.44e6) set_clock_settings_with_external_vcxo(rate); else set_clock_settings_with_internal_vco(rate); + //clock rate changed! update dboard clocks and FPGA ticks per second + set_rx_dboard_clock_rate(rate); + set_tx_dboard_clock_rate(rate); _iface->poke32(UE_REG_TIME64_TPS, boost::uint32_t(get_fpga_clock_rate())); } @@ -328,6 +331,7 @@ public: void set_rx_dboard_clock_rate(double rate){ assert_has(get_rx_dboard_clock_rates(), rate, "rx dboard clock rate"); + _rx_clock_rate = rate; size_t divider = size_t(this->_chan_rate/rate); //set the divider registers set_clock_divider(divider, @@ -340,6 +344,10 @@ public: this->latch_regs(); } + double get_rx_clock_rate(void){ + return _rx_clock_rate; + } + /*********************************************************************** * TX Dboard Clock Control (output 6, divider 2) **********************************************************************/ @@ -358,6 +366,7 @@ public: void set_tx_dboard_clock_rate(double rate){ assert_has(get_tx_dboard_clock_rates(), rate, "tx dboard clock rate"); + _tx_clock_rate = rate; size_t divider = size_t(this->_chan_rate/rate); //set the divider registers set_clock_divider(divider, @@ -369,7 +378,11 @@ public: this->send_reg(0x197); this->latch_regs(); } - + + double get_tx_clock_rate(void){ + return _tx_clock_rate; + } + /*********************************************************************** * Clock reference control **********************************************************************/ @@ -401,6 +414,7 @@ private: ad9522_regs_t _ad9522_regs; double _out_rate; //rate at the fpga and codec double _chan_rate; //rate before final dividers + double _rx_clock_rate, _tx_clock_rate; void latch_regs(void){ _ad9522_regs.io_update = 1; diff --git a/host/lib/usrp/usrp_e100/clock_ctrl.hpp b/host/lib/usrp/usrp_e100/clock_ctrl.hpp index 623fbc73b..507f914f3 100644 --- a/host/lib/usrp/usrp_e100/clock_ctrl.hpp +++ b/host/lib/usrp/usrp_e100/clock_ctrl.hpp @@ -78,6 +78,18 @@ public: */ virtual void set_tx_dboard_clock_rate(double rate) = 0; + /*! + * Get the current rx dboard clock rate. + * \return the clock rate in Hz + */ + virtual double get_rx_clock_rate(void) = 0; + + /*! + * Get the current tx dboard clock rate. + * \return the clock rate in Hz + */ + virtual double get_tx_clock_rate(void) = 0; + /*! * Enable/disable the rx dboard clock. * \param enb true to enable diff --git a/host/lib/usrp/usrp_e100/dboard_iface.cpp b/host/lib/usrp/usrp_e100/dboard_iface.cpp index 4ee354486..61b5a1c92 100644 --- a/host/lib/usrp/usrp_e100/dboard_iface.cpp +++ b/host/lib/usrp/usrp_e100/dboard_iface.cpp @@ -97,7 +97,6 @@ private: usrp_e100_iface::sptr _iface; usrp_e100_clock_ctrl::sptr _clock; usrp_e100_codec_ctrl::sptr _codec; - uhd::dict _clock_rates; }; /*********************************************************************** @@ -115,7 +114,6 @@ dboard_iface::sptr make_usrp_e100_dboard_iface( * Clock Rates **********************************************************************/ void usrp_e100_dboard_iface::set_clock_rate(unit_t unit, double rate){ - _clock_rates[unit] = rate; switch(unit){ case UNIT_RX: return _clock->set_rx_dboard_clock_rate(rate); case UNIT_TX: return _clock->set_tx_dboard_clock_rate(rate); @@ -131,7 +129,11 @@ std::vector usrp_e100_dboard_iface::get_clock_rates(unit_t unit){ } double usrp_e100_dboard_iface::get_clock_rate(unit_t unit){ - return _clock_rates[unit]; + switch(unit){ + case UNIT_RX: return _clock->get_rx_clock_rate(); + case UNIT_TX: return _clock->get_tx_clock_rate(); + } + UHD_THROW_INVALID_CODE_PATH(); } void usrp_e100_dboard_iface::set_clock_enabled(unit_t unit, bool enb){ -- cgit v1.2.3 From 2f102fbff2b7245d3d038e7dfffaa2de856b61aa Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 8 Apr 2011 16:59:29 -0500 Subject: usrp2: support fw protos with older compats for various parts i2c, spi, and uart are long time no changing registers changed recently (think re-map) also, perform the fpga compat check in the make now we can find devices with out of date images --- host/lib/usrp/usrp2/mboard_impl.cpp | 10 ++++++++ host/lib/usrp/usrp2/usrp2_iface.cpp | 48 +++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 40fc5098b..7a6c596bc 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -66,6 +66,16 @@ usrp2_mboard_impl::usrp2_mboard_impl( device_addr["addr"], BOOST_STRINGIZE(USRP2_UDP_CTRL_PORT) ))) { + + //check the fpga compatibility number + const boost::uint32_t fpga_compat_num = _iface->peek32(_iface->regs.compat_num_rb); + if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){ + throw uhd::runtime_error(str(boost::format( + "Expected fpga compatibility number %d, but got %d:\n" + "The fpga build is not compatible with the host code build." + ) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num)); + } + //construct transports for dsp and async errors std::cout << "Making transport for DSP0..." << std::endl; device.dsp_xports.push_back(udp_zero_copy::make( diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index e3827233b..227233917 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -34,6 +34,13 @@ using namespace uhd::transport; static const double CTRL_RECV_TIMEOUT = 1.0; +static const boost::uint32_t MIN_PROTO_COMPAT_SPI = 7; +static const boost::uint32_t MIN_PROTO_COMPAT_I2C = 7; +// The register compat number must reflect the protocol compatibility +// and the compatibility of the register mapping (more likely to change). +static const boost::uint32_t MIN_PROTO_COMPAT_REG = USRP2_FW_COMPAT_NUM; +static const boost::uint32_t MIN_PROTO_COMPAT_UART = 7; + class usrp2_iface_impl : public usrp2_iface{ public: /*********************************************************************** @@ -59,15 +66,6 @@ public: regs = usrp2_get_regs(false); break; } - - //check the fpga compatibility number - const boost::uint32_t fpga_compat_num = this->peek32(this->regs.compat_num_rb); - if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){ - throw uhd::runtime_error(str(boost::format( - "Expected fpga compatibility number %d, but got %d:\n" - "The fpga build is not compatible with the host code build." - ) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num)); - } } /*********************************************************************** @@ -115,7 +113,7 @@ public: out_data.data.spi_args.data = htonl(data); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_SPI); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_OMG_TRANSACTED_SPI_DUDE); return ntohl(in_data.data.spi_args.data); @@ -138,7 +136,7 @@ public: std::copy(buf.begin(), buf.end(), out_data.data.i2c_args.data); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_I2C); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_COOL_IM_DONE_I2C_WRITE_DUDE); } @@ -153,7 +151,7 @@ public: UHD_ASSERT_THROW(num_bytes <= sizeof(out_data.data.i2c_args.data)); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_I2C); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_HERES_THE_I2C_DATA_DUDE); UHD_ASSERT_THROW(in_data.data.i2c_args.addr = num_bytes); @@ -186,7 +184,7 @@ public: std::copy(item.begin(), item.end(), out_data.data.uart_args.data); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_UART); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_MAN_I_TOTALLY_WROTE_THAT_UART_DUDE); } } @@ -205,7 +203,7 @@ public: //UHD_ASSERT_THROW(num_bytes <= sizeof(out_data.data.uart_args.data)); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_UART); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_I_HELLA_READ_THAT_UART_DUDE); readlen = in_data.data.uart_args.bytes; @@ -226,9 +224,18 @@ public: /*********************************************************************** * Send/Recv over control **********************************************************************/ - usrp2_ctrl_data_t ctrl_send_and_recv(const usrp2_ctrl_data_t &out_data){ + usrp2_ctrl_data_t ctrl_send_and_recv( + const usrp2_ctrl_data_t &out_data, + boost::uint32_t lo = USRP2_FW_COMPAT_NUM, + boost::uint32_t hi = USRP2_FW_COMPAT_NUM + ){ boost::mutex::scoped_lock lock(_ctrl_mutex); + std::string range = (lo == hi)? + str(boost::format("%d") % hi) : + str(boost::format("[%d to %d]") % lo % hi) + ; + //fill in the seq number and send usrp2_ctrl_data_t out_copy = out_data; out_copy.proto_ver = htonl(USRP2_FW_COMPAT_NUM); @@ -240,11 +247,12 @@ public: const usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast(usrp2_ctrl_data_in_mem); while(true){ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CTRL_RECV_TIMEOUT); - if(len >= sizeof(boost::uint32_t) and ntohl(ctrl_data_in->proto_ver) != USRP2_FW_COMPAT_NUM){ + boost::uint32_t compat = ntohl(ctrl_data_in->proto_ver); + if(len >= sizeof(boost::uint32_t) and hi >= compat and lo <= compat){ throw uhd::runtime_error(str(boost::format( - "Expected protocol compatibility number %d, but got %d:\n" + "Expected protocol compatibility number %s, but got %d:\n" "The firmware build is not compatible with the host code build." - ) % int(USRP2_FW_COMPAT_NUM) % ntohl(ctrl_data_in->proto_ver))); + ) % range % compat)); } if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(ctrl_data_in->seq) == _ctrl_seq_num){ return *ctrl_data_in; @@ -297,7 +305,7 @@ private: out_data.data.poke_args.num_bytes = sizeof(T); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_REG); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_OMG_POKED_REGISTER_SO_BAD_DUDE); } @@ -309,7 +317,7 @@ private: out_data.data.poke_args.num_bytes = sizeof(T); //send and recv - usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data); + usrp2_ctrl_data_t in_data = this->ctrl_send_and_recv(out_data, MIN_PROTO_COMPAT_REG); UHD_ASSERT_THROW(ntohl(in_data.id) == USRP2_CTRL_ID_WOAH_I_DEFINITELY_PEEKED_IT_DUDE); return T(ntohl(in_data.data.poke_args.data)); } -- cgit v1.2.3 From e9ca5336eaa84832ccda9dec81022f7fbba48c45 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 9 Apr 2011 18:30:16 -0500 Subject: uhd: attempt to cleanup language in thread prio warning --- host/lib/utils/thread_priority.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/host/lib/utils/thread_priority.cpp b/host/lib/utils/thread_priority.cpp index bd34055e8..a63bdf5ce 100644 --- a/host/lib/utils/thread_priority.cpp +++ b/host/lib/utils/thread_priority.cpp @@ -27,18 +27,17 @@ bool uhd::set_thread_priority_safe(float priority, bool realtime){ return true; }catch(const std::exception &e){ uhd::warning::post(str(boost::format( + "Unable to set the thread priority. Performance may be negatively affected.\n" + "Please see the general application notes in the manual for instructions.\n" "%s\n" - "Failed to set thread priority %d (%s):\n" - "Performance may be negatively affected.\n" - "See the general application notes.\n" - ) % e.what() % priority % (realtime?"realtime":""))); + ) % e.what())); return false; } } static void check_priority_range(float priority){ if (priority > +1.0 or priority < -1.0) - throw std::range_error("priority out of range [-1.0, +1.0]"); + throw uhd::value_error("priority out of range [-1.0, +1.0]"); } /*********************************************************************** -- cgit v1.2.3 From f9e1f06e81109573d2e600a18c288aafd1438f64 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 13 Apr 2011 10:04:42 -0700 Subject: usrp2: add check for holler protocol, we can support backwards --- host/lib/usrp/usrp2/usrp2_iface.cpp | 2 +- host/lib/usrp/usrp2/usrp2_impl.cpp | 42 ++++++++++++++++++++++++------------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 227233917..6e1d69044 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -248,7 +248,7 @@ public: while(true){ size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem), CTRL_RECV_TIMEOUT); boost::uint32_t compat = ntohl(ctrl_data_in->proto_ver); - if(len >= sizeof(boost::uint32_t) and hi >= compat and lo <= compat){ + if(len >= sizeof(boost::uint32_t) and (hi < compat or lo > compat)){ throw uhd::runtime_error(str(boost::format( "Expected protocol compatibility number %s, but got %d:\n" "The firmware build is not compatible with the host code build." diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index f42be321b..cb92b1921 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -171,6 +171,15 @@ static mtu_result_t determine_mtu(const std::string &addr){ usrp2_ctrl_data_t *ctrl_data = reinterpret_cast(buffer); static const double echo_timeout = 0.020; //20 ms + //test holler - check if its supported in this fw version + ctrl_data->id = htonl(USRP2_CTRL_ID_HOLLER_AT_ME_BRO); + ctrl_data->proto_ver = htonl(USRP2_FW_COMPAT_NUM); + ctrl_data->data.echo_args.len = htonl(sizeof(usrp2_ctrl_data_t)); + udp_sock->send(boost::asio::buffer(buffer, sizeof(usrp2_ctrl_data_t))); + udp_sock->recv(boost::asio::buffer(buffer), echo_timeout); + if (ntohl(ctrl_data->id) != USRP2_CTRL_ID_HOLLER_BACK_DUDE) + throw uhd::not_implemented_error("holler protocol not implemented"); + size_t min_recv_mtu = sizeof(usrp2_ctrl_data_t), max_recv_mtu = sizeof(buffer); size_t min_send_mtu = sizeof(usrp2_ctrl_data_t), max_send_mtu = sizeof(buffer); @@ -233,23 +242,28 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){ device_addrs_t device_args = separate_device_addr(device_addr); - //calculate the minimum send and recv mtu of all devices - mtu_result_t mtu = determine_mtu(device_args[0]["addr"]); - for (size_t i = 1; i < device_args.size(); i++){ - mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]); - mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu); - mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu); - } + try{ + //calculate the minimum send and recv mtu of all devices + mtu_result_t mtu = determine_mtu(device_args[0]["addr"]); + for (size_t i = 1; i < device_args.size(); i++){ + mtu_result_t mtu_i = determine_mtu(device_args[i]["addr"]); + mtu.recv_mtu = std::min(mtu.recv_mtu, mtu_i.recv_mtu); + mtu.send_mtu = std::min(mtu.send_mtu, mtu_i.send_mtu); + } - //use the discovered mtu or clip the users requested mtu - mtu.recv_mtu = std::min(size_t(device_addr.cast("recv_frame_size", 9000)), mtu.recv_mtu); - mtu.send_mtu = std::min(size_t(device_addr.cast("send_frame_size", 9000)), mtu.send_mtu); + //use the discovered mtu or clip the users requested mtu + mtu.recv_mtu = std::min(size_t(device_addr.cast("recv_frame_size", 9000)), mtu.recv_mtu); + mtu.send_mtu = std::min(size_t(device_addr.cast("send_frame_size", 9000)), mtu.send_mtu); - device_addr["recv_frame_size"] = boost::lexical_cast(mtu.recv_mtu); - device_addr["send_frame_size"] = boost::lexical_cast(mtu.send_mtu); + device_addr["recv_frame_size"] = boost::lexical_cast(mtu.recv_mtu); + device_addr["send_frame_size"] = boost::lexical_cast(mtu.send_mtu); - std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; - std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + std::cout << boost::format("Current recv frame size: %d bytes") % mtu.recv_mtu << std::endl; + std::cout << boost::format("Current send frame size: %d bytes") % mtu.send_mtu << std::endl; + } + catch(const uhd::not_implemented_error &){ + //just ignore this error, makes older fw work... + } device_args = separate_device_addr(device_addr); //update args for new frame sizes -- cgit v1.2.3 From 668402f27e34422a9afdc4d12f0f5575228f815b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 13 Apr 2011 10:59:18 -0700 Subject: usrp2: use the firmware's discovered compat number --- host/lib/usrp/usrp2/usrp2_iface.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 6e1d69044..6b3409ecc 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -46,9 +46,20 @@ public: /*********************************************************************** * Structors **********************************************************************/ - usrp2_iface_impl(udp_simple::sptr ctrl_transport){ - _ctrl_transport = ctrl_transport; - _ctrl_seq_num = 0; + usrp2_iface_impl(udp_simple::sptr ctrl_transport): + _ctrl_transport(ctrl_transport), + _ctrl_seq_num(0), + _protocol_compat(0) //initialized below... + { + //Obtain the firmware's compat number. + //Save the response compat number for communication. + //TODO can choose to reject certain older compat numbers + usrp2_ctrl_data_t ctrl_data; + ctrl_data.id = htonl(USRP2_CTRL_ID_WAZZUP_BRO); + ctrl_data = ctrl_send_and_recv(ctrl_data, 0, ~0); + if (ntohl(ctrl_data.id) != USRP2_CTRL_ID_WAZZUP_DUDE) + throw uhd::runtime_error("firmware not responding"); + _protocol_compat = ntohl(ctrl_data.proto_ver); mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_N100); switch(this->get_rev()){ @@ -238,7 +249,7 @@ public: //fill in the seq number and send usrp2_ctrl_data_t out_copy = out_data; - out_copy.proto_ver = htonl(USRP2_FW_COMPAT_NUM); + out_copy.proto_ver = htonl(_protocol_compat); out_copy.seq = htonl(++_ctrl_seq_num); _ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t))); @@ -292,6 +303,7 @@ private: //used in send/recv boost::mutex _ctrl_mutex; boost::uint32_t _ctrl_seq_num; + boost::uint32_t _protocol_compat; /*********************************************************************** * Private Templated Peek and Poke -- cgit v1.2.3 From 5e8b0752a41f836f82c64a2c4e25a3786259b60e Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 13 Apr 2011 16:10:34 -0700 Subject: uhd: python messages more verbose + print boost configuration info --- host/CMakeLists.txt | 6 ++++++ host/Modules/UHDPython.cmake | 27 ++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 552fe492c..6b342c2d3 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -102,6 +102,8 @@ ENDIF(WIN32) ######################################################################## # Setup Boost ######################################################################## +MESSAGE(STATUS "") +MESSAGE(STATUS "Configuring Boost C++ Libraries...") SET(BOOST_REQUIRED_COMPONENTS date_time filesystem @@ -131,6 +133,10 @@ FIND_PACKAGE(Boost 1.36 COMPONENTS ${BOOST_REQUIRED_COMPONENTS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) +MESSAGE(STATUS "Boost include directories: ${Boost_INCLUDE_DIRS}") +MESSAGE(STATUS "Boost library directories: ${Boost_LIBRARY_DIRS}") +MESSAGE(STATUS "Boost libraries: ${Boost_LIBRARIES}") + ######################################################################## # Check Python Modules ######################################################################## diff --git a/host/Modules/UHDPython.cmake b/host/Modules/UHDPython.cmake index 90a778609..fdcdccb4b 100644 --- a/host/Modules/UHDPython.cmake +++ b/host/Modules/UHDPython.cmake @@ -15,9 +15,14 @@ # along with this program. If not, see . # +IF(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) +SET(INCLUDED_UHD_PYTHON_CMAKE TRUE) + ######################################################################## # Setup Python ######################################################################## +MESSAGE(STATUS "") +MESSAGE(STATUS "Configuring the python interpreter...") #this allows the user to override PYTHON_EXECUTABLE IF(PYTHON_EXECUTABLE) @@ -42,6 +47,9 @@ ENDIF(PYTHON_EXECUTABLE) #make the path to the executable appear in the cmake gui SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "python interpreter") +MESSAGE(STATUS "Python interpreter: ${PYTHON_EXECUTABLE}") +MESSAGE(STATUS "Override with: -DPYTHON_EXECUTABLE=") + IF(NOT PYTHONINTERP_FOUND) MESSAGE(FATAL_ERROR "Error: Python interpretor required by the build system.") ENDIF(NOT PYTHONINTERP_FOUND) @@ -53,17 +61,26 @@ MACRO(PYTHON_CHECK_MODULE desc mod cmd have) COMMAND ${PYTHON_EXECUTABLE} -c " ######################################### try: import ${mod} -except: exit(-1) +except: exit(1) try: assert ${cmd} -except: exit(-1) +except: exit(2) +exit(0) #########################################" RESULT_VARIABLE ${have} ) IF(${have} EQUAL 0) MESSAGE(STATUS "Python checking for ${desc} - found") SET(${have} TRUE) - ELSE(${have} EQUAL 0) - MESSAGE(STATUS "Python checking for ${desc} - not found") + ELSEIF(${have} EQUAL 1) + MESSAGE(STATUS "Python checking for ${desc} - \"import ${mod}\" failed") + SET(${have} FALSE) + ELSEIF(${have} EQUAL 2) + MESSAGE(STATUS "Python checking for ${desc} - \"assert ${cmd}\" failed") SET(${have} FALSE) - ENDIF(${have} EQUAL 0) + ELSE() + MESSAGE(STATUS "Python checking for ${desc} - unknown error") + SET(${have} FALSE) + ENDIF() ENDMACRO(PYTHON_CHECK_MODULE) + +ENDIF(NOT DEFINED INCLUDED_UHD_PYTHON_CMAKE) -- cgit v1.2.3 From 291a46b86e8e639b711a609134ace667235eeb91 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 14 Apr 2011 09:34:37 -0700 Subject: uhd: specify the UHD_PKG_DATA_PATH once (since images shipped w/ drivers) --- host/lib/CMakeLists.txt | 16 +++------------- host/lib/constants.hpp.in | 3 +-- host/lib/utils/paths.cpp | 8 ++------ 3 files changed, 6 insertions(+), 21 deletions(-) diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 8ca7c7dca..618e33608 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -81,19 +81,9 @@ INCLUDE_SUBDIRECTORY(utils) ######################################################################## # Setup compiled-in constants for data directories ######################################################################## -FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} LOCAL_PKG_DATA_DIR) -STRING(REPLACE "\\" "\\\\" LOCAL_PKG_DATA_DIR ${LOCAL_PKG_DATA_DIR}) -MESSAGE(STATUS "Local package data directory: ${LOCAL_PKG_DATA_DIR}") - -IF(UNIX) - #on unix systems, installers will use this directory for the package data - FILE(TO_NATIVE_PATH /usr/${PKG_DATA_DIR} INSTALLER_PKG_DATA_DIR) -ELSE() - #for the NSIS installer, this will be the default path for package data - FILE(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR}" INSTALLER_PKG_DATA_DIR) -ENDIF() -STRING(REPLACE "\\" "\\\\" INSTALLER_PKG_DATA_DIR ${INSTALLER_PKG_DATA_DIR}) -MESSAGE(STATUS "Installer package data directory: ${INSTALLER_PKG_DATA_DIR}") +FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH) +STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH}) +MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}") CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp.in diff --git a/host/lib/constants.hpp.in b/host/lib/constants.hpp.in index d62dda1cb..2e0495b12 100644 --- a/host/lib/constants.hpp.in +++ b/host/lib/constants.hpp.in @@ -20,7 +20,6 @@ //these should be pre-processor macros to avoid static initialization issues #define UHD_VERSION_STRING "@UHD_VERSION@-@UHD_BUILD_INFO@" -#define LOCAL_PKG_DATA_DIR "@LOCAL_PKG_DATA_DIR@" -#define INSTALLER_PKG_DATA_DIR "@INSTALLER_PKG_DATA_DIR@" +#define UHD_PKG_DATA_PATH "@UHD_PKG_DATA_PATH@" #endif /* INCLUDED_LIBUHD_CONSTANTS_HPP */ diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 329695873..0ddc80d6e 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -76,16 +76,12 @@ static std::vector get_env_paths(const std::string &var_name){ **********************************************************************/ std::vector get_image_paths(void){ std::vector paths = get_env_paths("UHD_IMAGE_PATH"); - paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "images"); - if (not std::string(INSTALLER_PKG_DATA_DIR).empty()) - paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "images"); + paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "images"); return paths; } std::vector get_module_paths(void){ std::vector paths = get_env_paths("UHD_MODULE_PATH"); - paths.push_back(fs::path(LOCAL_PKG_DATA_DIR) / "modules"); - if (not std::string(INSTALLER_PKG_DATA_DIR).empty()) - paths.push_back(fs::path(INSTALLER_PKG_DATA_DIR) / "modules"); + paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "modules"); return paths; } -- cgit v1.2.3 From d24d9d9bd9e6783aa1bb0692386e05f67c019329 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 14 Apr 2011 11:54:19 -0700 Subject: uhd: only set UHD_BUILD_INFO on successful return (also removed unused cruft) --- host/Modules/UHDVersion.cmake | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/host/Modules/UHDVersion.cmake b/host/Modules/UHDVersion.cmake index eb25db488..86d3133a8 100644 --- a/host/Modules/UHDVersion.cmake +++ b/host/Modules/UHDVersion.cmake @@ -42,34 +42,18 @@ ENDIF() IF(UHD_BUILD_INFO_DISCOVERY) - #grab the git log entry for the current head - EXECUTE_PROCESS( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GIT_EXECUTABLE} log HEAD~..HEAD --date=raw -n1 - OUTPUT_VARIABLE _git_log OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - #extract the timestamp from the git log entry - EXECUTE_PROCESS( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${PYTHON_EXECUTABLE} -c "import re; print re.match('^.*Date:\\s*(\\d*).*$', ''' ${_git_log} ''', re.MULTILINE | re.DOTALL).groups()[0]" - OUTPUT_VARIABLE _git_timestamp OUTPUT_STRIP_TRAILING_WHITESPACE - ) - - #format the timestamp into YYYY-MM-DD-HH-MM-SS - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d%H%M%S', time.gmtime(${_git_timestamp}))" - OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE - ) - #grab the git ref id for the current head EXECUTE_PROCESS( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE _git_rev_result ) - SET(UHD_BUILD_INFO ${_git_rev}) + #only set the build info on success + IF(_git_rev_result EQUAL 0) + SET(UHD_BUILD_INFO ${_git_rev}) + ENDIF() ENDIF(UHD_BUILD_INFO_DISCOVERY) ######################################################################## -- cgit v1.2.3 From 98a05d85cd6537dee9bf2f48d0e068d322363fc4 Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Wed, 13 Apr 2011 19:03:18 -0700 Subject: Updated documentation and improved XCVR RSSI calculation Documented dboard sensors Documented DBSRX2 Added description of direct conversion vs low IF for each dboard Added E1xx docs for adding refclock and pps connectors XCVR rssi calculation was in unscaled dB units Used chart in datasheet (pg 16) to rescale to dBm --- host/docs/dboards.rst | 119 ++++++++++++++++++++++++++++------- host/docs/usrp_e1xx.rst | 38 +++++++++++ host/lib/usrp/dboard/db_xcvr2450.cpp | 13 +++- 3 files changed, 144 insertions(+), 26 deletions(-) diff --git a/host/docs/dboards.rst b/host/docs/dboards.rst index 419456df2..373189441 100644 --- a/host/docs/dboards.rst +++ b/host/docs/dboards.rst @@ -27,12 +27,14 @@ Though the magic of aliasing, you can down-convert signals greater than the Nyquist rate of the ADC. BasicRX Bandwidth (Hz): - For Real-Mode (A or B subdevice): 250M - For Complex (AB or BA subdevice): 500M + +* For Real-Mode (A or B subdevice): 250M +* For Complex (AB or BA subdevice): 500M LFRX Bandwidth (Hz): - For Real-Mode (A or B subdevice): 33M - For Complex (AB or BA subdevice): 66M + +* For Real-Mode (A or B subdevice): 33M +* For Complex (AB or BA subdevice): 66M ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Basic TX and and LFTX @@ -49,31 +51,67 @@ Though the magic of aliasing, you can up-convert signals greater than the Nyquist rate of the DAC. BasicTX Bandwidth (Hz): 250M - For Real-Mode (A or B subdevice): 250M - For Complex (AB or BA subdevice): 500M + +* For Real-Mode (A or B subdevice): 250M +* For Complex (AB or BA subdevice): 500M LFTX Bandwidth (Hz): 33M - For Real-Mode (A or B subdevice): 33M - For Complex (AB or BA subdevice): 66M + +* For Real-Mode (A or B subdevice): 33M +* For Complex (AB or BA subdevice): 66M ^^^^^^^^^^^^^^^^^^^^^^^^^^^ DBSRX ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The DBSRX board has 1 quadrature subdevice. +The DBSRX board has 1 quadrature subdevice. +It defaults to direct conversion, but can use a low IF through lo_offset in uhd::tune_request_t Receive Antennas: **J3** The board has no user selectable antenna setting -Receive Gains: - **GC1**, Range: 0-56dB - **GC2**, Range: 0-24dB +Receive Gains: + +* **GC1**, Range: 0-56dB +* **GC2**, Range: 0-24dB Bandwidth (Hz): 8M-66M +Sensors: + +* **lo_locked**: boolean for LO lock state + +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +DBSRX2 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The DBSRX2 board has 1 quadrature subdevice. +It defaults to direct conversion, but can use a low IF through lo_offset in uhd::tune_request_t + +Receive Antennas: **J3** + +The board has no user selectable antenna setting + +Receive Gains: + +* **GC1**, Range: 0-73dB +* **BBG**, Range: 0-15dB + +Bandwidth (Hz): 8M-80M + +Sensors: + +* **lo_locked**: boolean for LO lock state + ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RFX Series ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The RFX Series boards have 2 quadrature subdevices, one transmit, one receive. +Transmit defaults to low IF and Receive defaults to direct conversion. +The IF can be adjusted through lo_offset in uhd::tune_request_t + +The RFX Series boards have independent receive and transmit LO's and synthesizers +allowing full-duplex operation on different transmit and receive frequencies. + Transmit Antennas: **TX/RX** Receive Antennas: **TX/RX** or **RX2** @@ -85,12 +123,21 @@ the receive antenna will always be set to RX2, regardless of the settings. Receive Gains: **PGA0**, Range: 0-70dB (except RFX400 range is 0-45dB) Bandwidths (Hz): - * **RX**: 40M - * **TX**: 40M + +* **RX**: 40M +* **TX**: 40M + +Sensors: + +* **lo_locked**: boolean for LO lock state ^^^^^^^^^^^^^^^^^^^^^^^^^^^ XCVR 2450 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The XCVR2450 has 2 quadrature subdevices, one transmit, one receive. +Transmit and Receive default to direct conversion but +can be used in low IF mode through lo_offset in uhd::tune_request_t + The XCVR2450 has a non-contiguous tuning range consisting of a high band (4.9-6.0GHz) and a low band (2.4-2.5GHz). @@ -106,20 +153,35 @@ The XCVR2450 does not support full-duplex mode, attempting to operate in full-duplex will result in transmit-only operation. Transmit Gains: - * **VGA**, Range: 0-30dB - * **BB**, Range: 0-5dB + +* **VGA**, Range: 0-30dB +* **BB**, Range: 0-5dB Receive Gains: - * **LNA**, Range: 0-30.5dB - * **VGA**, Range: 0-62dB + +* **LNA**, Range: 0-30.5dB +* **VGA**, Range: 0-62dB Bandwidths (Hz): - * **RX**: 15M, 19M, 28M, 36M; (each +-0, 5, or 10%) - * **TX**: 24M, 36M, 48M + +* **RX**: 15M, 19M, 28M, 36M; (each +-0, 5, or 10%) +* **TX**: 24M, 36M, 48M + +Sensors: + +* **lo_locked**: boolean for LO lock state +* **rssi**: float for rssi in dBm ^^^^^^^^^^^^^^^^^^^^^^^^^^^ WBX Series ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The WBX Series boards have 2 quadrature subdevices, one transmit, one receive. +Transmit and Receive default to direct conversion but +can be used in low IF mode through lo_offset in uhd::tune_request_t + +The WBX Series boards have independent receive and transmit LO's and synthesizers +allowing full-duplex operation on different transmit and receive frequencies. + Transmit Antennas: **TX/RX** Receive Antennas: **TX/RX** or **RX2** @@ -133,17 +195,26 @@ Transmit Gains: **PGA0**, Range: 0-25dB Receive Gains: **PGA0**, Range: 0-31.5dB Bandwidths (Hz): - * **RX**: 40M - * **TX**: 40M + +* **RX**: 40M +* **TX**: 40M + +Sensors: + +* **lo_locked**: boolean for LO lock state ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TVRX ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The TVRX board has 1 real-mode subdevice. +It is operated at a low IF. + Receive Antennas: RX Receive Gains: - * **RF**, Range: -13.3-50.3dB (frequency-dependent) - * **IF**, Range: -1.5-32.5dB + +* **RF**, Range: -13.3-50.3dB (frequency-dependent) +* **IF**, Range: -1.5-32.5dB Bandwidth: 6MHz diff --git a/host/docs/usrp_e1xx.rst b/host/docs/usrp_e1xx.rst index fb5848bad..2818a0a65 100644 --- a/host/docs/usrp_e1xx.rst +++ b/host/docs/usrp_e1xx.rst @@ -63,3 +63,41 @@ Run the following commands to restore the clock generator to a usable state: cd /share/uhd/usrp_e_utilities ./usrp-e-utility --fpga=../images/usrp_e100_pt_fpga.bin --reclk + + +------------------------------------------------------------------------ +Clock Synchronization +------------------------------------------------------------------------ + + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Ref Clock - 10MHz +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +The E1xx has a 10MHz TCXO which can be used to discipline the flexible clocking by +selecting REF_INT for the clock_config_t. + +Alternately, an external 10MHz reference clock can be supplied by soldering a connector. + +* Connector J10 (REF_IN) needs MCX connector WM5541-ND or similar +* Square wave will offer the best phase noise performance, but sinusoid is acceptable +* Power level: 0 to 15dBm +* Select REF_SMA in clock_config_t + + +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +PPS - Pulse Per Second +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +An exteral PPS signal for timestamp synchronization can be supplied by soldering a connector. + +* Connector J13 (PPS) needs MCX connector WM5541-ND or similar +* Requires a square wave signal +* Amplitude: 3.3 to 5Vpp + +Test the PPS input with the following app: + +* are device address arguments (optional if only one USRP is on your machine) + +:: + + cd /share/uhd/examples + ./test_pps_input --args= diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 9d25b30a5..70b0bbabd 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -152,12 +152,21 @@ private: * \return the rssi in dB */ double get_rssi(void){ + //*FIXME* RSSI depends on LNA Gain Setting (datasheet pg 16 top middle chart) + double max_power; + switch(_max2829_regs.rx_lna_gain){ + case 0: + case 1: max_power = 0; break; + case 2: max_power = -15; break; + case 3: max_power = -30.5; break; + } + //constants for the rssi calculation static const double min_v = 0.5, max_v = 2.5; static const double rssi_dyn_range = 60; //calculate the rssi from the voltage double voltage = this->get_iface()->read_aux_adc(dboard_iface::UNIT_RX, dboard_iface::AUX_ADC_B); - return rssi_dyn_range*(voltage - min_v)/(max_v - min_v); + return max_power - rssi_dyn_range*(voltage - min_v)/(max_v - min_v); } }; @@ -621,7 +630,7 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ if (key.name == "lo_locked") val = sensor_value_t("LO", this->get_locked(), "locked", "unlocked"); else if (key.name == "rssi") - val = sensor_value_t("RSSI", this->get_rssi(), "dB"); + val = sensor_value_t("RSSI", this->get_rssi(), "dBm"); else UHD_THROW_INVALID_CODE_PATH(); return; -- cgit v1.2.3 From 905a681afd3b8d089a3dbfe7aa31bbcb5a020c05 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 16 Apr 2011 11:12:33 -0700 Subject: uhd: added option for nsis installer to set PATH --- host/Modules/UHDPackage.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index bf31df3b3..1988c7f11 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -139,5 +139,10 @@ SET(CPACK_DEBIAN_PACKAGE_RECOMMENDS "python, python-tk") ######################################################################## SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, libusb1") +######################################################################## +# Setup CPack NSIS +######################################################################## +SET(CPACK_NSIS_MODIFY_PATH ON) + ######################################################################## INCLUDE(CPack) #include after setting vars -- cgit v1.2.3 From 1304340f269b6474a49970ee302e08ca9ed8d0ed Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Apr 2011 10:58:50 -0700 Subject: rfx: changes to pick from the dboard clock rates and use R=1 --- host/lib/usrp/dboard/db_rfx.cpp | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index 725b5cc03..f938c749a 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -312,7 +312,8 @@ double rfx_xcvr::set_lo_freq( (8, adf4360_regs_t::BAND_SELECT_CLOCK_DIV_8) ; - double actual_freq=0, ref_freq = this->get_iface()->get_clock_rate(unit); + std::vector clock_rates = this->get_iface()->get_clock_rates(unit); + double actual_freq = 0, ref_freq = 0; int R=0, BS=0, P=0, B=0, A=0; /* @@ -325,27 +326,31 @@ double rfx_xcvr::set_lo_freq( * fvco = [P*B + A] * fref/R * fvco*R/fref = P*B + A = N */ - for(R = 2; R <= 32; R+=2){ - BOOST_FOREACH(BS, bandsel_to_enum.keys()){ - if (ref_freq/R/BS > 1e6) continue; //constraint on band select clock - BOOST_FOREACH(P, prescaler_to_enum.keys()){ - //calculate B and A from N - double N = target_freq*R/ref_freq; - B = int(std::floor(N/P)); - A = boost::math::iround(N - P*B); - if (B < A or B > 8191 or B < 3 or A > 31) continue; //constraints on A, B - //calculate the actual frequency - actual_freq = double(P*B + A)*ref_freq/R; - if (actual_freq/P > 300e6) continue; //constraint on prescaler output - //constraints met: exit loop - goto done_loop; + for(R = 1; R <= 32; R+=((R==1)?1:2)){ + BOOST_FOREACH(ref_freq, uhd::reversed(uhd::sorted(clock_rates))){ + BOOST_FOREACH(BS, bandsel_to_enum.keys()){ + if (ref_freq/R/BS > 1e6) continue; //constraint on band select clock + BOOST_FOREACH(P, prescaler_to_enum.keys()){ + //calculate B and A from N + double N = target_freq*R/ref_freq; + B = int(std::floor(N/P)); + A = boost::math::iround(N - P*B); + if (B < A or B > 8191 or B < 3 or A > 31) continue; //constraints on A, B + //calculate the actual frequency + actual_freq = double(P*B + A)*ref_freq/R; + if (actual_freq/P > 300e6) continue; //constraint on prescaler output + //constraints met: exit loop + goto done_loop; + } } } } done_loop: if (rfx_debug) std::cerr << boost::format( - "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d" - ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) << std::endl; + "RFX tune: R=%d, BS=%d, P=%d, B=%d, A=%d, DIV2=%d, ref=%fMHz" + ) % R % BS % P % B % A % int(_div2[unit] && (!is_rx_rfx400)) % (ref_freq/1e6) << std::endl; + + this->get_iface()->set_clock_rate(unit, ref_freq); //load the register values adf4360_regs_t regs; -- cgit v1.2.3 From 46d0e64859cfabfc24ea04051fca624a185bff8b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Apr 2011 17:17:32 -0700 Subject: uhd: use UHD_PKG_DATA_PATH environment variable to override the one in constants The installer sets UHD_PKG_DATA_PATH, we can can handle transplanted builds. --- host/Modules/UHDPackage.cmake | 10 ++++++++++ host/lib/utils/paths.cpp | 27 +++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 1988c7f11..416d89998 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -144,5 +144,15 @@ SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, libusb1") ######################################################################## SET(CPACK_NSIS_MODIFY_PATH ON) +SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") + +SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" \\\"$INSTDIR\\\\share\\\\uhd\\\" +") + +SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" +") + ######################################################################## INCLUDE(CPack) #include after setting vars diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 0ddc80d6e..a0e4da547 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -18,14 +18,13 @@ #include "constants.hpp" #include #include -#include #include #include #include +#include #include #include -namespace po = boost::program_options; namespace fs = boost::filesystem; /*********************************************************************** @@ -44,22 +43,14 @@ namespace fs = boost::filesystem; /*********************************************************************** * Get a list of paths for an environment variable **********************************************************************/ -static std::string name_mapper(const std::string &key, const std::string &var_name){ - return (var_name == key)? var_name : ""; +static std::string get_env_var(const std::string &var_name, const std::string &def_val = ""){ + const char *var_value_ptr = std::getenv(var_name.c_str()); + return (var_value_ptr == NULL)? def_val : var_value_ptr; } static std::vector get_env_paths(const std::string &var_name){ - //register the options - std::string var_value; - po::options_description desc; - desc.add_options() - (var_name.c_str(), po::value(&var_value)->default_value("")) - ; - //parse environment variables - po::variables_map vm; - po::store(po::parse_environment(desc, boost::bind(&name_mapper, var_name, _1)), vm); - po::notify(vm); + std::string var_value = get_env_var(var_name); //convert to filesystem path, filter blank paths std::vector paths; @@ -74,14 +65,18 @@ static std::vector get_env_paths(const std::string &var_name){ /*********************************************************************** * Get a list of special purpose paths **********************************************************************/ +static fs::path get_uhd_pkg_data_path(void){ + return fs::path(get_env_var("UHD_PKG_DATA_PATH", UHD_PKG_DATA_PATH)); +} + std::vector get_image_paths(void){ std::vector paths = get_env_paths("UHD_IMAGE_PATH"); - paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "images"); + paths.push_back(get_uhd_pkg_data_path() / "images"); return paths; } std::vector get_module_paths(void){ std::vector paths = get_env_paths("UHD_MODULE_PATH"); - paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "modules"); + paths.push_back(get_uhd_pkg_data_path() / "modules"); return paths; } -- cgit v1.2.3 From a28099fe4abe10b11c9234d67b243adbd20ce1a1 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 19 Apr 2011 09:36:53 -0700 Subject: usrp2: improve the compatibility error messages --- host/lib/usrp/usrp2/mboard_impl.cpp | 6 ++++-- host/lib/usrp/usrp2/usrp2_iface.cpp | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 7a6c596bc..29e0535f8 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -71,8 +71,10 @@ usrp2_mboard_impl::usrp2_mboard_impl( const boost::uint32_t fpga_compat_num = _iface->peek32(_iface->regs.compat_num_rb); if (fpga_compat_num != USRP2_FPGA_COMPAT_NUM){ throw uhd::runtime_error(str(boost::format( - "Expected fpga compatibility number %d, but got %d:\n" - "The fpga build is not compatible with the host code build." + "\nPlease update the firmware and FPGA images for your device.\n" + "See the application notes for USRP2/N-Series for instructions.\n" + "Expected FPGA compatibility number %d, but got %d:\n" + "The FPGA build is not compatible with the host code build." ) % int(USRP2_FPGA_COMPAT_NUM) % fpga_compat_num)); } diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 6b3409ecc..d88d31765 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -242,11 +242,6 @@ public: ){ boost::mutex::scoped_lock lock(_ctrl_mutex); - std::string range = (lo == hi)? - str(boost::format("%d") % hi) : - str(boost::format("[%d to %d]") % lo % hi) - ; - //fill in the seq number and send usrp2_ctrl_data_t out_copy = out_data; out_copy.proto_ver = htonl(_protocol_compat); @@ -261,9 +256,11 @@ public: boost::uint32_t compat = ntohl(ctrl_data_in->proto_ver); if(len >= sizeof(boost::uint32_t) and (hi < compat or lo > compat)){ throw uhd::runtime_error(str(boost::format( + "\nPlease update the firmware and FPGA images for your device.\n" + "See the application notes for USRP2/N-Series for instructions.\n" "Expected protocol compatibility number %s, but got %d:\n" "The firmware build is not compatible with the host code build." - ) % range % compat)); + ) % ((lo == hi)? (boost::format("%d") % hi) : (boost::format("[%d to %d]") % lo % hi)) % compat)); } if (len >= sizeof(usrp2_ctrl_data_t) and ntohl(ctrl_data_in->seq) == _ctrl_seq_num){ return *ctrl_data_in; -- cgit v1.2.3 From 06e10b5f469b8b06af33a8a95a6302a1e365b396 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 18 Apr 2011 17:17:32 -0700 Subject: uhd: use UHD_PKG_DATA_PATH environment variable to override the one in constants The installer sets UHD_PKG_DATA_PATH, we can can handle transplanted builds. --- host/Modules/UHDPackage.cmake | 10 ++++++++++ host/lib/utils/paths.cpp | 27 +++++++++++---------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/host/Modules/UHDPackage.cmake b/host/Modules/UHDPackage.cmake index 1988c7f11..416d89998 100644 --- a/host/Modules/UHDPackage.cmake +++ b/host/Modules/UHDPackage.cmake @@ -144,5 +144,15 @@ SET(CPACK_RPM_PACKAGE_REQUIRES "boost-devel, libusb1") ######################################################################## SET(CPACK_NSIS_MODIFY_PATH ON) +SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") + +SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " + WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" \\\"$INSTDIR\\\\share\\\\uhd\\\" +") + +SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " + DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" +") + ######################################################################## INCLUDE(CPack) #include after setting vars diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 0ddc80d6e..a0e4da547 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -18,14 +18,13 @@ #include "constants.hpp" #include #include -#include #include #include #include +#include #include #include -namespace po = boost::program_options; namespace fs = boost::filesystem; /*********************************************************************** @@ -44,22 +43,14 @@ namespace fs = boost::filesystem; /*********************************************************************** * Get a list of paths for an environment variable **********************************************************************/ -static std::string name_mapper(const std::string &key, const std::string &var_name){ - return (var_name == key)? var_name : ""; +static std::string get_env_var(const std::string &var_name, const std::string &def_val = ""){ + const char *var_value_ptr = std::getenv(var_name.c_str()); + return (var_value_ptr == NULL)? def_val : var_value_ptr; } static std::vector get_env_paths(const std::string &var_name){ - //register the options - std::string var_value; - po::options_description desc; - desc.add_options() - (var_name.c_str(), po::value(&var_value)->default_value("")) - ; - //parse environment variables - po::variables_map vm; - po::store(po::parse_environment(desc, boost::bind(&name_mapper, var_name, _1)), vm); - po::notify(vm); + std::string var_value = get_env_var(var_name); //convert to filesystem path, filter blank paths std::vector paths; @@ -74,14 +65,18 @@ static std::vector get_env_paths(const std::string &var_name){ /*********************************************************************** * Get a list of special purpose paths **********************************************************************/ +static fs::path get_uhd_pkg_data_path(void){ + return fs::path(get_env_var("UHD_PKG_DATA_PATH", UHD_PKG_DATA_PATH)); +} + std::vector get_image_paths(void){ std::vector paths = get_env_paths("UHD_IMAGE_PATH"); - paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "images"); + paths.push_back(get_uhd_pkg_data_path() / "images"); return paths; } std::vector get_module_paths(void){ std::vector paths = get_env_paths("UHD_MODULE_PATH"); - paths.push_back(fs::path(UHD_PKG_DATA_PATH) / "modules"); + paths.push_back(get_uhd_pkg_data_path() / "modules"); return paths; } -- cgit v1.2.3 From 00bc8d50d5a2528704441ef5532fea13106a8d30 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 19 Apr 2011 16:58:12 -0700 Subject: uhd: removed constants.hpp.in, replaced w/ per source compile defines --- host/lib/CMakeLists.txt | 17 ++++++----------- host/lib/constants.hpp.in | 25 ------------------------- host/lib/utils/CMakeLists.txt | 13 +++++++++++++ host/lib/utils/paths.cpp | 1 - host/lib/version.cpp | 8 +------- 5 files changed, 20 insertions(+), 44 deletions(-) delete mode 100644 host/lib/constants.hpp.in diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt index 618e33608..fca4730d8 100644 --- a/host/lib/CMakeLists.txt +++ b/host/lib/CMakeLists.txt @@ -79,23 +79,18 @@ INCLUDE_SUBDIRECTORY(usrp) INCLUDE_SUBDIRECTORY(utils) ######################################################################## -# Setup compiled-in constants for data directories +# Setup UHD_VERSION_STRING for version.cpp ######################################################################## -FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH) -STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH}) -MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}") - -CONFIGURE_FILE( - ${CMAKE_CURRENT_SOURCE_DIR}/constants.hpp.in - ${CMAKE_CURRENT_BINARY_DIR}/constants.hpp -@ONLY) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp + PROPERTIES COMPILE_DEFINITIONS + "UHD_VERSION_STRING=\"${UHD_VERSION}-${UHD_BUILD_INFO}\"" +) ######################################################################## # Append to the list of sources for lib uhd ######################################################################## LIBUHD_APPEND_SOURCES( - ${CMAKE_CURRENT_BINARY_DIR}/constants.hpp ${CMAKE_CURRENT_SOURCE_DIR}/device.cpp ${CMAKE_CURRENT_SOURCE_DIR}/exception.cpp ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp diff --git a/host/lib/constants.hpp.in b/host/lib/constants.hpp.in deleted file mode 100644 index 2e0495b12..000000000 --- a/host/lib/constants.hpp.in +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_LIBUHD_CONSTANTS_HPP -#define INCLUDED_LIBUHD_CONSTANTS_HPP - -//these should be pre-processor macros to avoid static initialization issues -#define UHD_VERSION_STRING "@UHD_VERSION@-@UHD_BUILD_INFO@" -#define UHD_PKG_DATA_PATH "@UHD_PKG_DATA_PATH@" - -#endif /* INCLUDED_LIBUHD_CONSTANTS_HPP */ diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 26c02b5b4..1314f7475 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -111,6 +111,19 @@ SET_SOURCE_FILES_PROPERTIES( PROPERTIES COMPILE_DEFINITIONS "${LOAD_MODULES_DEFS}" ) +######################################################################## +# Define UHD_PKG_DATA_PATH for paths.cpp +######################################################################## +FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH) +STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH}) +MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}") + +SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp + PROPERTIES COMPILE_DEFINITIONS + "UHD_PKG_DATA_PATH=\"${UHD_PKG_DATA_PATH}\"" +) + ######################################################################## # Append sources ######################################################################## diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index a0e4da547..a3dd377e5 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -15,7 +15,6 @@ // along with this program. If not, see . // -#include "constants.hpp" #include #include #include diff --git a/host/lib/version.cpp b/host/lib/version.cpp index 93fdecb1a..d75cc8fda 100644 --- a/host/lib/version.cpp +++ b/host/lib/version.cpp @@ -15,13 +15,7 @@ // along with this program. If not, see . // -#include "constants.hpp" #include - -std::string uhd::get_version_string(void){ - return UHD_VERSION_STRING; -} - #include #include #include @@ -31,7 +25,7 @@ UHD_STATIC_BLOCK(print_system_info){ << BOOST_PLATFORM << "; " << BOOST_COMPILER << "; " << "Boost_" << BOOST_VERSION << "; " - << "UHD_" << uhd::get_version_string() + << "UHD_" << UHD_VERSION_STRING << std::endl << std::endl ; } -- cgit v1.2.3