Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host: Implement n-times repeated transmission in tx_samples_from_file example #679

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 45 additions & 19 deletions host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ cmake_minimum_required(VERSION 3.8)
if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) # Suppress Version warnings
endif(POLICY CMP0048)

project(UHD CXX C)
enable_testing()

#make sure our local CMake Modules path comes first
# Make sure our local CMake Modules path comes first
list(INSERT CMAKE_MODULE_PATH 0 ${UHD_SOURCE_DIR}/cmake/Modules)


########################################################################
# UHD Dependency Minimum Versions
########################################################################
Expand All @@ -41,6 +43,7 @@ set(RUAMEL.YAML_MIN_VERSION "0.15")
set(PY_MAKO_MIN_VERSION "0.4.2")
set(PY_REQUESTS_MIN_VERSION "2.0")


########################################################################
# Check Compiler Version
########################################################################
Expand All @@ -59,21 +62,22 @@ elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
RESULT_VARIABLE res ERROR_VARIABLE err
ERROR_STRIP_TRAILING_WHITESPACE)
if(${res} STREQUAL "0")
# output is in error stream
# Version output is in error stream
string(REGEX MATCH "^Apple.*" IS_APPLE ${err})

# Retrieve the compiler's version
if("${IS_APPLE}" STREQUAL "")
set(MIN_VERSION ${CLANG_MIN_VERSION})
set(APPLE_STR "")
# retrieve the compiler's version from it
string(REGEX MATCH "clang version [0-9.]+" CLANG_OTHER_VERSION ${err})
string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_OTHER_VERSION})
else()
set(MIN_VERSION ${APPLECLANG_MIN_VERSION})
set(APPLE_STR "Apple ")
# retrieve the compiler's version from it
string(REGEX MATCH "(clang-[0-9.]+)" CLANG_APPLE_VERSION ${err})
string(REGEX MATCH "[0-9.]+" CLANG_VERSION ${CLANG_APPLE_VERSION})
endif()

if(${CLANG_VERSION} VERSION_LESS "${MIN_VERSION}")
message(WARNING "\nThe compiler selected to build UHD (${APPLE_STR}Clang version ${CLANG_VERSION} : ${CMAKE_CXX_COMPILER}) is older than that officially supported (${MIN_VERSION} minimum). This build may or not work. We highly recommend using Apple Clang version ${APPLECLANG_MIN_VERSION} or more recent, or Clang version ${CLANG_MIN_VERSION} or more recent.")
endif()
Expand All @@ -94,21 +98,22 @@ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "C
set(CMAKE_CXX_FLAGS "-stdlib=libc++ ${CMAKE_CXX_FLAGS}")
endif()


########################################################################
# Packaging Variables
########################################################################

option(UNDERSCORE_UHD_VERSION "Replace dashes in uhd version with underscores" OFF)
set(LIBUHD_PKG ${LIBUHD_PKG} CACHE BOOL "Build Debian libuhd003 package")
set(LIBUHDDEV_PKG ${LIBUHDDEV_PKG} CACHE BOOL "Build Debian libuhd-dev package")
set(UHDHOST_PKG ${UHDPOST_PKG} CACHE BOOL "Build Debian uhd-host package")
include(UHDComponent) #enable components
include(UHDPackage) #setup cpack


########################################################################
# Install Dirs
########################################################################
#when the library suffix should be 64 (applies to redhat linux family)
# Whether 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()
Expand All @@ -129,6 +134,7 @@ if(NOT DEFINED PKG_DOC_DIR)
endif()
set(PKG_MAN_DIR share/man/man1)


########################################################################
# UHD config files
########################################################################
Expand All @@ -153,6 +159,7 @@ else()
message(WARNING "Not setting UHD_SYS_CONF_FILE!")
endif()


########################################################################
# UHD Image Directories
########################################################################
Expand All @@ -171,12 +178,14 @@ if(DEFINED UHD_IMAGES_DIR_WINREG_KEY)
add_definitions(-DUHD_IMAGES_DIR_WINREG_KEY=${UHD_IMAGES_DIR_WINREG_KEY})
endif(DEFINED UHD_IMAGES_DIR_WINREG_KEY)


########################################################################
# Local Include Dir
########################################################################
include_directories(${UHD_BINARY_DIR}/include)
include_directories(${UHD_SOURCE_DIR}/include)


########################################################################
# Static Lib Configuration
########################################################################
Expand All @@ -185,8 +194,9 @@ if(ENABLE_STATIC_LIBS)
message(STATUS "Building Static Libraries: ${ENABLE_STATIC_LIBS}")
endif(ENABLE_STATIC_LIBS)


########################################################################
# On Apple only, set install name and use rpath correctly, if not already set
# On Apple only, set install name and rpath correctly if not already set
########################################################################
if(APPLE)
if(NOT CMAKE_INSTALL_NAME_DIR)
Expand All @@ -202,9 +212,12 @@ if(APPLE)
if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE
BOOL "Do Build Using Library Install RPath" FORCE)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON CACHE
BOOL "Set install name to install name dir during build" FORCE)
endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
endif(APPLE)


########################################################################
# Optional Compiler Flags
########################################################################
Expand All @@ -216,14 +229,14 @@ macro(UHD_ADD_OPTIONAL_CXX_COMPILER_FLAG flag have)
endif(${have})
endmacro(UHD_ADD_OPTIONAL_CXX_COMPILER_FLAG)

#select the release build type by default to get optimization flags
# Select the release build type by default to get optimization flags
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING "")

#force UHD_RELEASE_MODE to be a string for cmake-gui
# Force UHD_RELEASE_MODE to be a string for cmake-gui
set(UHD_RELEASE_MODE "${UHD_RELEASE_MODE}" CACHE STRING "UHD Release Mode")

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR
Expand All @@ -240,21 +253,23 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR
#add_definitions(-pedantic)
#add_definitions(-ansi)
if(NOT WIN32)
#only export symbols that are declared to be part of the uhd api (non dll platforms)
# 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)
UHD_ADD_OPTIONAL_CXX_COMPILER_FLAG(-fvisibility-inlines-hidden HAVE_VISIBILITY_INLINES_HIDDEN)
endif(NOT WIN32)
if(${CMAKE_BUILD_TYPE} STREQUAL "Coverage")
include(CodeCoverage)
setup_target_for_coverage(coverage "ctest || return 0" coverage) # never fail ctest, always generate coverage report
# Never fail ctest, always generate coverage report
setup_target_for_coverage(coverage "ctest || return 0" coverage)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -pthread -g -O0 -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C++ compiler during Coverage builds." FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -pthread -g -O0 -fprofile-arcs -ftest-coverage" CACHE STRING "Flags used by the C compiler during Coverage builds." FORCE)
endif()
endif()

if(MSVC)
include_directories(${UHD_SOURCE_DIR}/cmake/msvc)
add_definitions( #stop all kinds of compatibility warnings
# Stop all kinds of compatibility warnings
add_definitions(
-DWIN32_LEAN_AND_MEAN
-DVC_EXTRALEAN
-D_SCL_SECURE_NO_WARNINGS
Expand All @@ -265,19 +280,20 @@ if(MSVC)
-D_CRT_NONSTDC_NO_DEPRECATE
-D_WINSOCK_DEPRECATED_NO_WARNINGS
)
# multi-threaded build and increases the number of addressable sections in an .obj file.
# Enable multi-threaded build and increase the number of addressable sections in an .obj file.
add_compile_options(/MP /bigobj)
endif(MSVC)

if(CYGWIN)
add_definitions(-D__USE_W32_SOCKETS) #boost asio says we need this
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
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
########################################################################
Expand All @@ -298,15 +314,17 @@ set(UHD_BOOST_REQUIRED_COMPONENTS

include(UHDBoost)

include_directories(${Boost_INCLUDE_DIRS})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
Copy link

@JohnJohn06 JohnJohn06 Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment to describe the goal of including directoy "SYSTEM". May include it in a makefile line dedicated to it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment here

link_directories(${Boost_LIBRARY_DIRS})


########################################################################
# Additional settings for build environment
########################################################################
include(UHDGlobalDefs)
include(UHDLog)


########################################################################
# Check Python Modules
########################################################################
Expand Down Expand Up @@ -352,6 +370,7 @@ PYTHON_CHECK_MODULE_VERSION(
HAVE_PYTHON_MODULE_YAML
)


########################################################################
# Option to use QEMU for running unittests
#
Expand Down Expand Up @@ -405,6 +424,7 @@ if(ENABLE_QEMU_UNITTESTS)
message(STATUS " QEMU sysroot: ${QEMU_SYSROOT}")
endif(ENABLE_QEMU_UNITTESTS)


########################################################################
# Create Uninstall Target
########################################################################
Expand All @@ -417,6 +437,7 @@ add_custom_target(uninstall
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)


########################################################################
# Install Package Docs
########################################################################
Expand All @@ -427,6 +448,7 @@ UHD_INSTALL(FILES
COMPONENT readme
)


########################################################################
# Register top level components
########################################################################
Expand All @@ -441,6 +463,7 @@ LIBUHD_REGISTER_COMPONENT("Examples" ENABLE_EXAMPLES ON "ENABLE_LIBUHD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("Utils" ENABLE_UTILS ON "ENABLE_LIBUHD" OFF OFF)
LIBUHD_REGISTER_COMPONENT("Tests" ENABLE_TESTS ON "ENABLE_LIBUHD" OFF OFF)


########################################################################
# Add the subdirectories
########################################################################
Expand Down Expand Up @@ -468,6 +491,7 @@ if(ENABLE_PYTHON_API)
add_subdirectory(python)
endif()


########################################################################
# Create Pkg Config File
########################################################################
Expand All @@ -479,12 +503,12 @@ foreach(lib ${Boost_LIBRARY_DIRS})
list(APPEND UHD_PC_LIBS "-L${lib}")
endforeach(lib)

#use space-separation format for the pc file
# Use space-separation format for the pc file
string(REPLACE ";" " " UHD_PC_REQUIRES "${UHD_PC_REQUIRES}")
string(REPLACE ";" " " UHD_PC_CFLAGS "${UHD_PC_CFLAGS}")
string(REPLACE ";" " " UHD_PC_LIBS "${UHD_PC_LIBS}")

#unset these vars to avoid hard-coded paths to cross environment
# Unset these vars to avoid hard-coded paths to cross environment
if(CMAKE_CROSSCOMPILING)
set(UHD_PC_CFLAGS)
set(UHD_PC_LIBS)
Expand Down Expand Up @@ -544,6 +568,7 @@ UHD_INSTALL(
COMPONENT "devel"
)


########################################################################
# Handle pre-built UHD Images for packaging
########################################################################
Expand All @@ -557,6 +582,7 @@ if(DEFINED UHD_IMAGES_SRC_DIR AND EXISTS "${UHD_IMAGES_SRC_DIR}")
UHD_INSTALL(FILES ${_image_files} DESTINATION ${PKG_DATA_DIR}/images COMPONENT images)
endif(DEFINED UHD_IMAGES_SRC_DIR AND EXISTS "${UHD_IMAGES_SRC_DIR}")


########################################################################
# Print Summary
########################################################################
Expand Down
2 changes: 2 additions & 0 deletions host/cmake/Modules/FindDPDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ else()
endif(PC_DPDK_FOUND)
endif()


find_package_handle_standard_args(DPDK
REQUIRED_VARS DPDK_INCLUDE_DIRS DPDK_LIBRARIES
VERSION_VAR DPDK_VERSION
HANDLE_VERSION_RANGE
)
11 changes: 2 additions & 9 deletions host/cmake/Modules/UHDConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
# Allows us to use all .cmake files in this directory
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}")

# set that this file was found, for use in GNU Radio's FindUHD.cmake.
# Set that this file was found, for use in GNU Radio's FindUHD.cmake.
# Have to use the ENV, since this file might not allow CACHE changes.

set(ENV{UHD_CONFIG_USED} TRUE)

# set default values

# Set default values
set(UHD_FOUND TRUE)
set(UHD_RFNOC_FOUND @UHD_RFNOC_FOUND@)
set(UHD_INCLUDE_HINTS)
Expand Down Expand Up @@ -69,7 +67,6 @@ endif()
# Verify that <uhd/config.hpp> and libuhd are available, and, if a
# version is provided, that UHD meets the version requirements -- no
# matter what pkg-config might think.

find_path(
UHD_INCLUDE_DIRS
NAMES uhd/config.hpp
Expand Down Expand Up @@ -103,13 +100,9 @@ if(UHD_USE_STATIC_LIBS)
endif(UHD_USE_STATIC_LIBS)

if(UHD_LIBRARIES AND UHD_INCLUDE_DIRS)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS)
mark_as_advanced(UHD_LIBRARIES UHD_INCLUDE_DIRS)

elseif(UHD_FIND_REQUIRED)

message(FATAL_ERROR "UHD is required, but was not found.")

endif()
5 changes: 5 additions & 0 deletions host/examples/rx_samples_to_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ double disk_rate_check(const size_t sample_type_size,
std::cerr << err_msg << std::endl;
}
}
#else
static_cast<void>(sample_type_size);
static_cast<void>(channel_count);
static_cast<void>(samps_per_buff);
static_cast<void>(file);
#endif
return 0;
}
Expand Down
Loading