1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 11:19:18 +00:00

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 # https://github.com/myriadrf/gr-limesdr
########################################## ##########################################
find_package(GRLIMESDR) find_package(GRLIMESDR)
set_package_properties(limesdr PROPERTIES set_package_properties(GRLIMESDR PROPERTIES
PURPOSE "Used for communication with LimeSDR." PURPOSE "Used for communication with LimeSDR."
TYPE OPTIONAL TYPE OPTIONAL
) )

View File

@ -35,7 +35,7 @@ if(NOT PKG_CONFIG_FOUND)
include(FindPkgConfig) include(FindPkgConfig)
endif() endif()
pkg_check_modules(GRLIMESDR_PKG gnuradio-limesdr) pkg_check_modules(GRLIMESDR_PKG QUIET gnuradio-limesdr)
if(NOT GRLIMESDR_ROOT) if(NOT GRLIMESDR_ROOT)
set(GRLIMESDR_ROOT_USER_DEFINED /usr) set(GRLIMESDR_ROOT_USER_DEFINED /usr)
@ -115,11 +115,11 @@ set_package_properties(GRLIMESDR PROPERTIES
if(GRLIMESDR_FOUND AND GRLIMESDR_VERSION) if(GRLIMESDR_FOUND AND GRLIMESDR_VERSION)
set_package_properties(GRLIMESDR PROPERTIES set_package_properties(GRLIMESDR PROPERTIES
DESCRIPTION "limesdr GNU Radio blocks (found: v${GRLIMESDR_VERSION})" DESCRIPTION "LimeSDR GNU Radio blocks (found: v${GRLIMESDR_VERSION})"
) )
else() else()
set_package_properties(GRLIMESDR PROPERTIES set_package_properties(GRLIMESDR PROPERTIES
DESCRIPTION "limesdr GNU Radio blocks" DESCRIPTION "LimeSDR GNU Radio blocks"
) )
endif() endif()
@ -132,16 +132,30 @@ if(GRLIMESDR_FOUND AND NOT TARGET Gnuradio::limesdr)
INTERFACE_LINK_LIBRARIES "${GRLIMESDR_LIBRARIES}" INTERFACE_LINK_LIBRARIES "${GRLIMESDR_LIBRARIES}"
) )
#check for PPS custom version message(STATUS "The (optional) gr-limesdr module has been found.")
file(READ ${GRLIMESDR_INCLUDE_DIR}/limesdr/source.h TMPTXT)
string(FIND "${TMPTXT}" "enable_PPS_mode" matchres) # check for PPS custom version
message(STATUS ${matchres}) file(READ ${GRLIMESDR_INCLUDE_DIR}/limesdr/source.h TMPTXT)
if(${matchres} EQUAL -1) string(FIND "${TMPTXT}" "enable_PPS_mode" matchres)
message("Using standard gr-limesdr library ") if(${matchres} EQUAL -1)
else() message(STATUS " Using standard gr-limesdr library.")
set(GRLIMESDR_PPS True) else()
message("Using custom gr-limesdr library with PPS support ") 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() endif()
endforeach()
if(${_g38_branch})
set(GR_LIMESDR_IS_G38_BRANCH TRUE)
endif()
endif() endif()
mark_as_advanced(GRLIMESDR_LIBRARIES GRLIMESDR_INCLUDE_DIR) mark_as_advanced(GRLIMESDR_LIBRARIES GRLIMESDR_INCLUDE_DIR)

View File

@ -269,8 +269,12 @@ if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2)
endif() endif()
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) if(GRLIMESDR_PPS)
target_compile_definitions(signal_source_adapters PUBLIC -DLimeSDR_PPS=1) target_compile_definitions(signal_source_adapters PRIVATE -DLimeSDR_PPS=1)
endif() endif()
if(ENABLE_CLANG_TIDY) if(ENABLE_CLANG_TIDY)

View File

@ -56,7 +56,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
PPS_mode_ = configuration->property(role + ".PPS_mode", false); 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 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); limechannel_mode_ = configuration->property(role + ".limechannel_mode", 0);
if (limechannel_mode_ < 0 && limechannel_mode_ > 2) if ((limechannel_mode_ < 0) || (limechannel_mode_ > 2))
{ {
std::cout std::cout
<< "ERROR: source_impl::source_impl(): ChannelMode must be A(0), B(1) or (A+B) MIMO(2)" << "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); exit(0);
} }
if (item_type_ == "short") if (item_type_ == "short")
{ {
item_size_ = sizeof(int16_t); item_size_ = sizeof(int16_t);
@ -87,7 +86,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
{ {
if (limesdr_source_->set_ext_clk(ext_clock_MHz_)) 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 else
{ {
@ -100,7 +99,7 @@ LimesdrSignalSource::LimesdrSignalSource(const ConfigurationInterface* configura
} }
#else #else
#ifdef GR_GREATER_38 #ifdef GR_LIMESDR_IS_G38_BRANCH
limesdr_source_ = gr::limesdr::source::make(limesdr_serial_, limechannel_mode_, limesdr_file_, false); limesdr_source_ = gr::limesdr::source::make(limesdr_serial_, limechannel_mode_, limesdr_file_, false);
#else #else
limesdr_source_ = gr::limesdr::source::make(limesdr_serial_, limechannel_mode_, limesdr_file_); 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_); 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_; LOG(INFO) << "LimeSDR RX antenna set to " << antenna_ << " for channel " << channel_;
// 2 set sampling rate // 2 set sampling rate
double actual_sample_rate = limesdr_source_->set_sample_rate(sample_rate_); double actual_sample_rate = limesdr_source_->set_sample_rate(sample_rate_);
std::cout << "Actual RX Rate: " << actual_sample_rate << " [SPS]...\n"; 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"; std::cout << "PLL Frequency tune error: " << actual_center_freq - freq_ << " [Hz]...\n";
LOG(INFO) << "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... // TODO: gr-limesdr does not report PLL tune frequency error...
// 4. set rx gain // 4. set rx gain