Skip to content

Commit

Permalink
RX can work
Browse files Browse the repository at this point in the history
  • Loading branch information
jocover committed Aug 24, 2017
1 parent e84eeb9 commit 31d9097
Show file tree
Hide file tree
Showing 6 changed files with 374 additions and 214 deletions.
18 changes: 16 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
cmake_minimum_required(VERSION 2.8.9)
project(SoapyPlutoSDR CXX)

find_package(SoapySDR "0.6.0" NO_MODULE)
find_package(SoapySDR NO_MODULE)
if (NOT SoapySDR_FOUND)
message(FATAL_ERROR "Soapy SDR development files not found...")
endif ()
Expand All @@ -23,17 +23,31 @@ endif()

include_directories(${LIBIIO_INCLUDE_DIRS})

find_package(Threads)

#enable c++11 features
if(CMAKE_COMPILER_IS_GNUCXX)

#C++11 is a required language feature for this project
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_STD_CXX11)
if(HAS_STD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
else(HAS_STD_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()

#disable warnings for unused parameters
add_definitions(-Wno-unused-parameter)

endif(CMAKE_COMPILER_IS_GNUCXX)


SOAPY_SDR_MODULE_UTIL(
TARGET PlutSDRSupport
SOURCES
PlutoSDR_Registation.cpp
PlutoSDR_Settings.cpp
PlutoSDR_Streaming.cpp
LIBRARIES ${LIBIIO_LIBRARIES}
LIBRARIES ${LIBIIO_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
)
34 changes: 34 additions & 0 deletions Findlibiio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# - Try to find libiio
# Once done this will define
#
# LIBIIO_FOUND - system has libiio
# LIBIIO_INCLUDE_DIRS - the libiio include directory
# LIBIIO_LIBRARIES - Link these to use libiio
# LIBIIO_DEFINITIONS - Compiler switches required for using libiio
#
# Redistribution and use is allowed according to the terms of the New BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#

include(FindPkgConfig)
pkg_check_modules(PC_LIBIIO QUIET libiio)
set(LIBIIO_DEFINITIONS ${PC_LIBIIO_CFLAGS_OTHER})

find_path(LIBIIO_INCLUDE_DIR iio.h
HINTS ${PC_LIBIIO_INCLUDEDIR} ${PC_LIBIIO_INCLUDE_DIRS}
PATH_SUFFIXES libiio)

find_library(LIBIIO_LIBRARY NAMES iio libiio
HINTS ${PC_LIBIIO_LIBDIR} ${PC_LIBIIO_LIBRARY_DIRS})

set(LIBIIO_VERSION ${PC_LIBIIO_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(libiio
REQUIRED_VARS LIBIIO_LIBRARY LIBIIO_INCLUDE_DIR
VERSION_VAR LIBIIO_VERSION)

mark_as_advanced(LIBIIO_INCLUDE_DIR LIBIIO_LIBRARY)

set(LIBIIO_LIBRARIES ${LIBIIO_LIBRARY})
set(LIBIIO_INCLUDE_DIRS ${LIBIIO_INCLUDE_DIR})
11 changes: 6 additions & 5 deletions PlutoSDR_Registation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ static std::vector<SoapySDR::Kwargs> find_PlutoSDR(const SoapySDR::Kwargs &args)

std::vector<SoapySDR::Kwargs> results;

unsigned int ret;
ssize_t ret=0;
iio_context *ctx;
iio_scan_context *scan_ctx;
iio_context_info **info;
SoapySDR::Kwargs options;

scan_ctx = iio_create_scan_context(NULL, 0);

//Skipping broken USB device
ret = iio_scan_context_get_info_list(scan_ctx, &info);

if(ret == 0){

ctx=iio_create_network_context(PLUTOSDR_DEFAULT_IP);
if(ctx !=NULL){
options["backend"]="network";
options["hostname"]=PLUTOSDR_DEFAULT_IP;
}else{
ctx=iio_create_network_context(PLUTOSDR_DEFAULT_HOSTNAME);
if(ctx !=NULL){
options["backend"]="network";
options["hostname"]=PLUTOSDR_DEFAULT_HOSTNAME;}
else{
return results;
Expand All @@ -34,8 +33,8 @@ static std::vector<SoapySDR::Kwargs> find_PlutoSDR(const SoapySDR::Kwargs &args)
}else if (ret == 1){

ctx = iio_create_context_from_uri(iio_context_info_get_uri(info[0]));
options["backend"]="uri";
options["uri"]=iio_context_info_get_uri(info[0]);
if (ctx != NULL)
options["uri"] = std::string(iio_context_info_get_uri(info[0]));

}else{

Expand All @@ -53,6 +52,8 @@ static std::vector<SoapySDR::Kwargs> find_PlutoSDR(const SoapySDR::Kwargs &args)

results.push_back(options);

if (ctx)iio_context_destroy(ctx);

return results;
}

Expand Down
Loading

0 comments on commit 31d9097

Please sign in to comment.