From ab4304f827cdfb5d46e392a14bad012378e4c4e7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Jul 2010 23:02:33 -0700 Subject: uhd: moved version extraction code into version.cmake --- host/CMakeLists.txt | 3 +- host/config/CPack.cmake | 70 ---------------------------------------------- host/config/Version.cmake | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 71 deletions(-) create mode 100644 host/config/Version.cmake (limited to 'host') diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 8e28ddb34..ceea5d024 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -20,9 +20,10 @@ PROJECT(UHD CXX) ENABLE_TESTING() ######################################################################## -# Config Files +# Config Files (include order is important) ######################################################################## INCLUDE(${CMAKE_SOURCE_DIR}/config/Python.cmake) +INCLUDE(${CMAKE_SOURCE_DIR}/config/Version.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/config/CPack.cmake) ######################################################################## diff --git a/host/config/CPack.cmake b/host/config/CPack.cmake index 2756c6ab8..a86f452f9 100644 --- a/host/config/CPack.cmake +++ b/host/config/CPack.cmake @@ -15,76 +15,6 @@ # along with this program. If not, see . # -######################################################################## -# Setup Version Numbers -######################################################################## -SET(UHD_VERSION_MAJOR 0) -SET(UHD_VERSION_MINOR 0) -SET(UHD_VERSION_PATCH 0) - -######################################################################## -# Get the current YYYYMMDD HHMMSS timestamp -######################################################################## - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d', time.gmtime())" - OUTPUT_VARIABLE UHD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE - ) - SET(UHD_VERSION_MAJOR ${UHD_DATE}) - - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%H%M%S', time.gmtime())" - OUTPUT_VARIABLE UHD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE - ) - SET(UHD_VERSION_MINOR ${UHD_TIME}) - -######################################################################## -# Find GIT to get repo information -######################################################################## -MESSAGE(STATUS "Checking for git") -FIND_PROGRAM(GIT git) -IF(${GIT} STREQUAL "GIT-NOTFOUND") - MESSAGE(STATUS "Checking for git - not found") -ELSE(${GIT} STREQUAL "GIT-NOTFOUND") - MESSAGE(STATUS "Checking for git - found") - - #grab the git log entry for the current head - EXECUTE_PROCESS( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GIT} log HEAD~..HEAD --date=raw - 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 - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d', time.gmtime(${_git_timestamp}))" - OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE - ) - SET(UHD_VERSION_MAJOR ${_git_date}) - - #format the timestamp into HH-MM-SS - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%H%M%S', time.gmtime(${_git_timestamp}))" - OUTPUT_VARIABLE _git_time OUTPUT_STRIP_TRAILING_WHITESPACE - ) - SET(UHD_VERSION_MINOR ${_git_time}) - - #grab the git ref id for the current head - EXECUTE_PROCESS( - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${GIT} rev-parse --short HEAD - OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE - ) - SET(UHD_VERSION_PATCH ${_git_rev}) - -ENDIF(${GIT} STREQUAL "GIT-NOTFOUND") - ######################################################################## # Setup CPack ######################################################################## diff --git a/host/config/Version.cmake b/host/config/Version.cmake new file mode 100644 index 000000000..a592a4565 --- /dev/null +++ b/host/config/Version.cmake @@ -0,0 +1,71 @@ +# +# Copyright 2010 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 . +# + +######################################################################## +# Setup Version Numbers +######################################################################## +SET(UHD_VERSION_MAJOR 0) +SET(UHD_VERSION_MINOR 0) +SET(UHD_VERSION_PATCH 0) + +######################################################################## +# Find GIT to get repo information +######################################################################## +MESSAGE(STATUS "Checking for git") +FIND_PROGRAM(GIT git) +IF(${GIT} STREQUAL "GIT-NOTFOUND") + MESSAGE(STATUS "Checking for git - not found") +ELSE(${GIT} STREQUAL "GIT-NOTFOUND") + MESSAGE(STATUS "Checking for git - found") + + #grab the git log entry for the current head + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${GIT} log HEAD~..HEAD --date=raw + 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 + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%Y%m%d', time.gmtime(${_git_timestamp}))" + OUTPUT_VARIABLE _git_date OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(UHD_VERSION_MAJOR ${_git_date}) + + #format the timestamp into HH-MM-SS + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import time; print time.strftime('%H%M%S', time.gmtime(${_git_timestamp}))" + OUTPUT_VARIABLE _git_time OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(UHD_VERSION_MINOR ${_git_time}) + + #grab the git ref id for the current head + EXECUTE_PROCESS( + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${GIT} rev-parse --short HEAD + OUTPUT_VARIABLE _git_rev OUTPUT_STRIP_TRAILING_WHITESPACE + ) + SET(UHD_VERSION_PATCH ${_git_rev}) + +ENDIF(${GIT} STREQUAL "GIT-NOTFOUND") -- cgit v1.2.3 From 1e2f457ee118f55d753a4c124315ab17f8eb5f1b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 22 Jul 2010 23:27:57 -0700 Subject: usrp: fix the N/2 cordic tune issue, use boost math sign inplace of my signum --- host/include/uhd/utils/algorithm.hpp | 11 ----------- host/lib/usrp/dsp_utils.hpp | 4 ++-- host/lib/usrp/tune_helper.cpp | 4 ++-- 3 files changed, 4 insertions(+), 15 deletions(-) (limited to 'host') diff --git a/host/include/uhd/utils/algorithm.hpp b/host/include/uhd/utils/algorithm.hpp index b52edc6b5..54bc78494 100644 --- a/host/include/uhd/utils/algorithm.hpp +++ b/host/include/uhd/utils/algorithm.hpp @@ -111,17 +111,6 @@ namespace std{ std::equal(boost::begin(range1), boost::end(range1), boost::begin(range2)); } - /*! - * A templated signum implementation. - * \param n the comparable to process - * \return -1 when n negative, +1 when n positive, otherwise 0 - */ - template inline int signum(T n){ - if (n < 0) return -1; - if (n > 0) return +1; - return 0; - } - /*! * A templated clip implementation. * \param val the value to clip between an upper and lower limit diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp index 2f246c788..ebed12c41 100644 --- a/host/lib/usrp/dsp_utils.hpp +++ b/host/lib/usrp/dsp_utils.hpp @@ -82,11 +82,11 @@ namespace dsp_type1{ double &freq, double codec_rate ){ - UHD_ASSERT_THROW(freq >= -codec_rate/2.0 and freq < codec_rate/2.0); + UHD_ASSERT_THROW(std::abs(freq) <= codec_rate/2.0); static const double scale_factor = std::pow(2.0, 32); //calculate the freq register word (signed) - boost::int32_t freq_word = boost::math::iround((freq / codec_rate) * scale_factor); + boost::int32_t freq_word = boost::int32_t(boost::math::round((freq / codec_rate) * scale_factor)); //update the actual frequency freq = (double(freq_word) / scale_factor) * codec_rate; diff --git a/host/lib/usrp/tune_helper.cpp b/host/lib/usrp/tune_helper.cpp index c5cce3ecf..e516477d3 100644 --- a/host/lib/usrp/tune_helper.cpp +++ b/host/lib/usrp/tune_helper.cpp @@ -16,10 +16,10 @@ // #include -#include #include #include #include //unit_t +#include #include using namespace uhd; @@ -46,7 +46,7 @@ static tune_result_t tune_xx_subdev_and_dxc( double delta_freq = std::fmod(target_freq - actual_inter_freq, dxc_sample_rate); bool outside_of_nyquist = std::abs(delta_freq) > dxc_sample_rate/2.0; double target_dxc_freq = (outside_of_nyquist)? - std::signum(delta_freq)*dxc_sample_rate - delta_freq : -delta_freq; + boost::math::sign(delta_freq)*dxc_sample_rate - delta_freq : -delta_freq; //invert the sign on the dxc freq given the following conditions if (unit == dboard_iface::UNIT_TX) target_dxc_freq *= -1.0; -- cgit v1.2.3 From f86c25317b457b280c697fc47905c79bdbbc0c93 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 26 Jul 2010 11:46:08 -0700 Subject: uhd: removed remaining template stuff from vrt packet handler, also tweaked format in rx timed samples --- host/examples/rx_timed_samples.cpp | 7 ++++--- host/lib/transport/vrt_packet_handler.hpp | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'host') diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 3b9acbb2c..4856f6779 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -74,8 +74,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //setup streaming std::cout << std::endl; - std::cout << boost::format("Begin streaming %u samples, %d seconds in the future...") - % total_num_samps % seconds_in_future << std::endl; + std::cout << boost::format( + "Begin streaming %u samples, %d 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; @@ -102,7 +103,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (num_acc_samps == 0) continue; std::cout << boost::format( "Got timeout before all samples received, possible packet loss, exiting loop..." - ) % md.error_code << std::endl; + ) << std::endl; goto done_loop; default: diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index 07ad9115c..cf9d649dd 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -286,7 +286,6 @@ namespace vrt_packet_handler{ * Pack a vrt header, copy-convert the data, and send it. * - helper function for vrt_packet_handler::send ******************************************************************/ - template static UHD_INLINE void _send1( send_state &state, const std::vector &buffs, @@ -295,7 +294,7 @@ namespace vrt_packet_handler{ uhd::transport::vrt::if_packet_info_t &if_packet_info, const uhd::io_type_t &io_type, const uhd::otw_type_t &otw_type, - vrt_packer_type vrt_packer, + const vrt_packer_t &vrt_packer, const get_send_buffs_t &get_send_buffs, size_t vrt_header_offset_words32 ){ -- cgit v1.2.3