Fix detection of gr-limesdr branch

Fixes build with macOS
This commit is contained in:
Carles Fernandez 2021-12-06 20:56:28 +01:00
parent 4e1ee0f49b
commit da9d0122d7
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
4 changed files with 37 additions and 20 deletions

View File

@ -2986,7 +2986,7 @@ endif()
# https://github.com/myriadrf/gr-limesdr
##########################################
find_package(GRLIMESDR)
set_package_properties(limesdr PROPERTIES
set_package_properties(GRLIMESDR PROPERTIES
PURPOSE "Used for communication with LimeSDR."
TYPE OPTIONAL
)

View File

@ -35,7 +35,7 @@ if(NOT PKG_CONFIG_FOUND)
include(FindPkgConfig)
endif()
pkg_check_modules(GRLIMESDR_PKG gnuradio-limesdr)
pkg_check_modules(GRLIMESDR_PKG QUIET gnuradio-limesdr)
if(NOT GRLIMESDR_ROOT)
set(GRLIMESDR_ROOT_USER_DEFINED /usr)
@ -115,11 +115,11 @@ set_package_properties(GRLIMESDR PROPERTIES
if(GRLIMESDR_FOUND AND GRLIMESDR_VERSION)
set_package_properties(GRLIMESDR PROPERTIES
DESCRIPTION "limesdr GNU Radio blocks (found: v${GRLIMESDR_VERSION})"
DESCRIPTION "LimeSDR GNU Radio blocks (found: v${GRLIMESDR_VERSION})"
)
else()
set_package_properties(GRLIMESDR PROPERTIES
DESCRIPTION "limesdr GNU Radio blocks"
DESCRIPTION "LimeSDR GNU Radio blocks"
)
endif()
@ -132,16 +132,30 @@ if(GRLIMESDR_FOUND AND NOT TARGET Gnuradio::limesdr)
INTERFACE_LINK_LIBRARIES "${GRLIMESDR_LIBRARIES}"
)
#check for PPS custom version
file(READ ${GRLIMESDR_INCLUDE_DIR}/limesdr/source.h TMPTXT)
string(FIND "${TMPTXT}" "enable_PPS_mode" matchres)
message(STATUS ${matchres})
if(${matchres} EQUAL -1)
message("Using standard gr-limesdr library ")
else()
set(GRLIMESDR_PPS True)
message("Using custom gr-limesdr library with PPS support ")
message(STATUS "The (optional) gr-limesdr module has been found.")
# check for PPS custom version
file(READ ${GRLIMESDR_INCLUDE_DIR}/limesdr/source.h TMPTXT)
string(FIND "${TMPTXT}" "enable_PPS_mode" matchres)
if(${matchres} EQUAL -1)
message(STATUS " Using standard gr-limesdr library.")
else()
set(GRLIMESDR_PPS TRUE)
message(STATUS " Using custom gr-limesdr library with PPS support.")
endif()
# check gr-limesdr branch
set(_g38_branch TRUE)
file(STRINGS ${GRLIMESDR_INCLUDE_DIR}/limesdr/source.h _limesdr_header_content)
foreach(_loop_var IN LISTS _limesdr_header_content)
string(STRIP "${_loop_var}" _file_line)
if("static sptr make(std::string serial, int channel_mode, const std::string& filename);" STREQUAL "${_file_line}")
set(_g38_branch FALSE)
endif()
endforeach()
if(${_g38_branch})
set(GR_LIMESDR_IS_G38_BRANCH TRUE)
endif()
endif()
mark_as_advanced(GRLIMESDR_LIBRARIES GRLIMESDR_INCLUDE_DIR)

View File

@ -269,8 +269,12 @@ if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
endif()
endif()
if(GR_LIMESDR_IS_G38_BRANCH)
target_compile_definitions(signal_source_adapters PRIVATE -DGR_LIMESDR_IS_G38_BRANCH=1)
endif()
if(GRLIMESDR_PPS)
target_compile_definitions(signal_source_adapters PUBLIC -DLimeSDR_PPS=1)
target_compile_definitions(signal_source_adapters PRIVATE -DLimeSDR_PPS=1)
endif()
if(ENABLE_CLANG_TIDY)

View File

@ -56,7 +56,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
PPS_mode_ = configuration->property(role + ".PPS_mode", false);
ext_clock_MHz_ = configuration->property(role + ".ext_clock_MHz", 0.0); // external clock: 0.0 MHz will enable the internal clock
limechannel_mode_ = configuration->property(role + ".limechannel_mode", 0);
if (limechannel_mode_ < 0 && limechannel_mode_ > 2)
if ((limechannel_mode_ < 0) || (limechannel_mode_ > 2))
{
std::cout
<< "ERROR: source_impl::source_impl(): ChannelMode must be A(0), B(1) or (A+B) MIMO(2)"
@ -64,7 +64,6 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
exit(0);
}
if (item_type_ == "short")
{
item_size_ = sizeof(int16_t);
@ -87,7 +86,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
{
if (limesdr_source_->set_ext_clk(ext_clock_MHz_))
{
std::cout << "External clock enabled with expected frequency input of " << ext_clock_MHz_ << "\n";
std::cout << "External clock enabled with expected frequency input of " << ext_clock_MHz_ << " MHz\n";
}
else
{
@ -100,7 +99,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
}
#else
#ifdef GR_GREATER_38
#ifdef GR_LIMESDR_IS_G38_BRANCH
limesdr_source_ = gr::limesdr::source::make(limesdr_serial_, limechannel_mode_, limesdr_file_, false);
#else
limesdr_source_ = gr::limesdr::source::make(limesdr_serial_, limechannel_mode_, limesdr_file_);
@ -124,8 +123,9 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
*/
limesdr_source_->set_antenna(antenna_, channel_);
std::cout << "LimeSDR RX antenna set to " << antenna_ << " for channel " << channel_ << "\n";
std::cout << "LimeSDR RX antenna set to " << antenna_ << " for channel " << channel_ << '\n';
LOG(INFO) << "LimeSDR RX antenna set to " << antenna_ << " for channel " << channel_;
// 2 set sampling rate
double actual_sample_rate = limesdr_source_->set_sample_rate(sample_rate_);
std::cout << "Actual RX Rate: " << actual_sample_rate << " [SPS]...\n";
@ -141,7 +141,6 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
std::cout << "PLL Frequency tune error: " << actual_center_freq - freq_ << " [Hz]...\n";
LOG(INFO) << "PLL Frequency tune error: " << actual_center_freq - freq_ << " [Hz]...\n";
// TODO: gr-limesdr does not report PLL tune frequency error...
// 4. set rx gain