hackrf: Add cmake magic to figure out if multiple devices support is available in libhackrf, so that backwards compatibility with old libhackrf is maintained.

Signed-off-by: Heikki Hannikainen <hessu@hes.iki.fi>
soapy_support
Heikki Hannikainen 8 years ago committed by Dimitri Stolnikov
parent 254e1b1981
commit dd6690b6ca
  1. 9
      cmake/Modules/FindLibHackRF.cmake
  2. 4
      lib/hackrf/hackrf_sink_c.cc
  3. 4
      lib/hackrf/hackrf_source_c.cc

@ -22,3 +22,12 @@ FIND_LIBRARY(
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBHACKRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIRS)
MARK_AS_ADVANCED(LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIRS)
INCLUDE(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${LIBHACKRF_LIBRARIES})
CHECK_FUNCTION_EXISTS(hackrf_device_list LIBHACKRF_HAVE_DEVICE_LIST)
if(LIBHACKRF_HAVE_DEVICE_LIST)
message(STATUS "HackRF multiple device support enabled")
endif(LIBHACKRF_HAVE_DEVICE_LIST)

@ -193,9 +193,11 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args)
}
_dev = NULL;
#ifdef LIBHACKRF_HAVE_DEVICE_LIST
if ( hackrf_serial )
ret = hackrf_open_by_serial( hackrf_serial->c_str(), &_dev );
else
#endif
ret = hackrf_open( &_dev );
HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device")
@ -484,7 +486,7 @@ std::vector<std::string> hackrf_sink_c::get_devices()
_usage++;
}
#if 1
#ifdef LIBHACKRF_HAVE_DEVICE_LIST
hackrf_device_list_t *list = hackrf_device_list();
for (unsigned int i = 0; i < list->devicecount; i++) {

@ -144,6 +144,7 @@ hackrf_source_c::hackrf_source_c (const std::string &args)
_dev = NULL;
#ifdef LIBHACKRF_HAVE_DEVICE_LIST
if (dict.count("hackrf") && dict["hackrf"].length() > 0) {
hackrf_serial = dict["hackrf"];
@ -169,6 +170,7 @@ hackrf_source_c::hackrf_source_c (const std::string &args)
hackrf_device_list_free(list);
}
} else
#endif
ret = hackrf_open( &_dev );
HACKRF_THROW_ON_ERROR(ret, "Failed to open HackRF device")
@ -399,7 +401,7 @@ std::vector<std::string> hackrf_source_c::get_devices()
_usage++;
}
#if 1
#if LIBHACKRF_HAVE_DEVICE_LIST
hackrf_device_list_t *list = hackrf_device_list();
for (unsigned int i = 0; i < list->devicecount; i++) {

Loading…
Cancel
Save