├── .gitignore ├── CMakeLists.txt ├── COPYING ├── MANIFEST.md ├── README.md ├── azure-pipelines.yml ├── ci └── travis │ ├── before_install_darwin │ ├── before_install_lib.sh │ ├── before_install_linux │ ├── lib.sh │ └── make_linux ├── cmake ├── Modules │ ├── CMakeParseArgumentsCopy.cmake │ ├── FindCppUnit.cmake │ ├── FindGnuradioRuntime.cmake │ ├── GrMiscUtils.cmake │ ├── GrPlatform.cmake │ ├── GrPython.cmake │ ├── GrSwig.cmake │ ├── GrTest.cmake │ ├── UseSWIG.cmake │ └── iioConfig.cmake └── cmake_uninstall.cmake.in ├── gnuradio-iio.pc.in ├── grc ├── CMakeLists.txt ├── iio_attr_sink.xml ├── iio_attr_source.xml ├── iio_attr_updater.xml ├── iio_device_sink.xml ├── iio_device_source.xml ├── iio_fmcomms2_sink.xml ├── iio_fmcomms2_source.xml ├── iio_fmcomms5_sink.xml ├── iio_fmcomms5_source.xml ├── iio_math.xml ├── iio_math_gen.xml ├── iio_modulo_const_ff.xml ├── iio_modulo_ff.xml ├── iio_pluto_sink.xml ├── iio_pluto_source.xml └── iio_power_ff.xml ├── iio-examples ├── attr-sink.grc ├── attr-source.grc ├── cyclic-sine.grc ├── cyclic-sine_pluto.grc ├── fm-transmitter.grc ├── fm-transmitter_pluto.grc ├── fmradio.grc ├── fmradio_pluto.grc └── packrf.grc ├── include └── gnuradio │ └── iio │ ├── CMakeLists.txt │ ├── api.h │ ├── attr_sink.h │ ├── attr_source.h │ ├── converter_ss.h │ ├── device_sink.h │ ├── device_source.h │ ├── fmcomms2_sink.h │ ├── fmcomms2_source.h │ ├── fmcomms5_sink.h │ ├── fmcomms5_source.h │ ├── math.h │ ├── modulo_const_ff.h │ ├── modulo_ff.h │ ├── pluto_sink.h │ ├── pluto_source.h │ └── power_ff.h ├── lib ├── CMakeLists.txt ├── attr_sink_impl.cc ├── attr_sink_impl.h ├── attr_source_impl.cc ├── attr_source_impl.h ├── converter_ss_impl.cc ├── converter_ss_impl.h ├── device_sink_impl.cc ├── device_sink_impl.h ├── device_source_impl.cc ├── device_source_impl.h ├── fmcomms2_sink_impl.cc ├── fmcomms2_sink_impl.h ├── fmcomms2_source_impl.cc ├── fmcomms2_source_impl.h ├── fmcomms5_sink_impl.cc ├── fmcomms5_sink_impl.h ├── fmcomms5_source_impl.cc ├── fmcomms5_source_impl.h ├── iio_math_gen_impl.cc ├── iio_math_impl.cc ├── iio_math_impl.h ├── iio_math_lexer.l ├── iio_math_parser.y ├── iio_modulo_const_ff_impl.cc ├── iio_modulo_const_ff_impl.h ├── iio_modulo_ff_impl.cc ├── iio_modulo_ff_impl.h ├── iio_power_ff_impl.cc ├── iio_power_ff_impl.h ├── pluto_sink_impl.cc ├── pluto_sink_impl.h ├── pluto_source_impl.cc └── pluto_source_impl.h ├── python └── iio │ ├── CMakeLists.txt │ ├── __init__.py │ └── attr_updater.py └── swig ├── CMakeLists.txt ├── iio_pluto_sink_swig.i ├── iio_pluto_source_swig.i └── iio_swig.i /.gitignore: -------------------------------------------------------------------------------- 1 | # Directory generated by "dpkg-buildpackage" 2 | obj-*-linux-gnu 3 | *.swp 4 | build/ 5 | -------------------------------------------------------------------------------- /MANIFEST.md: -------------------------------------------------------------------------------- 1 | title: gr-iio 2 | brief: Analog Devices' IIO blocks for GNU Radio 3 | tags: 4 | - IIO 5 | - FMCOMMS 6 | - Pluto 7 | author: 8 | - Travis Collins 9 | - Paul Cercueil 10 | - Lars-Peter Clausen 11 | copyright_owner: 12 | - Analog Devices Inc. 13 | dependencies: 14 | - gnuradio 15 | repo: https://github.com/analogdevicesinc/gr-iio.git 16 | stable_release: HEAD 17 | icon: 18 | --- 19 | 20 | The Industrial Input/Output (IIO) framework has been in the upstream Linux kernels since 2011 and is responsible for handling sensors, converters, integrated transceivers and other real-world I/O devices. It provides a hardware abstraction layer with a consistent API for the user space applications. The IIO framework supports discrete components as well as integrated transceivers like the Analog Devices AD9361, a 2x2 RF Agile Transceiver, found in many SDR products. 21 | 22 | gr-iio contains several new blocks for GNU Radio that can be used to stream samples from and to high-speed IIO devices. These new GNU Radio blocks are built around ADI’s libiio library, which concentrates most of the complexity, supports all IIO devices and has built-in support for data streaming over the network. This data streaming feature has several benefits: it allows the GNURadio flowgraphs to run on operating systems other than Linux (including Windows), and on more capable computers than the development board where the IIO devices are attached, which is usually not suitable for high-performance and real-time data processing. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gr-iio 2 | 3 | IIO blocks for GNU Radio 4 | 5 | ## Documentaion 6 | [GNU Radio IIO Blocks](https://wiki.analog.com/resources/tools-software/linux-software/gnuradio) 7 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | ########################################################### 3 | # Builds 4 | ########################################################### 5 | - job: LinuxBuilds 6 | # Host Box 7 | pool: 8 | vmImage: 'ubuntu-20.04' 9 | # Docker Images 10 | strategy: 11 | matrix: 12 | ubuntu18: 13 | image: tfcollins/test-ubuntu:20.04 14 | container: $[ variables['image'] ] 15 | steps: 16 | - script: | 17 | sudo DEBIAN_FRONTEND=noninteractive apt-get -qq update 18 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y git cmake doxygen graphviz libaio-dev libusb-1.0-0-dev libserialport-dev libavahi-client-dev rpm tar bzip2 gzip 19 | displayName: "Setup Ubuntu" 20 | condition: contains(variables['image'], 'ubuntu') 21 | 22 | - script: | 23 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libxml2 libxml2-dev bison flex libboost-all-dev 24 | git clone https://github.com/analogdevicesinc/libiio.git 25 | cd libiio 26 | mkdir build && cd build 27 | cmake .. 28 | make 29 | sudo make install 30 | sudo ldconfig 31 | cd ../.. 32 | rm -rf libiio 33 | displayName: Install libiio-iio 34 | 35 | - script: | 36 | git clone https://github.com/analogdevicesinc/libad9361-iio.git 37 | cd libad9361-iio 38 | mkdir build && cd build 39 | cmake .. 40 | make 41 | sudo make install 42 | sudo ldconfig 43 | cd ../.. 44 | rm -rf libad9361-iio 45 | displayName: Install libad9361-iio 46 | 47 | - script: | 48 | sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libgmp-dev swig gnuradio gnuradio-dev 49 | mkdir build && cd build 50 | cmake .. 51 | make 52 | cd .. 53 | displayName: Build 54 | 55 | ########################################################### 56 | # Deploy 57 | ########################################################### 58 | -------------------------------------------------------------------------------- /ci/travis/before_install_darwin: -------------------------------------------------------------------------------- 1 | #!/bin/sh -xe 2 | 3 | . ci/travis/lib.sh 4 | . ci/travis/before_install_lib.sh 5 | 6 | brew_install_or_upgrade cmake boost bison libusb libxml2 python@2 brew-pip \ 7 | fftw flex 8 | 9 | for pkg in gcc bison gettext ; do 10 | brew link --overwrite --force $pkg 11 | done 12 | 13 | if [ "$TRAVIS" == "true" ] ; then 14 | # FIXME: remove & pip these when not building gnuradio 15 | sudo pip install -U six mako 16 | for pkg in libiio libad9361-iio ; do 17 | wget http://swdownloads.analog.com/cse/travis_builds/master_latest_${pkg}${LDIST}.pkg 18 | sudo installer -pkg master_latest_${pkg}${LDIST}.pkg -target / 19 | done 20 | fi 21 | 22 | __handle_common 23 | 24 | -------------------------------------------------------------------------------- /ci/travis/before_install_lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | NUM_JOBS=3 5 | 6 | __cmake() { 7 | local args="$1" 8 | mkdir -p build 9 | cd build # build 10 | 11 | if [ "$TRAVIS" = "true" ] || [ "$INSIDE_DOCKER" = "1" ] ; then 12 | cmake $args .. 13 | make -j${NUM_JOBS} 14 | sudo make install 15 | else 16 | cmake -DCMAKE_PREFIX_PATH="$STAGINGDIR" -DCMAKE_INSTALL_PREFIX="$STAGINGDIR" \ 17 | -DCMAKE_EXE_LINKER_FLAGS="-L${STAGINGDIR}/lib" \ 18 | $args .. $SILENCED 19 | CFLAGS=-I${STAGINGDIR}/include LDFLAGS=-L${STAGINGDIR}/lib make -j${NUM_JOBS} $SILENCED 20 | make install 21 | fi 22 | 23 | cd .. 24 | } 25 | 26 | __make() { 27 | $preconfigure 28 | if [ "$TRAVIS" = "true" ] || [ "$INSIDE_DOCKER" = "1" ] ; then 29 | $configure 30 | $make -j${NUM_JOBS} 31 | sudo $make install 32 | else 33 | $configure --prefix="$STAGINGDIR" $SILENCED 34 | CFLAGS=-I${STAGINGDIR}/include LDFLAGS=-L${STAGINGDIR}/lib $make -j${NUM_JOBS} $SILENCED 35 | $SUDO $make install 36 | fi 37 | } 38 | 39 | __build_common() { 40 | local dir="$1" 41 | local buildfunc="$2" 42 | local getfunc="$3" 43 | local subdir="$4" 44 | local args="$5" 45 | 46 | cd "$WORKDIR" # deps dir 47 | 48 | # if we have this folder, we may not need to download it 49 | [ -d "$dir" ] || $getfunc 50 | 51 | cd "$dir" # this dep dir 52 | [ -z "$subdir" ] || cd "$subdir" # in case there is a build subdir or smth 53 | 54 | $buildfunc "$args" 55 | 56 | cd .. 57 | cd .. 58 | [ -z "$subdir" ] || cd .. 59 | } 60 | 61 | wget_and_untar() { 62 | [ -d "$WORKDIR/$dir" ] || { 63 | local tar_file="${dir}.tar.gz" 64 | wget --no-check-certificate "$url" -O "$tar_file" 65 | tar -xvf "$tar_file" > /dev/null 66 | [ -z "$patchfunc" ] || { 67 | cd $dir 68 | $patchfunc 69 | cd .. 70 | } 71 | } 72 | } 73 | 74 | git_clone_update() { 75 | [ -d "$WORKDIR/$dir" ] || { 76 | [ -z "$branch" ] || branch="-b $branch" 77 | git clone --recursive $branch "$url" "$dir" 78 | [ -z "$patchfunc" ] || { 79 | cd $dir 80 | $patchfunc 81 | cd .. 82 | } 83 | } 84 | } 85 | 86 | cmake_build_wget() { 87 | local dir="$1" 88 | local url="$2" 89 | 90 | __build_common "$dir" "__cmake" "wget_and_untar" 91 | } 92 | 93 | cmake_build_git() { 94 | local dir="$1" 95 | local url="$2" 96 | local branch="$3" 97 | local args="$4" 98 | 99 | __build_common "$dir" "__cmake" "git_clone_update" "" "$args" 100 | } 101 | 102 | make_build_wget() { 103 | local dir="$1" 104 | local url="$2" 105 | local configure="${3:-./configure}" 106 | local make="${4:-make}" 107 | 108 | __build_common "$dir" "__make" "wget_and_untar" 109 | } 110 | 111 | make_build_git() { 112 | local dir="$1" 113 | local url="$2" 114 | local configure="${3:-./configure}" 115 | local make="${4:-make}" 116 | local preconfigure="$5" 117 | 118 | __build_common "$dir" "__make" "git_clone_update" 119 | } 120 | 121 | 122 | __handle_common() { 123 | # -DENABLE_INTERNAL_VOLK:BOOL=OFF 124 | # FIXME: see about keeping a deb/rpm somewhere cached for this 125 | cmake_build_git "gnuradio" \ 126 | "https://github.com/analogdevicesinc/gnuradio" \ 127 | "signal_source_phase_rebased" \ 128 | "-DENABLE_INTERNAL_VOLK:BOOL=ON -DENABLE_GR_FEC:BOOL=OFF -DENABLE_GR_DIGITAL:BOOL=OFF -DENABLE_GR_DTV:BOOL=OFF -DENABLE_GR_ATSC:BOOL=OFF -DENABLE_GR_AUDIO:BOOL=OFF -DENABLE_GR_CHANNELS:BOOL=OFF -DENABLE_GR_NOAA:BOOL=OFF -DENABLE_GR_PAGER:BOOL=OFF -DENABLE_GR_TRELLIS:BOOL=OFF -DENABLE_GR_VOCODER:BOOL=OFF" 129 | } 130 | 131 | -------------------------------------------------------------------------------- /ci/travis/before_install_linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | . ci/travis/lib.sh 4 | . ci/travis/before_install_lib.sh 5 | 6 | BOOST_PACKAGES_BASE="libboost libboost-regex libboost-date-time 7 | libboost-program-options libboost-test libboost-filesystem 8 | libboost-system libboost-thread" 9 | 10 | handle_centos() { 11 | # First EPEL stuff 12 | yum install -y epel-release 13 | 14 | yum -y groupinstall 'Development Tools' 15 | # FIXME: remove python-mako & python-six when not building gnuradio 16 | yum -y install cmake boost-devel python-devel fftw-devel bison flex yum \ 17 | python-mako python-six \ 18 | swig git libusb1-devel doxygen libaio-devel avahi-devel bzip2 gzip \ 19 | rpm rpm-build libxml2-devel 20 | 21 | __handle_common 22 | 23 | if [ "$TRAVIS" = "true" ] || [ "$INSIDE_DOCKER" = "1" ] ; then 24 | for pkg in libiio libad9361-iio ; do 25 | wget http://swdownloads.analog.com/cse/travis_builds/${LIBIIO_BRANCH}_latest_${pkg}${LDIST}.rpm 26 | sudo yum localinstall -y ./${LIBIIO_BRANCH}_latest_${pkg}${LDIST}.rpm 27 | done 28 | fi 29 | } 30 | 31 | handle_centos_docker() { 32 | prepare_docker_image "centos:centos${OS_VERSION}" 33 | } 34 | 35 | handle_ubuntu_docker() { 36 | prepare_docker_image "ubuntu:${OS_VERSION}" 37 | } 38 | 39 | handle_default() { 40 | local BOOST_PACKAGES 41 | 42 | for package in $BOOST_PACKAGES_BASE ; do 43 | BOOST_PACKAGES="$BOOST_PACKAGES ${package}${BOOST_VER}-dev" 44 | done 45 | 46 | sudo apt-get -qq update 47 | # FIXME: remove python-mako & python-six when not building gnuradio 48 | sudo apt-get install -y build-essential libboost-dev libpython-dev bison \ 49 | flex git libfftw3-dev swig cmake libaio-dev libavahi-client-dev libavahi-common-dev \ 50 | libusb-1.0-0-dev libxml2-dev tar bzip2 gzip \ 51 | python-mako python-six \ 52 | $BOOST_PACKAGES 53 | 54 | if apt-cache show libserialport-dev &> /dev/null ; then 55 | sudo apt-get install -y libserialport-dev 56 | fi 57 | 58 | __handle_common 59 | 60 | if [ "$TRAVIS" = "true" ] || [ "$INSIDE_DOCKER" = "1" ] ; then 61 | for pkg in libiio libad9361-iio ; do 62 | wget http://swdownloads.analog.com/cse/travis_builds/${LIBIIO_BRANCH}_latest_${pkg}${LDIST}.deb 63 | sudo dpkg -i ./${LIBIIO_BRANCH}_latest_${pkg}${LDIST}.deb 64 | done 65 | fi 66 | } 67 | 68 | LIBNAME="gr-iio" 69 | OS_TYPE=${1:-default} 70 | OS_VERSION="$2" 71 | 72 | handle_${OS_TYPE} 73 | -------------------------------------------------------------------------------- /ci/travis/lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | TRAVIS_BUILD_DIR=${TRAVIS_BUILD_DIR:-'./'} 4 | 5 | LIBIIO_BRANCH=master 6 | 7 | command_exists() { 8 | local cmd=$1 9 | [ -n "$cmd" ] || return 1 10 | type "$cmd" >/dev/null 2>&1 11 | } 12 | 13 | ensure_command_exists() { 14 | local cmd="$1" 15 | local package="$2" 16 | [ -n "$cmd" ] || return 1 17 | [ -n "$package" ] || package="$cmd" 18 | ! command_exists "$cmd" || return 0 19 | # go through known package managers 20 | for pacman in apt-get brew yum ; do 21 | command_exists $pacman || continue 22 | $pacman install -y $package || { 23 | # Try an update if install doesn't work the first time 24 | $pacman -y update && \ 25 | $pacman install -y $package 26 | } 27 | return $? 28 | done 29 | return 1 30 | } 31 | 32 | ensure_command_exists wget 33 | ensure_command_exists sudo 34 | 35 | # Get the common stuff from libiio 36 | [ -f ${TRAVIS_BUILD_DIR}/build/lib.sh ] || { 37 | mkdir -p ${TRAVIS_BUILD_DIR}/build 38 | wget https://raw.githubusercontent.com/analogdevicesinc/libiio/master/CI/travis/lib.sh \ 39 | -O ${TRAVIS_BUILD_DIR}/build/lib.sh 40 | } 41 | 42 | # For OS X builds 43 | export PATH="/usr/local/opt/bison/bin:$PATH" 44 | 45 | . ${TRAVIS_BUILD_DIR}/build/lib.sh 46 | 47 | if [ -z "${LDIST}" -a -f "build/.LDIST" ] ; then 48 | export LDIST="-$(cat build/.LDIST)" 49 | fi 50 | if [ -z "${LDIST}" ] || [ "$LDIST" = "DO_NOT_DEPLOY" ] ; then 51 | export LDIST="-$(get_ldist)" 52 | fi 53 | -------------------------------------------------------------------------------- /ci/travis/make_linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | . ci/travis/lib.sh 4 | 5 | handle_default() { 6 | mkdir -p build 7 | cd build 8 | cmake .. 9 | make 10 | cd .. 11 | } 12 | 13 | handle_centos() { 14 | handle_default 15 | } 16 | 17 | handle_centos_docker() { 18 | run_docker_script inside_docker.sh \ 19 | "centos:centos${OS_VERSION}" "centos" 20 | } 21 | 22 | handle_ubuntu_docker() { 23 | run_docker_script inside_docker.sh \ 24 | "ubuntu:${OS_VERSION}" 25 | } 26 | 27 | LIBNAME="gr-iio" 28 | OS_TYPE=${1:-default} 29 | OS_VERSION="$2" 30 | 31 | handle_${OS_TYPE} 32 | -------------------------------------------------------------------------------- /cmake/Modules/CMakeParseArgumentsCopy.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE_PARSE_ARGUMENTS( args...) 2 | # 3 | # CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for 4 | # parsing the arguments given to that macro or function. 5 | # It processes the arguments and defines a set of variables which hold the 6 | # values of the respective options. 7 | # 8 | # The argument contains all options for the respective macro, 9 | # i.e. keywords which can be used when calling the macro without any value 10 | # following, like e.g. the OPTIONAL keyword of the install() command. 11 | # 12 | # The argument contains all keywords for this macro 13 | # which are followed by one value, like e.g. DESTINATION keyword of the 14 | # install() command. 15 | # 16 | # The argument contains all keywords for this macro 17 | # which can be followed by more than one value, like e.g. the TARGETS or 18 | # FILES keywords of the install() command. 19 | # 20 | # When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the 21 | # keywords listed in , and 22 | # a variable composed of the given 23 | # followed by "_" and the name of the respective keyword. 24 | # These variables will then hold the respective value from the argument list. 25 | # For the keywords this will be TRUE or FALSE. 26 | # 27 | # All remaining arguments are collected in a variable 28 | # _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether 29 | # your macro was called with unrecognized parameters. 30 | # 31 | # As an example here a my_install() macro, which takes similar arguments as the 32 | # real install() command: 33 | # 34 | # function(MY_INSTALL) 35 | # set(options OPTIONAL FAST) 36 | # set(oneValueArgs DESTINATION RENAME) 37 | # set(multiValueArgs TARGETS CONFIGURATIONS) 38 | # cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) 39 | # ... 40 | # 41 | # Assume my_install() has been called like this: 42 | # my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) 43 | # 44 | # After the cmake_parse_arguments() call the macro will have set the following 45 | # variables: 46 | # MY_INSTALL_OPTIONAL = TRUE 47 | # MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() 48 | # MY_INSTALL_DESTINATION = "bin" 49 | # MY_INSTALL_RENAME = "" (was not used) 50 | # MY_INSTALL_TARGETS = "foo;bar" 51 | # MY_INSTALL_CONFIGURATIONS = "" (was not used) 52 | # MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" 53 | # 54 | # You can the continue and process these variables. 55 | # 56 | # Keywords terminate lists of values, e.g. if directly after a one_value_keyword 57 | # another recognized keyword follows, this is interpreted as the beginning of 58 | # the new option. 59 | # E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in 60 | # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would 61 | # be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. 62 | 63 | #============================================================================= 64 | # Copyright 2010 Alexander Neundorf 65 | # 66 | # Distributed under the OSI-approved BSD License (the "License"); 67 | # see accompanying file Copyright.txt for details. 68 | # 69 | # This software is distributed WITHOUT ANY WARRANTY; without even the 70 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 71 | # See the License for more information. 72 | #============================================================================= 73 | # (To distribute this file outside of CMake, substitute the full 74 | # License text for the above reference.) 75 | 76 | 77 | if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) 78 | return() 79 | endif() 80 | set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) 81 | 82 | 83 | function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) 84 | # first set all result variables to empty/FALSE 85 | foreach(arg_name ${_singleArgNames} ${_multiArgNames}) 86 | set(${prefix}_${arg_name}) 87 | endforeach(arg_name) 88 | 89 | foreach(option ${_optionNames}) 90 | set(${prefix}_${option} FALSE) 91 | endforeach(option) 92 | 93 | set(${prefix}_UNPARSED_ARGUMENTS) 94 | 95 | set(insideValues FALSE) 96 | set(currentArgName) 97 | 98 | # now iterate over all arguments and fill the result variables 99 | foreach(currentArg ${ARGN}) 100 | list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword 101 | list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword 102 | list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword 103 | 104 | if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) 105 | if(insideValues) 106 | if("${insideValues}" STREQUAL "SINGLE") 107 | set(${prefix}_${currentArgName} ${currentArg}) 108 | set(insideValues FALSE) 109 | elseif("${insideValues}" STREQUAL "MULTI") 110 | list(APPEND ${prefix}_${currentArgName} ${currentArg}) 111 | endif() 112 | else(insideValues) 113 | list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) 114 | endif(insideValues) 115 | else() 116 | if(NOT ${optionIndex} EQUAL -1) 117 | set(${prefix}_${currentArg} TRUE) 118 | set(insideValues FALSE) 119 | elseif(NOT ${singleArgIndex} EQUAL -1) 120 | set(currentArgName ${currentArg}) 121 | set(${prefix}_${currentArgName}) 122 | set(insideValues "SINGLE") 123 | elseif(NOT ${multiArgIndex} EQUAL -1) 124 | set(currentArgName ${currentArg}) 125 | set(${prefix}_${currentArgName}) 126 | set(insideValues "MULTI") 127 | endif() 128 | endif() 129 | 130 | endforeach(currentArg) 131 | 132 | # propagate the result variables to the caller: 133 | foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) 134 | set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) 135 | endforeach(arg_name) 136 | set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) 137 | 138 | endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) 139 | -------------------------------------------------------------------------------- /cmake/Modules/FindCppUnit.cmake: -------------------------------------------------------------------------------- 1 | # http://www.cmake.org/pipermail/cmake/2006-October/011446.html 2 | # Modified to use pkg config and use standard var names 3 | 4 | # 5 | # Find the CppUnit includes and library 6 | # 7 | # This module defines 8 | # CPPUNIT_INCLUDE_DIR, where to find tiff.h, etc. 9 | # CPPUNIT_LIBRARIES, the libraries to link against to use CppUnit. 10 | # CPPUNIT_FOUND, If false, do not try to use CppUnit. 11 | 12 | INCLUDE(FindPkgConfig) 13 | PKG_CHECK_MODULES(PC_CPPUNIT "cppunit") 14 | 15 | FIND_PATH(CPPUNIT_INCLUDE_DIRS 16 | NAMES cppunit/TestCase.h 17 | HINTS ${PC_CPPUNIT_INCLUDE_DIR} 18 | PATHS 19 | /usr/local/include 20 | /usr/include 21 | ) 22 | 23 | FIND_LIBRARY(CPPUNIT_LIBRARIES 24 | NAMES cppunit 25 | HINTS ${PC_CPPUNIT_LIBDIR} 26 | PATHS 27 | ${CPPUNIT_INCLUDE_DIRS}/../lib 28 | /usr/local/lib 29 | /usr/lib 30 | ) 31 | 32 | LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) 33 | 34 | INCLUDE(FindPackageHandleStandardArgs) 35 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 36 | MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 37 | -------------------------------------------------------------------------------- /cmake/Modules/FindGnuradioRuntime.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_GNURADIO_RUNTIME gnuradio-runtime) 3 | 4 | if(PC_GNURADIO_RUNTIME_FOUND) 5 | # look for include files 6 | FIND_PATH( 7 | GNURADIO_RUNTIME_INCLUDE_DIRS 8 | NAMES gnuradio/top_block.h 9 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/include 10 | ${PC_GNURADIO_RUNTIME_INCLUDE_DIRS} 11 | ${CMAKE_INSTALL_PREFIX}/include 12 | PATHS /usr/local/include 13 | /usr/include 14 | ) 15 | 16 | # look for libs 17 | FIND_LIBRARY( 18 | GNURADIO_RUNTIME_LIBRARIES 19 | NAMES gnuradio-runtime 20 | HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib 21 | ${PC_GNURADIO_RUNTIME_LIBDIR} 22 | ${CMAKE_INSTALL_PREFIX}/lib/ 23 | ${CMAKE_INSTALL_PREFIX}/lib64/ 24 | PATHS /usr/local/lib 25 | /usr/local/lib64 26 | /usr/lib 27 | /usr/lib64 28 | ) 29 | 30 | set(GNURADIO_RUNTIME_FOUND ${PC_GNURADIO_RUNTIME_FOUND}) 31 | endif(PC_GNURADIO_RUNTIME_FOUND) 32 | 33 | INCLUDE(FindPackageHandleStandardArgs) 34 | # do not check GNURADIO_RUNTIME_INCLUDE_DIRS, is not set when default include path us used. 35 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_RUNTIME DEFAULT_MSG GNURADIO_RUNTIME_LIBRARIES) 36 | MARK_AS_ADVANCED(GNURADIO_RUNTIME_LIBRARIES GNURADIO_RUNTIME_INCLUDE_DIRS) 37 | -------------------------------------------------------------------------------- /cmake/Modules/GrPlatform.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_PLATFORM_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_PLATFORM_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Setup additional defines for OS types 27 | ######################################################################## 28 | if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 29 | set(LINUX TRUE) 30 | endif() 31 | 32 | if(LINUX AND EXISTS "/etc/debian_version") 33 | set(DEBIAN TRUE) 34 | endif() 35 | 36 | if(LINUX AND EXISTS "/etc/redhat-release") 37 | set(REDHAT TRUE) 38 | endif() 39 | 40 | ######################################################################## 41 | # when the library suffix should be 64 (applies to redhat linux family) 42 | ######################################################################## 43 | if(NOT DEFINED LIB_SUFFIX AND REDHAT AND CMAKE_SYSTEM_PROCESSOR MATCHES "64$") 44 | set(LIB_SUFFIX 64) 45 | endif() 46 | set(LIB_SUFFIX ${LIB_SUFFIX} CACHE STRING "lib directory suffix") 47 | -------------------------------------------------------------------------------- /cmake/Modules/GrTest.cmake: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | if(DEFINED __INCLUDED_GR_TEST_CMAKE) 21 | return() 22 | endif() 23 | set(__INCLUDED_GR_TEST_CMAKE TRUE) 24 | 25 | ######################################################################## 26 | # Add a unit test and setup the environment for a unit test. 27 | # Takes the same arguments as the ADD_TEST function. 28 | # 29 | # Before calling set the following variables: 30 | # GR_TEST_TARGET_DEPS - built targets for the library path 31 | # GR_TEST_LIBRARY_DIRS - directories for the library path 32 | # GR_TEST_PYTHON_DIRS - directories for the python path 33 | ######################################################################## 34 | function(GR_ADD_TEST test_name) 35 | 36 | if(WIN32) 37 | #Ensure that the build exe also appears in the PATH. 38 | list(APPEND GR_TEST_TARGET_DEPS ${ARGN}) 39 | 40 | #In the land of windows, all libraries must be in the PATH. 41 | #Since the dependent libraries are not yet installed, 42 | #we must manually set them in the PATH to run tests. 43 | #The following appends the path of a target dependency. 44 | foreach(target ${GR_TEST_TARGET_DEPS}) 45 | get_target_property(location ${target} LOCATION) 46 | if(location) 47 | get_filename_component(path ${location} PATH) 48 | string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) 49 | list(APPEND GR_TEST_LIBRARY_DIRS ${path}) 50 | endif(location) 51 | endforeach(target) 52 | 53 | #SWIG generates the python library files into a subdirectory. 54 | #Therefore, we must append this subdirectory into PYTHONPATH. 55 | #Only do this for the python directories matching the following: 56 | foreach(pydir ${GR_TEST_PYTHON_DIRS}) 57 | get_filename_component(name ${pydir} NAME) 58 | if(name MATCHES "^(swig|lib|src)$") 59 | list(APPEND GR_TEST_PYTHON_DIRS ${pydir}/${CMAKE_BUILD_TYPE}) 60 | endif() 61 | endforeach(pydir) 62 | endif(WIN32) 63 | 64 | file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) 65 | file(TO_NATIVE_PATH "${GR_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? 66 | file(TO_NATIVE_PATH "${GR_TEST_PYTHON_DIRS}" pypath) #ok to use on dir list? 67 | 68 | set(environs "GR_DONT_LOAD_PREFS=1" "srcdir=${srcdir}") 69 | 70 | #http://www.cmake.org/pipermail/cmake/2009-May/029464.html 71 | #Replaced this add test + set environs code with the shell script generation. 72 | #Its nicer to be able to manually run the shell script to diagnose problems. 73 | #ADD_TEST(${ARGV}) 74 | #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") 75 | 76 | if(UNIX) 77 | set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") 78 | #set both LD and DYLD paths to cover multiple UNIX OS library paths 79 | list(APPEND libpath "$LD_LIBRARY_PATH" "$DYLD_LIBRARY_PATH") 80 | list(APPEND pypath "$PYTHONPATH") 81 | 82 | #replace list separator with the path separator 83 | string(REPLACE ";" ":" libpath "${libpath}") 84 | string(REPLACE ";" ":" pypath "${pypath}") 85 | list(APPEND environs "PATH=${binpath}" "LD_LIBRARY_PATH=${libpath}" "DYLD_LIBRARY_PATH=${libpath}" "PYTHONPATH=${pypath}") 86 | 87 | #generate a bat file that sets the environment and runs the test 88 | find_program(SHELL sh) 89 | set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) 90 | file(WRITE ${sh_file} "#!${SHELL}\n") 91 | #each line sets an environment variable 92 | foreach(environ ${environs}) 93 | file(APPEND ${sh_file} "export ${environ}\n") 94 | endforeach(environ) 95 | #load the command to run with its arguments 96 | foreach(arg ${ARGN}) 97 | file(APPEND ${sh_file} "${arg} ") 98 | endforeach(arg) 99 | file(APPEND ${sh_file} "\n") 100 | 101 | #make the shell file executable 102 | execute_process(COMMAND chmod +x ${sh_file}) 103 | 104 | add_test(${test_name} ${SHELL} ${sh_file}) 105 | 106 | endif(UNIX) 107 | 108 | if(WIN32) 109 | list(APPEND libpath ${DLL_PATHS} "%PATH%") 110 | list(APPEND pypath "%PYTHONPATH%") 111 | 112 | #replace list separator with the path separator (escaped) 113 | string(REPLACE ";" "\\;" libpath "${libpath}") 114 | string(REPLACE ";" "\\;" pypath "${pypath}") 115 | list(APPEND environs "PATH=${libpath}" "PYTHONPATH=${pypath}") 116 | 117 | #generate a bat file that sets the environment and runs the test 118 | set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) 119 | file(WRITE ${bat_file} "@echo off\n") 120 | #each line sets an environment variable 121 | foreach(environ ${environs}) 122 | file(APPEND ${bat_file} "SET ${environ}\n") 123 | endforeach(environ) 124 | #load the command to run with its arguments 125 | foreach(arg ${ARGN}) 126 | file(APPEND ${bat_file} "${arg} ") 127 | endforeach(arg) 128 | file(APPEND ${bat_file} "\n") 129 | 130 | add_test(${test_name} ${bat_file}) 131 | endif(WIN32) 132 | 133 | endfunction(GR_ADD_TEST) 134 | -------------------------------------------------------------------------------- /cmake/Modules/iioConfig.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_IIO iio) 3 | 4 | FIND_PATH( 5 | IIO_INCLUDE_DIRS 6 | NAMES iio/api.h 7 | HINTS $ENV{IIO_DIR}/include 8 | ${PC_IIO_INCLUDEDIR} 9 | PATHS ${CMAKE_INSTALL_PREFIX}/include 10 | /usr/local/include 11 | /usr/include 12 | ) 13 | 14 | FIND_LIBRARY( 15 | IIO_LIBRARIES 16 | NAMES gnuradio-iio 17 | HINTS $ENV{IIO_DIR}/lib 18 | ${PC_IIO_LIBDIR} 19 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 20 | ${CMAKE_INSTALL_PREFIX}/lib64 21 | /usr/local/lib 22 | /usr/local/lib64 23 | /usr/lib 24 | /usr/lib64 25 | ) 26 | 27 | INCLUDE(FindPackageHandleStandardArgs) 28 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(IIO DEFAULT_MSG IIO_LIBRARIES IIO_INCLUDE_DIRS) 29 | MARK_AS_ADVANCED(IIO_LIBRARIES IIO_INCLUDE_DIRS) 30 | 31 | -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F 2 | 3 | IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 5 | ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 6 | 7 | FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 8 | STRING(REGEX REPLACE "\n" ";" files "${files}") 9 | FOREACH(file ${files}) 10 | MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 11 | IF(EXISTS "$ENV{DESTDIR}${file}") 12 | EXEC_PROGRAM( 13 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 14 | OUTPUT_VARIABLE rm_out 15 | RETURN_VALUE rm_retval 16 | ) 17 | IF(NOT "${rm_retval}" STREQUAL 0) 18 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 19 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 20 | ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}") 21 | EXEC_PROGRAM( 22 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 23 | OUTPUT_VARIABLE rm_out 24 | RETURN_VALUE rm_retval 25 | ) 26 | IF(NOT "${rm_retval}" STREQUAL 0) 27 | MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 28 | ENDIF(NOT "${rm_retval}" STREQUAL 0) 29 | ELSE(EXISTS "$ENV{DESTDIR}${file}") 30 | MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 31 | ENDIF(EXISTS "$ENV{DESTDIR}${file}") 32 | ENDFOREACH(file) 33 | -------------------------------------------------------------------------------- /gnuradio-iio.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/@GR_LIBRARY_DIR@ 4 | includedir=${prefix}/@GR_INCLUDE_DIR@ 5 | 6 | Name: gnuradio-iio 7 | Description: GNU Radio blocks for the IIO devices 8 | Requires: gnuradio-runtime gnuradio-analog gnuradio-blocks 9 | Version: @GR_IIO_VERSION@ 10 | Libs: -L${libdir} -lgnuradio-iio -lgnuradio-analog -lgnuradio-blocks 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /grc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | install(FILES 21 | iio_device_source.xml iio_device_sink.xml 22 | iio_fmcomms2_source.xml iio_fmcomms2_sink.xml 23 | iio_fmcomms5_source.xml iio_fmcomms5_sink.xml 24 | iio_pluto_source.xml iio_pluto_sink.xml 25 | iio_math.xml iio_math_gen.xml iio_power_ff.xml 26 | iio_modulo_ff.xml iio_modulo_const_ff.xml 27 | iio_attr_sink.xml 28 | iio_attr_source.xml 29 | iio_attr_updater.xml 30 | DESTINATION share/gnuradio/grc/blocks 31 | ) 32 | -------------------------------------------------------------------------------- /grc/iio_attr_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IIO Attribute Sink 4 | iio_attr_sink 5 | [Industrial IO] 6 | from gnuradio import iio 7 | iio.attr_sink($uri, $device, $channel, $attr_type, $output, $required_enable) 8 | 9 | uri 10 | uri 11 | "" 12 | string 13 | 14 | 15 | Device 16 | device 17 | "" 18 | string 19 | 20 | 21 | 22 | Attribute Type 23 | attr_type 24 | enum 25 | 29 | 33 | 37 | 41 | 45 | 46 | 47 | 48 | Required Enable 49 | required_enable 50 | enum 51 | #if int($attr_type()) == 4 then 'none' else 'all'# 52 | 56 | 60 | 61 | 62 | 63 | Input/Output 64 | output 65 | enum 66 | #if int($attr_type()) == 0 then 'none' else 'all'# 67 | 71 | 75 | 76 | 77 | 78 | Channel Name 79 | channel 80 | "" 81 | string 82 | #if int($attr_type()) == 0 then 'none' else 'all'# 83 | 84 | 85 | 86 | attr 87 | message 88 | 1 89 | 90 | 91 | https://wiki.analog.com/resources/tools-software/linux-software/gnuradio 92 | 93 | 94 | -------------------------------------------------------------------------------- /grc/iio_attr_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IIO Attribute Source 4 | iio_attr_source 5 | [Industrial IO] 6 | from gnuradio import iio 7 | iio.attr_source($uri, $device, $channel, $attribute, $update_interval_ms, $samples_per_update, $type, $attr_type, $output, $address, $required_enable) 8 | 9 | 10 | uri 11 | uri 12 | "" 13 | string 14 | 15 | 16 | Device 17 | device 18 | "" 19 | string 20 | 21 | 22 | Attribute Type 23 | attr_type 24 | enum 25 | 29 | 33 | 37 | 41 | 42 | 43 | Input/Output 44 | output 45 | enum 46 | #if int($attr_type()) == 0 then 'none' else 'all'# 47 | 51 | 55 | 56 | 57 | Channel Name 58 | channel 59 | "" 60 | string 61 | #if int($attr_type()) == 0 then 'none' else 'all'# 62 | 63 | 64 | Attribute Name 65 | attribute 66 | "" 67 | string 68 | #if int($attr_type()) != 3 then 'none' else 'all'# 69 | 70 | 71 | Register Address 72 | address 73 | int("0x123",0) 74 | int 75 | #if int($attr_type()) == 3 then 'none' else 'all'# 76 | 77 | 78 | Required Enable 79 | required_enable 80 | enum 81 | #if int($attr_type()) == 3 then 'none' else 'all'# 82 | 86 | 90 | 91 | 92 | Data Type 93 | type 94 | enum 95 | #if int($attr_type()) != 3 then 'none' else 'all'# 96 | 101 | 106 | 111 | 116 | 121 | 122 | 123 | Update Interval (ms) 124 | update_interval_ms 125 | 1 126 | int 127 | 128 | 129 | Samples Per Update 130 | samples_per_update 131 | 1024 132 | int 133 | 134 | 135 | 136 | out 137 | #if int($attr_type()) == 3 then 's32' else str($type.fcn)# 138 | len($attributes) 139 | 140 | 141 | 142 | https://wiki.analog.com/resources/tools-software/linux-software/gnuradio 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /grc/iio_attr_updater.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IIO Attribute Updater 4 | iio_attr_updater 5 | [Industrial IO] 6 | from gnuradio import iio 7 | iio.attr_updater($attr, $value, $interval) 8 | update_value($value) 9 | 10 | Attribute 11 | attr 12 | "" 13 | string 14 | 15 | 16 | Value 17 | value 18 | "" 19 | string 20 | 21 | 22 | Interval (ms) 23 | interval 24 | 1 25 | int 26 | 27 | 28 | 29 | out 30 | message 31 | 32 | 33 | -------------------------------------------------------------------------------- /grc/iio_device_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IIO Device Sink 4 | iio_device_sink 5 | [Industrial IO] 6 | throttle 7 | from gnuradio import iio 8 | iio.device_sink($uri, $device, $channels, $device_phy, $params, $buffer_size, $interpolation - 1, $cyclic) 9 | 10 | 11 | IIO context URI 12 | uri 13 | local: 14 | string 15 | 16 | 17 | 18 | Device Name/ID 19 | device 20 | string 21 | 22 | 23 | 24 | PHY Device Name/ID 25 | device_phy 26 | string 27 | 28 | 29 | 30 | Channels 31 | channels 32 | [] 33 | raw 34 | 35 | 36 | 37 | Buffer size 38 | buffer_size 39 | 0x8000 40 | int 41 | 42 | 43 | 44 | Interpolation 45 | interpolation 46 | 1 47 | int 48 | 49 | 50 | 51 | Cyclic 52 | cyclic 53 | False 54 | enum 55 | 56 | 57 | 58 | 59 | 60 | Parameters 61 | params 62 | [] 63 | raw 64 | 65 | 66 | 67 | $device 68 | $device_phy 69 | 70 | 71 | $interpolation > 0 72 | 73 | 74 | len($channels) > 0 75 | 76 | 77 | in 78 | short 79 | len($channels) 80 | 81 | 82 | -------------------------------------------------------------------------------- /grc/iio_device_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | IIO Device Source 4 | iio_device_source 5 | [Industrial IO] 6 | throttle 7 | from gnuradio import iio 8 | iio.device_source($uri, $device, $channels, $device_phy, $params, $buffer_size, $decimation - 1) 9 | 10 | 11 | IIO context URI 12 | uri 13 | local: 14 | string 15 | 16 | 17 | 18 | Device Name/ID 19 | device 20 | string 21 | 22 | 23 | 24 | PHY Device Name/ID 25 | device_phy 26 | string 27 | 28 | 29 | 30 | Channels 31 | channels 32 | [] 33 | raw 34 | 35 | 36 | 37 | Buffer size 38 | buffer_size 39 | 0x8000 40 | int 41 | 42 | 43 | 44 | Decimation 45 | decimation 46 | 1 47 | int 48 | 49 | 50 | 51 | Parameters 52 | params 53 | [] 54 | raw 55 | 56 | 57 | 58 | $device 59 | $device_phy 60 | 61 | 62 | $decimation > 0 63 | 64 | 65 | len($channels) > 0 66 | 67 | 68 | out 69 | short 70 | len($channels) 71 | 72 | 73 | msg 74 | message 75 | 1 76 | 77 | 78 | -------------------------------------------------------------------------------- /grc/iio_fmcomms2_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FMComms2/3/4 Sink 4 | iio_fmcomms2_sink 5 | [Industrial IO]/FMComms 6 | throttle 7 | from gnuradio import iio 8 | iio.fmcomms2_sink_f32c($uri, int($frequency), int($samplerate), int($bandwidth), $tx1_en, $tx2_en, $buffer_size, $cyclic, $rf_port_select, $attenuation1, $attenuation2, $filter, $auto_filter) 9 | set_params(int($frequency), int($samplerate), int($bandwidth), $rf_port_select, $attenuation1, $attenuation2, $filter, $auto_filter) 10 | 11 | 12 | IIO context URI 13 | uri 14 | local: 15 | string 16 | 17 | 18 | 19 | LO Frequency 20 | frequency 21 | 2400000000 22 | real 23 | 24 | 25 | 26 | Sample rate 27 | samplerate 28 | 2084000 29 | real 30 | 31 | 32 | 33 | RF bandwidth 34 | bandwidth 35 | 20000000 36 | real 37 | 38 | 39 | 40 | Buffer size 41 | buffer_size 42 | 0x8000 43 | int 44 | 45 | 46 | 47 | TX1 Enabled 48 | tx1_en 49 | True 50 | enum 51 | 52 | 53 | 54 | 55 | 56 | TX2 Enabled 57 | tx2_en 58 | True 59 | enum 60 | 61 | 62 | 63 | 64 | 65 | Cyclic 66 | cyclic 67 | False 68 | enum 69 | 70 | 71 | 72 | 73 | 74 | RF Port Select 75 | rf_port_select 76 | enum 77 | 81 | 85 | 86 | 87 | 88 | Attenuation TX1 (dB) 89 | attenuation1 90 | 10.0 91 | real 92 | 93 | 94 | 95 | Attenuation TX2 (dB) 96 | attenuation2 97 | 10.0 98 | real 99 | 100 | 101 | 102 | Filter 103 | filter 104 | 105 | file_open 106 | 107 | 108 | 109 | Filter auto 110 | auto_filter 111 | True 112 | enum 113 | 114 | 115 | 116 | 117 | 118 | sum([$tx1_en, $tx2_en]) > 0 119 | 120 | 121 | ($samplerate >= 2084000) or (len($filter) > 0) or $auto_filter 122 | 123 | 124 | ($frequency >= 0) 125 | ($bandwidth >= 0) 126 | ($samplerate >= 0) 127 | 128 | 129 | not ($auto_filter and len($filter)) 130 | 131 | 132 | in 133 | complex 134 | sum([$tx1_en, $tx2_en]) 135 | 136 | 137 | -------------------------------------------------------------------------------- /grc/iio_fmcomms2_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FMComms2/3/4 Source 4 | iio_fmcomms2_source 5 | [Industrial IO]/FMComms 6 | throttle 7 | from gnuradio import iio 8 | iio.fmcomms2_source_f32c($uri, int($frequency), int($samplerate), int($bandwidth), $rx1_en, $rx2_en, $buffer_size, $quadrature, $rfdc, $bbdc, $gain1, $manual_gain1, $gain2, $manual_gain2, $rf_port_select, $filter, $auto_filter) 9 | set_params(int($frequency), int($samplerate), int($bandwidth), $quadrature, $rfdc, $bbdc, $gain1, $manual_gain1, $gain2, $manual_gain2, $rf_port_select, $filter, $auto_filter) 10 | 11 | 12 | IIO context URI 13 | uri 14 | local: 15 | string 16 | 17 | 18 | 19 | LO Frequency 20 | frequency 21 | 2400000000 22 | real 23 | 24 | 25 | 26 | Sample rate 27 | samplerate 28 | 2084000 29 | real 30 | 31 | 32 | 33 | RF bandwidth 34 | bandwidth 35 | 20000000 36 | real 37 | 38 | 39 | 40 | Buffer size 41 | buffer_size 42 | 0x8000 43 | int 44 | 45 | 46 | 47 | RX1 Enabled 48 | rx1_en 49 | True 50 | enum 51 | 52 | 53 | 54 | 55 | 56 | RX2 Enabled 57 | rx2_en 58 | True 59 | enum 60 | 61 | 62 | 63 | 64 | 65 | Quadrature 66 | quadrature 67 | True 68 | enum 69 | 70 | 71 | 72 | 73 | 74 | RF DC 75 | rfdc 76 | True 77 | enum 78 | 79 | 80 | 81 | 82 | 83 | BB DC 84 | bbdc 85 | True 86 | enum 87 | 88 | 89 | 90 | 91 | 92 | Gain Mode (RX1) 93 | gain1 94 | enum 95 | 99 | 103 | 107 | 111 | 112 | 113 | 114 | Manual Gain (RX1)(dB) 115 | manual_gain1 116 | 64.0 117 | real 118 | #if $gain1() == '"manual"' then 'none' else 'all'# 119 | 120 | 121 | 122 | Gain Mode (RX2) 123 | gain2 124 | enum 125 | 129 | 133 | 137 | 141 | 142 | 143 | 144 | Manual Gain (RX2)(dB) 145 | manual_gain2 146 | 64.0 147 | real 148 | #if $gain2() == '"manual"' then 'none' else 'all'# 149 | 150 | 151 | 152 | RF Port Select 153 | rf_port_select 154 | enum 155 | 159 | 163 | 167 | 171 | 175 | 179 | 183 | 187 | 191 | 195 | 199 | 203 | 204 | 205 | 206 | Filter 207 | filter 208 | 209 | file_open 210 | 211 | 212 | 213 | Filter auto 214 | auto_filter 215 | True 216 | enum 217 | 218 | 219 | 220 | 221 | sum([$rx1_en, $rx2_en]) > 0 222 | 223 | 224 | ($samplerate >= 2084000) or (len($filter) > 0) or $auto_filter 225 | 226 | 227 | ($frequency >= 0) 228 | ($bandwidth >= 0) 229 | ($samplerate >= 0) 230 | 231 | 232 | not ($auto_filter and len($filter)) 233 | 234 | 235 | out 236 | complex 237 | sum([$rx1_en, $rx2_en]) 238 | 239 | 240 | -------------------------------------------------------------------------------- /grc/iio_fmcomms5_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FMComms5 Sink 4 | iio_fmcomms5_sink 5 | [Industrial IO]/FMComms 6 | throttle 7 | from gnuradio import iio 8 | iio.fmcomms5_sink_f32c($uri, int($frequency1), int($frequency2), int($samplerate), int($bandwidth), $ch1_en, $ch2_en, $ch3_en, $ch4_en, $buffer_size, $cyclic, $rf_port_select, $attenuation1, $attenuation2, $attenuation3, $attenuation4, $filter) 9 | set_params(int($frequency1), int($frequency2), int($samplerate), int($bandwidth), $rf_port_select, $attenuation1, $attenuation2, $attenuation3, $attenuation4) 10 | 11 | 12 | 13 | IIO context URI 14 | uri 15 | local: 16 | string 17 | 18 | 19 | 20 | LO Frequency (TX1/TX2) 21 | frequency1 22 | 2400000000 23 | real 24 | 25 | 26 | 27 | LO Frequency (TX3/TX4) 28 | frequency2 29 | 2400000000 30 | real 31 | 32 | 33 | 34 | Sample rate 35 | samplerate 36 | 2084000 37 | real 38 | 39 | 40 | 41 | RF bandwidth 42 | bandwidth 43 | 20000000 44 | real 45 | 46 | 47 | 48 | Buffer size 49 | buffer_size 50 | 0x8000 51 | int 52 | 53 | 54 | 55 | Channel 1 Enabled 56 | ch1_en 57 | True 58 | enum 59 | 60 | 61 | 62 | 63 | 64 | Channel 2 Enabled 65 | ch2_en 66 | True 67 | enum 68 | 69 | 70 | 71 | 72 | 73 | Channel 3 Enabled 74 | ch3_en 75 | True 76 | enum 77 | 78 | 79 | 80 | 81 | 82 | Channel 4 Enabled 83 | ch4_en 84 | True 85 | enum 86 | 87 | 88 | 89 | 90 | 91 | Cyclic 92 | cyclic 93 | False 94 | enum 95 | 96 | 97 | 98 | 99 | 100 | RF Port Select 101 | rf_port_select 102 | enum 103 | 107 | 111 | 112 | 113 | 114 | Attenuation TX1 (dB) 115 | attenuation1 116 | 10.0 117 | real 118 | 119 | 120 | 121 | Attenuation TX2 (dB) 122 | attenuation2 123 | 10.0 124 | real 125 | 126 | 127 | 128 | Attenuation TX3 (dB) 129 | attenuation3 130 | 10.0 131 | real 132 | 133 | 134 | 135 | Attenuation TX4 (dB) 136 | attenuation4 137 | 10.0 138 | real 139 | 140 | 141 | 142 | Filter 143 | filter 144 | 145 | file_open 146 | 147 | 148 | sum([$ch1_en, $ch2_en, $ch3_en, $ch4_en]) > 0 149 | $samplerate >= 2084000 150 | 151 | 152 | ($frequency1 >= 0) 153 | ($frequency2 >= 0) 154 | ($bandwidth >= 0) 155 | ($samplerate >= 0) 156 | 157 | 158 | in 159 | complex 160 | sum([$ch1_en, $ch2_en, $ch3_en, $ch4_en]) 161 | 162 | 163 | -------------------------------------------------------------------------------- /grc/iio_fmcomms5_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | FMComms5 Source 4 | iio_fmcomms5_source 5 | [Industrial IO]/FMComms 6 | throttle 7 | from gnuradio import iio 8 | iio.fmcomms5_source_f32c($uri, int($frequency1), int($frequency2), int($samplerate), int($bandwidth), $ch1_en, $ch2_en, $ch3_en, $ch4_en, $buffer_size, $quadrature, $rfdc, $bbdc, $gain1, $manual_gain1, $gain2, $manual_gain2, $gain3, $manual_gain3, $gain4, $manual_gain4, $rf_port_select, $filter) 9 | set_params(int($frequency1), int($frequency2), int($samplerate), int($bandwidth), $quadrature, $rfdc, $bbdc, $gain1, $manual_gain1, $gain2, $manual_gain2, $gain3, $manual_gain3, $gain4, $manual_gain4, $rf_port_select) 10 | 11 | 12 | IIO context URI 13 | uri 14 | local: 15 | string 16 | 17 | 18 | 19 | LO Frequency (RX1/RX2) 20 | frequency1 21 | 2400000000 22 | real 23 | 24 | 25 | 26 | LO Frequency (RX3/RX4) 27 | frequency2 28 | 2400000000 29 | real 30 | 31 | 32 | 33 | Sample rate 34 | samplerate 35 | 2084000 36 | real 37 | 38 | 39 | 40 | RF bandwidth 41 | bandwidth 42 | 20000000 43 | real 44 | 45 | 46 | 47 | Buffer size 48 | buffer_size 49 | 0x8000 50 | int 51 | 52 | 53 | 54 | Channel 1 Enabled 55 | ch1_en 56 | True 57 | enum 58 | 59 | 60 | 61 | 62 | 63 | Channel 2 Enabled 64 | ch2_en 65 | True 66 | enum 67 | 68 | 69 | 70 | 71 | 72 | Channel 3 Enabled 73 | ch3_en 74 | True 75 | enum 76 | 77 | 78 | 79 | 80 | 81 | Channel 4 Enabled 82 | ch4_en 83 | True 84 | enum 85 | 86 | 87 | 88 | 89 | 90 | Quadrature 91 | quadrature 92 | True 93 | enum 94 | 95 | 96 | 97 | 98 | 99 | RF DC 100 | rfdc 101 | True 102 | enum 103 | 104 | 105 | 106 | 107 | 108 | BB DC 109 | bbdc 110 | True 111 | enum 112 | 113 | 114 | 115 | 116 | 117 | Gain Mode (RX1) 118 | gain1 119 | enum 120 | 124 | 128 | 132 | 136 | 137 | 138 | 139 | Manual Gain (RX1)(dB) 140 | manual_gain1 141 | 64.0 142 | real 143 | #if $gain1() == '"manual"' then 'none' else 'all'# 144 | 145 | 146 | 147 | Gain Mode (RX2) 148 | gain2 149 | enum 150 | 154 | 158 | 162 | 166 | 167 | 168 | 169 | Manual Gain (RX2)(dB) 170 | manual_gain2 171 | 64.0 172 | real 173 | #if $gain2() == '"manual"' then 'none' else 'all'# 174 | 175 | 176 | 177 | Gain Mode (RX3) 178 | gain3 179 | enum 180 | 184 | 188 | 192 | 196 | 197 | 198 | 199 | Manual Gain (RX3)(dB) 200 | manual_gain3 201 | 64.0 202 | real 203 | #if $gain3() == '"manual"' then 'none' else 'all'# 204 | 205 | 206 | 207 | Gain Mode (RX4) 208 | gain4 209 | enum 210 | 214 | 218 | 222 | 226 | 227 | 228 | 229 | Manual Gain (RX4)(dB) 230 | manual_gain4 231 | 64.0 232 | real 233 | #if $gain4() == '"manual"' then 'none' else 'all'# 234 | 235 | 236 | 237 | RF Port Select 238 | rf_port_select 239 | enum 240 | 244 | 248 | 252 | 256 | 260 | 264 | 268 | 272 | 276 | 280 | 284 | 288 | 289 | 290 | 291 | Filter 292 | filter 293 | 294 | file_open 295 | 296 | 297 | sum([$ch1_en, $ch2_en, $ch3_en, $ch4_en]) > 0 298 | $samplerate >= 2084000 299 | 300 | 301 | ($frequency1 >= 0) 302 | ($frequency2 >= 0) 303 | ($bandwidth >= 0) 304 | ($samplerate >= 0) 305 | 306 | 307 | out 308 | complex 309 | sum([$ch1_en, $ch2_en, $ch3_en, $ch4_en]) 310 | 311 | 312 | -------------------------------------------------------------------------------- /grc/iio_math.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Function 4 | math 5 | [Industrial IO]/Math Operators 6 | from gnuradio import iio 7 | iio.iio_math($function, $num_inputs) 8 | 9 | 10 | f(x) = 11 | function 12 | 13 | string 14 | 15 | 16 | 17 | Num Inputs 18 | num_inputs 19 | 1 20 | int 21 | 22 | 23 | 24 | $function 25 | 26 | $num_inputs > 0 27 | 28 | 29 | in 30 | float 31 | $num_inputs 32 | 33 | 34 | 35 | out 36 | float 37 | 38 | 39 | -------------------------------------------------------------------------------- /grc/iio_math_gen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Function Generator 4 | math_gen 5 | [Industrial IO]/Waveform Generators 6 | from gnuradio import iio 7 | iio.iio_math_gen($samp_rate, $wav_freq, $function) 8 | 9 | 10 | samp_rate 11 | samp_rate 12 | samp_rate 13 | int 14 | 15 | 16 | 17 | wav_freq 18 | wav_freq 19 | 1 20 | int 21 | 22 | 23 | 24 | f(x) = 25 | function 26 | 27 | string 28 | 29 | 30 | 31 | $function 32 | 33 | 34 | out 35 | float 36 | 37 | 38 | -------------------------------------------------------------------------------- /grc/iio_modulo_const_ff.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Modulo Const 4 | iio_modulo_const_ff 5 | [Industrial IO]/Math Operators 6 | from gnuradio import iio 7 | iio.modulo_const_ff($modulo, $vlen) 8 | 9 | Modulo 10 | modulo 11 | 1.0 12 | float 13 | 14 | 15 | Vec Length 16 | vlen 17 | 1 18 | int 19 | 20 | $vlen > 0 21 | 22 | in 23 | float 24 | $vlen 25 | 26 | 27 | out 28 | float 29 | $vlen 30 | 31 | 32 | -------------------------------------------------------------------------------- /grc/iio_modulo_ff.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Modulo 4 | iio_modulo_ff 5 | [Industrial IO]/Math Operators 6 | from gnuradio import iio 7 | iio.modulo_ff($vlen) 8 | 9 | Vec Length 10 | vlen 11 | 1 12 | int 13 | 14 | $vlen > 0 15 | 16 | in 17 | float 18 | $vlen 19 | 20 | 21 | mod 22 | float 23 | $vlen 24 | 25 | 26 | out 27 | float 28 | $vlen 29 | 30 | 31 | -------------------------------------------------------------------------------- /grc/iio_pluto_sink.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | PlutoSDR Sink 4 | pluto_sink 5 | [Industrial IO]/PlutoSDR 6 | throttle 7 | from gnuradio import iio 8 | iio.pluto_sink($uri, int($frequency), int($samplerate), int($bandwidth), $buffer_size, $cyclic, $attenuation, $filter, $auto_filter) 9 | set_params(int($frequency), int($samplerate), int($bandwidth), $attenuation, $filter, $auto_filter) 10 | 11 | 12 | IIO context URI 13 | uri 14 | 15 | string 16 | 17 | 18 | 19 | LO Frequency 20 | frequency 21 | 2400000000 22 | real 23 | 24 | 25 | 26 | Sample rate 27 | samplerate 28 | 2084000 29 | real 30 | 31 | 32 | 33 | RF bandwidth 34 | bandwidth 35 | 20000000 36 | real 37 | 38 | 39 | 40 | Buffer size 41 | buffer_size 42 | 0x8000 43 | int 44 | 45 | 46 | 47 | Cyclic 48 | cyclic 49 | False 50 | enum 51 | 52 | 53 | 54 | 55 | 56 | Attenuation (dB) 57 | attenuation 58 | 10.0 59 | real 60 | 61 | 62 | 63 | Filter 64 | filter 65 | 66 | file_open 67 | 68 | 69 | 70 | Filter auto 71 | auto_filter 72 | True 73 | enum 74 | 75 | 76 | 77 | 78 | 79 | ($samplerate >= 2084000) or (len($filter) > 0) or $auto_filter 80 | 81 | 82 | ($frequency >= 0) 83 | ($bandwidth >= 0) 84 | ($samplerate >= 0) 85 | 86 | 87 | not ($auto_filter and len($filter)) 88 | 89 | 90 | in 91 | complex 92 | 1 93 | 94 | 95 | -------------------------------------------------------------------------------- /grc/iio_pluto_source.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | PlutoSDR Source 4 | pluto_source 5 | [Industrial IO]/PlutoSDR 6 | throttle 7 | from gnuradio import iio 8 | iio.pluto_source($uri, int($frequency), int($samplerate), int($bandwidth), $buffer_size, $quadrature, $rfdc, $bbdc, $gain, $manual_gain, $filter, $auto_filter) 9 | set_params(int($frequency), int($samplerate), int($bandwidth), $quadrature, $rfdc, $bbdc, $gain, $manual_gain, $filter, $auto_filter) 10 | 11 | 12 | Device URI 13 | uri 14 | 15 | string 16 | 17 | 18 | 19 | LO Frequency 20 | frequency 21 | 2400000000 22 | real 23 | 24 | 25 | 26 | Sample rate 27 | samplerate 28 | 2084000 29 | real 30 | 31 | 32 | 33 | RF bandwidth 34 | bandwidth 35 | 20000000 36 | real 37 | 38 | 39 | 40 | Buffer size 41 | buffer_size 42 | 0x8000 43 | int 44 | 45 | 46 | 47 | Quadrature 48 | quadrature 49 | True 50 | enum 51 | 52 | 53 | 54 | 55 | 56 | RF DC 57 | rfdc 58 | True 59 | enum 60 | 61 | 62 | 63 | 64 | 65 | BB DC 66 | bbdc 67 | True 68 | enum 69 | 70 | 71 | 72 | 73 | 74 | Gain Mode 75 | gain 76 | enum 77 | 81 | 85 | 89 | 93 | 94 | 95 | 96 | Manual Gain (dB) 97 | manual_gain 98 | 64.0 99 | real 100 | #if $gain() == '"manual"' then 'none' else 'all'# 101 | 102 | 103 | 104 | Filter 105 | filter 106 | 107 | file_open 108 | 109 | 110 | 111 | Filter auto 112 | auto_filter 113 | True 114 | enum 115 | 116 | 117 | 118 | 119 | 120 | ($samplerate >= 2084000) or (len($filter) > 0) or $auto_filter 121 | 122 | 123 | ($frequency >= 0) 124 | ($bandwidth >= 0) 125 | ($samplerate >= 0) 126 | 127 | 128 | not ($auto_filter and len($filter)) 129 | 130 | 131 | out 132 | complex 133 | 1 134 | 135 | 136 | -------------------------------------------------------------------------------- /grc/iio_power_ff.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | Power 10 | iio_power_ff 11 | [Industrial IO]/Math Operators 12 | from gnuradio import iio 13 | iio.power_ff($vlen) 14 | 15 | Vec Length 16 | vlen 17 | 1 18 | int 19 | 20 | $vlen > 0 21 | 22 | base 23 | float 24 | $vlen 25 | 26 | 27 | exp 28 | float 29 | $vlen 30 | 31 | 32 | out 33 | float 34 | $vlen 35 | 36 | 37 | -------------------------------------------------------------------------------- /iio-examples/attr-sink.grc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Thu Aug 2 18:56:14 2018 5 | 6 | options 7 | 8 | author 9 | Travis Collins 10 | 11 | 12 | window_size 13 | 14 | 15 | 16 | category 17 | [GRC Hier Blocks] 18 | 19 | 20 | comment 21 | 22 | 23 | 24 | description 25 | 26 | 27 | 28 | _enabled 29 | True 30 | 31 | 32 | _coordinate 33 | (8, 8) 34 | 35 | 36 | _rotation 37 | 0 38 | 39 | 40 | generate_options 41 | no_gui 42 | 43 | 44 | hier_block_src_path 45 | .: 46 | 47 | 48 | id 49 | attr_sink_example 50 | 51 | 52 | max_nouts 53 | 0 54 | 55 | 56 | qt_qss_theme 57 | 58 | 59 | 60 | realtime_scheduling 61 | 62 | 63 | 64 | run_command 65 | {python} -u {filename} 66 | 67 | 68 | run_options 69 | prompt 70 | 71 | 72 | run 73 | True 74 | 75 | 76 | thread_safe_setters 77 | 78 | 79 | 80 | title 81 | Attribute Sink Example 82 | 83 | 84 | 85 | blocks_message_debug 86 | 87 | alias 88 | 89 | 90 | 91 | comment 92 | 93 | 94 | 95 | affinity 96 | 97 | 98 | 99 | _enabled 100 | True 101 | 102 | 103 | _coordinate 104 | (584, 216) 105 | 106 | 107 | _rotation 108 | 0 109 | 110 | 111 | id 112 | blocks_message_debug_0 113 | 114 | 115 | 116 | blocks_message_strobe 117 | 118 | alias 119 | 120 | 121 | 122 | comment 123 | 124 | 125 | 126 | affinity 127 | 128 | 129 | 130 | _enabled 131 | 1 132 | 133 | 134 | _coordinate 135 | (224, 84) 136 | 137 | 138 | _rotation 139 | 0 140 | 141 | 142 | id 143 | blocks_message_strobe_0_0 144 | 145 | 146 | maxoutbuf 147 | 0 148 | 149 | 150 | msg 151 | msg_source.msg_dic 152 | 153 | 154 | minoutbuf 155 | 0 156 | 157 | 158 | period 159 | 1000 160 | 161 | 162 | 163 | iio_attr_sink 164 | 165 | alias 166 | 167 | 168 | 169 | channel 170 | "voltage0" 171 | 172 | 173 | comment 174 | 175 | 176 | 177 | affinity 178 | 179 | 180 | 181 | device 182 | "ad9361-phy" 183 | 184 | 185 | _enabled 186 | 1 187 | 188 | 189 | _coordinate 190 | (552, 80) 191 | 192 | 193 | _rotation 194 | 0 195 | 196 | 197 | id 198 | iio_attr_sink_0 199 | 200 | 201 | uri 202 | "ip:192.168.2.1" 203 | 204 | 205 | 206 | epy_module 207 | 208 | alias 209 | 210 | 211 | 212 | source_code 213 | import pmt 214 | key0 = pmt.intern("rf_bandwidth") 215 | val0 = pmt.intern("23000000") 216 | msg_dic = pmt.make_dict() 217 | msg_dic = pmt.dict_add(msg_dic, key0, val0) 218 | 219 | 220 | comment 221 | 222 | 223 | 224 | _enabled 225 | True 226 | 227 | 228 | _coordinate 229 | (32, 132) 230 | 231 | 232 | _rotation 233 | 0 234 | 235 | 236 | id 237 | msg_source 238 | 239 | 240 | 241 | blocks_message_strobe_0_0 242 | blocks_message_debug_0 243 | strobe 244 | print 245 | 246 | 247 | blocks_message_strobe_0_0 248 | iio_attr_sink_0 249 | strobe 250 | attr 251 | 252 | 253 | -------------------------------------------------------------------------------- /include/gnuradio/iio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011,2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Install public header files 22 | ######################################################################## 23 | install(FILES 24 | api.h 25 | device_source.h device_sink.h 26 | fmcomms2_source.h fmcomms2_sink.h 27 | fmcomms5_source.h fmcomms5_sink.h 28 | pluto_source.h pluto_sink.h 29 | converter_ss.h math.h power_ff.h 30 | attr_sink.h 31 | attr_source.h 32 | modulo_ff.h modulo_const_ff.h 33 | DESTINATION ${GR_INCLUDE_DIR}/gnuradio/iio 34 | ) 35 | -------------------------------------------------------------------------------- /include/gnuradio/iio/api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * GNU Radio is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * GNU Radio is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with GNU Radio; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_API_H 23 | #define INCLUDED_IIO_API_H 24 | 25 | #include 26 | 27 | #ifdef gnuradio_iio_EXPORTS 28 | # define IIO_API __GR_ATTR_EXPORT 29 | #else 30 | # define IIO_API __GR_ATTR_IMPORT 31 | #endif 32 | 33 | #endif /* INCLUDED_IIO_API_H */ 34 | -------------------------------------------------------------------------------- /include/gnuradio/iio/attr_sink.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2018 Analog Devices Inc. 4 | * Author: Travis Collins 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_ATTR_SINK_H 24 | #define INCLUDED_IIO_ATTR_SINK_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | 32 | /*! 33 | * \brief <+description of block+> 34 | * \ingroup iio 35 | * 36 | */ 37 | class IIO_API attr_sink : virtual public gr::block 38 | { 39 | public: 40 | typedef boost::shared_ptr sptr; 41 | 42 | /*! 43 | * \brief Return a shared_ptr to a new instance of iio::attr_sink. 44 | * 45 | * To avoid accidental use of raw pointers, iio::attr_sink's 46 | * constructor is in a private implementation 47 | * class. iio::attr_sink::make is the public interface for 48 | * creating new instances. 49 | */ 50 | static sptr make(const std::string &uri, const std::string &device, 51 | const std::string &channel, int type, bool output, bool required_enable); 52 | }; 53 | 54 | } // namespace iio 55 | } // namespace gr 56 | 57 | #endif /* INCLUDED_IIO_ATTR_SINK_H */ 58 | -------------------------------------------------------------------------------- /include/gnuradio/iio/attr_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2018 Analog Devices Inc. 4 | * Author: Travis Collins 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_ATTR_SOURCE_H 24 | #define INCLUDED_IIO_ATTR_SOURCE_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | 32 | /*! 33 | * \brief <+description of block+> 34 | * \ingroup iio 35 | * 36 | */ 37 | class IIO_API attr_source : virtual public gr::sync_block 38 | { 39 | public: 40 | typedef boost::shared_ptr sptr; 41 | 42 | /*! 43 | * \brief Return a shared_ptr to a new instance of iio::attr_source. 44 | * 45 | * To avoid accidental use of raw pointers, iio::attr_source's 46 | * constructor is in a private implementation 47 | * class. iio::attr_source::make is the public interface for 48 | * creating new instances. 49 | */ 50 | static sptr make(const std::string &uri, const std::string &device, const std::string &channel, 51 | const std::string &attribute, int update_interval_ms, int samples_per_update, 52 | int data_type, int attr_type, bool output, uint32_t address, bool required_enable); 53 | }; 54 | 55 | } // namespace iio 56 | } // namespace gr 57 | 58 | #endif /* INCLUDED_IIO_ATTR_SOURCE_H */ 59 | -------------------------------------------------------------------------------- /include/gnuradio/iio/converter_ss.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_CONVERTER_SS_H 24 | #define INCLUDED_IIO_CONVERTER_SS_H 25 | 26 | #include 27 | #include 28 | 29 | extern "C" { 30 | struct iio_channel; 31 | }; 32 | 33 | namespace gr { 34 | namespace iio { 35 | 36 | /*! 37 | * \brief <+description of block+> 38 | * \ingroup iio 39 | * 40 | */ 41 | class IIO_API converter_ss : virtual public gr::sync_block 42 | { 43 | public: 44 | typedef boost::shared_ptr sptr; 45 | 46 | static sptr make(const struct iio_channel *channel, 47 | bool inverse); 48 | }; 49 | } 50 | } 51 | 52 | #endif /* INCLUDED_IIO_CONVERTER_SS_H */ 53 | -------------------------------------------------------------------------------- /include/gnuradio/iio/device_sink.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_DEVICE_SINK_H 24 | #define INCLUDED_IIO_DEVICE_SINK_H 25 | 26 | #include 27 | #include 28 | 29 | #define DEFAULT_BUFFER_SIZE 0x8000 30 | 31 | extern "C" { 32 | struct iio_context; 33 | }; 34 | 35 | namespace gr { 36 | namespace iio { 37 | 38 | /*! 39 | * \brief <+description of block+> 40 | * \ingroup iio 41 | * 42 | */ 43 | class IIO_API device_sink : virtual public gr::sync_block 44 | { 45 | public: 46 | typedef boost::shared_ptr sptr; 47 | 48 | /*! 49 | * \brief Return a shared_ptr to a new instance of iio::device. 50 | * 51 | * To avoid accidental use of raw pointers, iio::device's 52 | * constructor is in a private implementation 53 | * class. iio::device::make is the public interface for 54 | * creating new instances. 55 | */ 56 | static sptr make(const std::string &uri, const std::string &device, 57 | const std::vector &channels, 58 | const std::string &device_phy, 59 | const std::vector ¶ms, 60 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 61 | unsigned int interpolation = 0, bool cyclic = false); 62 | 63 | static sptr make_from(struct iio_context *ctx, const std::string &device, 64 | const std::vector &channels, 65 | const std::string &device_phy, 66 | const std::vector ¶ms, 67 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 68 | unsigned int interpolation = 0, bool cyclic = false); 69 | }; 70 | 71 | } // namespace iio 72 | } // namespace gr 73 | 74 | #endif /* INCLUDED_IIO_DEVICE_SINK_H */ 75 | 76 | -------------------------------------------------------------------------------- /include/gnuradio/iio/device_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_DEVICE_SOURCE_H 24 | #define INCLUDED_IIO_DEVICE_SOURCE_H 25 | 26 | #include 27 | #include 28 | 29 | #define DEFAULT_BUFFER_SIZE 0x8000 30 | 31 | extern "C" { 32 | struct iio_context; 33 | }; 34 | 35 | namespace gr { 36 | namespace iio { 37 | 38 | /*! 39 | * \brief <+description of block+> 40 | * \ingroup iio 41 | * 42 | */ 43 | class IIO_API device_source : virtual public gr::sync_block 44 | { 45 | public: 46 | typedef boost::shared_ptr sptr; 47 | 48 | /*! 49 | * \brief Return a shared_ptr to a new instance of iio::device. 50 | * 51 | * To avoid accidental use of raw pointers, iio::device's 52 | * constructor is in a private implementation 53 | * class. iio::device::make is the public interface for 54 | * creating new instances. 55 | */ 56 | static sptr make(const std::string &uri, const std::string &device, 57 | const std::vector &channels, 58 | const std::string &device_phy, 59 | const std::vector ¶ms, 60 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 61 | unsigned int decimation = 0); 62 | 63 | static sptr make_from(struct iio_context *ctx, const std::string &device, 64 | const std::vector &channels, 65 | const std::string &device_phy, 66 | const std::vector ¶ms, 67 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 68 | unsigned int decimation = 0); 69 | 70 | virtual void set_buffer_size(unsigned int buffer_size) = 0; 71 | virtual void set_timeout_ms(unsigned long timeout) = 0; 72 | }; 73 | 74 | } // namespace iio 75 | } // namespace gr 76 | 77 | #endif /* INCLUDED_IIO_DEVICE_SOURCE_H */ 78 | 79 | -------------------------------------------------------------------------------- /include/gnuradio/iio/fmcomms2_sink.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_FMCOMMS2_SINK_H 24 | #define INCLUDED_IIO_FMCOMMS2_SINK_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "device_sink.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class IIO_API fmcomms2_sink : virtual public gr::sync_block 36 | { 37 | public: 38 | typedef boost::shared_ptr sptr; 39 | 40 | static sptr make(const std::string &uri, unsigned long long frequency, 41 | unsigned long samplerate, 42 | unsigned long bandwidth, 43 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 44 | unsigned long buffer_size, bool cyclic, 45 | const char *rf_port_select, double attenuation1, 46 | double attenuation2, const char *filter = "", 47 | bool auto_filter = true); 48 | 49 | static sptr make_from(struct iio_context *ctx, 50 | unsigned long long frequency, unsigned long samplerate, 51 | unsigned long bandwidth, 52 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 53 | unsigned long buffer_size, bool cyclic, 54 | const char *rf_port_select, double attenuation1, 55 | double attenuation2, const char *filter = "", 56 | bool auto_filter = true); 57 | 58 | virtual void set_params(unsigned long long frequency, 59 | unsigned long samplerate, unsigned long bandwidth, 60 | const char *rf_port_select, double attenuation1, 61 | double attenuation2, const char *filter = "", 62 | bool auto_filter = true) = 0; 63 | }; 64 | 65 | class IIO_API fmcomms2_sink_f32c : virtual public gr::hier_block2 66 | { 67 | public: 68 | typedef boost::shared_ptr sptr; 69 | 70 | static sptr make(const std::string &uri, unsigned long long frequency, 71 | unsigned long samplerate, 72 | unsigned long bandwidth, bool rx1_en, bool rx2_en, 73 | unsigned long buffer_size, bool cyclic, 74 | const char *rf_port_select, double attenuation1, 75 | double attenuation2, const char *filter = "", 76 | bool auto_filter = true) 77 | { 78 | fmcomms2_sink::sptr block = fmcomms2_sink::make(uri, frequency, 79 | samplerate, bandwidth, rx1_en, 80 | rx1_en, rx2_en, rx2_en, buffer_size, cyclic, 81 | rf_port_select, attenuation1, attenuation2, 82 | filter, auto_filter); 83 | 84 | return gnuradio::get_initial_sptr( 85 | new fmcomms2_sink_f32c(rx1_en, rx2_en, block)); 86 | } 87 | 88 | void set_params(unsigned long long frequency, 89 | unsigned long samplerate, unsigned long bandwidth, 90 | const char *rf_port_select, double attenuation1, 91 | double attenuation2, const char *filter = "", 92 | bool auto_filter = true) 93 | { 94 | fmcomms2_block->set_params(frequency, samplerate, bandwidth, 95 | rf_port_select, attenuation1, attenuation2, 96 | filter, auto_filter); 97 | } 98 | 99 | private: 100 | fmcomms2_sink::sptr fmcomms2_block; 101 | 102 | protected: 103 | explicit fmcomms2_sink_f32c(bool rx1_en, bool rx2_en, 104 | fmcomms2_sink::sptr block); 105 | }; 106 | 107 | } // namespace iio 108 | } // namespace gr 109 | 110 | #endif /* INCLUDED_IIO_FMCOMMS2_SINK_H */ 111 | 112 | -------------------------------------------------------------------------------- /include/gnuradio/iio/fmcomms2_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_FMCOMMS2_SOURCE_H 24 | #define INCLUDED_IIO_FMCOMMS2_SOURCE_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "device_source.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | /*! 36 | * \brief <+description of block+> 37 | * \ingroup iio 38 | * 39 | */ 40 | class IIO_API fmcomms2_source : virtual public gr::sync_block 41 | { 42 | public: 43 | typedef boost::shared_ptr sptr; 44 | 45 | /*! 46 | * \brief Return a shared_ptr to a new instance of iio::device. 47 | * 48 | * To avoid accidental use of raw pointers, iio::device's 49 | * constructor is in a private implementation 50 | * class. iio::device::make is the public interface for 51 | * creating new instances. 52 | */ 53 | static sptr make(const std::string &uri, unsigned long long frequency, 54 | unsigned long samplerate, 55 | unsigned long bandwidth, 56 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 57 | unsigned long buffer_size, bool quadrature, bool rfdc, 58 | bool bbdc, const char *gain1, double gain1_value, 59 | const char *gain2, double gain2_value, 60 | const char *rf_port_select, const char *filter = "", 61 | bool auto_filter = true); 62 | 63 | static sptr make_from(struct iio_context *ctx, 64 | unsigned long long frequency, unsigned long samplerate, 65 | unsigned long bandwidth, 66 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 67 | unsigned long buffer_size, bool quadrature, bool rfdc, 68 | bool bbdc, const char *gain1, double gain1_value, 69 | const char *gain2, double gain2_value, 70 | const char *rf_port_select, const char *filter = "", 71 | bool auto_filter = true); 72 | 73 | virtual void set_params(unsigned long long frequency, 74 | unsigned long samplerate, unsigned long bandwidth, 75 | bool quadrature, bool rfdc, bool bbdc, 76 | const char *gain1, double gain1_value, 77 | const char *gain2, double gain2_value, 78 | const char *rf_port_select, 79 | const char *filter = "", bool auto_filter = true) = 0; 80 | }; 81 | 82 | class IIO_API fmcomms2_source_f32c : virtual public gr::hier_block2 83 | { 84 | public: 85 | typedef boost::shared_ptr sptr; 86 | 87 | static sptr make(const std::string &uri, 88 | unsigned long long frequency, unsigned long samplerate, 89 | unsigned long bandwidth, 90 | bool rx1_en, bool rx2_en, 91 | unsigned long buffer_size, bool quadrature, bool rfdc, 92 | bool bbdc, const char *gain1, double gain1_value, 93 | const char *gain2, double gain2_value, 94 | const char *rf_port_select, const char *filter = "", 95 | bool auto_filter = true) 96 | { 97 | fmcomms2_source::sptr block = fmcomms2_source::make(uri, 98 | frequency, samplerate, 99 | bandwidth, rx1_en, rx1_en, rx2_en, 100 | rx2_en, buffer_size, quadrature, 101 | rfdc, bbdc, gain1, gain1_value, 102 | gain2, gain2_value, rf_port_select, 103 | filter, auto_filter); 104 | 105 | return gnuradio::get_initial_sptr( 106 | new fmcomms2_source_f32c(rx1_en, rx2_en, block)); 107 | } 108 | 109 | void set_params(unsigned long long frequency, 110 | unsigned long samplerate, unsigned long bandwidth, 111 | bool quadrature, bool rfdc, bool bbdc, 112 | const char *gain1, double gain1_value, 113 | const char *gain2, double gain2_value, 114 | const char *rf_port_select, 115 | const char *filter = "", bool auto_filter = true) 116 | { 117 | fmcomms2_block->set_params(frequency, samplerate, bandwidth, 118 | quadrature, rfdc, bbdc, gain1, gain1_value, 119 | gain2, gain2_value, rf_port_select, filter, 120 | auto_filter); 121 | } 122 | private: 123 | fmcomms2_source::sptr fmcomms2_block; 124 | 125 | protected: 126 | explicit fmcomms2_source_f32c(bool rx1_en, bool rx2_en, 127 | fmcomms2_source::sptr block); 128 | }; 129 | 130 | } // namespace iio 131 | } // namespace gr 132 | 133 | #endif /* INCLUDED_IIO_FMCOMMS2_SOURCE_H */ 134 | 135 | -------------------------------------------------------------------------------- /include/gnuradio/iio/fmcomms5_sink.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_FMCOMMS5_SINK_H 24 | #define INCLUDED_IIO_FMCOMMS5_SINK_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "device_sink.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class IIO_API fmcomms5_sink : virtual public gr::sync_block 36 | { 37 | public: 38 | typedef boost::shared_ptr sptr; 39 | 40 | static sptr make(const std::string &uri, unsigned long long frequency1, 41 | unsigned long long frequency2, 42 | unsigned long samplerate, 43 | unsigned long bandwidth, 44 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 45 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 46 | unsigned long buffer_size, bool cyclic, 47 | const char *rf_port_select, 48 | double attenuation1, double attenuation2, 49 | double attenuation3, double attenuation4, 50 | const char *filter = ""); 51 | 52 | static sptr make_from(struct iio_context *ctx, 53 | unsigned long long frequency1, 54 | unsigned long long frequency2, unsigned long samplerate, 55 | unsigned long bandwidth, 56 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 57 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 58 | unsigned long buffer_size, bool cyclic, 59 | const char *rf_port_select, 60 | double attenuation1, double attenuation2, 61 | double attenuation3, double attenuation4, 62 | const char *filter = ""); 63 | 64 | virtual void set_params(unsigned long long frequency1, 65 | unsigned long long frequency2, 66 | unsigned long samplerate, unsigned long bandwidth, 67 | const char *rf_port_select, 68 | double attenuation1, double attenuation2, 69 | double attenuation3, double attenuation4) = 0; 70 | }; 71 | 72 | class IIO_API fmcomms5_sink_f32c : virtual public gr::hier_block2 73 | { 74 | public: 75 | typedef boost::shared_ptr sptr; 76 | 77 | static sptr make(const std::string &uri, unsigned long long frequency1, 78 | unsigned long long frequency2, 79 | unsigned long samplerate, 80 | unsigned long bandwidth, bool rx1_en, bool rx2_en, 81 | bool rx3_en, bool rx4_en, 82 | unsigned long buffer_size, bool cyclic, 83 | const char *rf_port_select, double attenuation1, 84 | double attenuation2, double attenuation3, 85 | double attenuation4, const char *filter = "") 86 | { 87 | fmcomms5_sink::sptr block = fmcomms5_sink::make(uri, frequency1, 88 | frequency2, samplerate, bandwidth, rx1_en, 89 | rx1_en, rx2_en, rx2_en, rx3_en, rx3_en, 90 | rx4_en, rx4_en, buffer_size, cyclic, 91 | rf_port_select, attenuation1, attenuation2, 92 | attenuation3, attenuation4, 93 | filter); 94 | 95 | return gnuradio::get_initial_sptr( 96 | new fmcomms5_sink_f32c(rx1_en, rx2_en, rx3_en, rx4_en, block)); 97 | } 98 | 99 | void set_params(unsigned long long frequency1, 100 | unsigned long long frequency2, 101 | unsigned long samplerate, unsigned long bandwidth, 102 | const char *rf_port_select, double attenuation1, 103 | double attenuation2, double attenuation3, double attenuation4) 104 | { 105 | fmcomms5_block->set_params(frequency1, frequency2, 106 | samplerate, bandwidth, 107 | rf_port_select, attenuation1, attenuation2, 108 | attenuation3, attenuation4); 109 | } 110 | 111 | private: 112 | fmcomms5_sink::sptr fmcomms5_block; 113 | 114 | protected: 115 | explicit fmcomms5_sink_f32c(bool rx1_en, bool rx2_en, 116 | bool rx3_en, bool rx4_en, fmcomms5_sink::sptr block); 117 | }; 118 | 119 | } // namespace iio 120 | } // namespace gr 121 | 122 | #endif /* INCLUDED_IIO_FMCOMMS5_SINK_H */ 123 | -------------------------------------------------------------------------------- /include/gnuradio/iio/fmcomms5_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_FMCOMMS5_SOURCE_H 24 | #define INCLUDED_IIO_FMCOMMS5_SOURCE_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include "device_source.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | /*! 36 | * \brief <+description of block+> 37 | * \ingroup iio 38 | * 39 | */ 40 | class IIO_API fmcomms5_source : virtual public gr::sync_block 41 | { 42 | public: 43 | typedef boost::shared_ptr sptr; 44 | 45 | /*! 46 | * \brief Return a shared_ptr to a new instance of iio::device. 47 | * 48 | * To avoid accidental use of raw pointers, iio::device's 49 | * constructor is in a private implementation 50 | * class. iio::device::make is the public interface for 51 | * creating new instances. 52 | */ 53 | static sptr make(const std::string &uri, unsigned long long frequency1, 54 | unsigned long long frequency2, 55 | unsigned long samplerate, 56 | unsigned long bandwidth, 57 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 58 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 59 | unsigned long buffer_size, bool quadrature, bool rfdc, 60 | bool bbdc, const char *gain1, double gain1_value, 61 | const char *gain2, double gain2_value, 62 | const char *gain3, double gain3_value, 63 | const char *gain4, double gain4_value, 64 | const char *rf_port_select, const char *filter = ""); 65 | 66 | static sptr make_from(struct iio_context *ctx, 67 | unsigned long long frequency1, 68 | unsigned long long frequency2, unsigned long samplerate, 69 | unsigned long bandwidth, 70 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 71 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 72 | unsigned long buffer_size, bool quadrature, bool rfdc, 73 | bool bbdc, const char *gain1, double gain1_value, 74 | const char *gain2, double gain2_value, 75 | const char *gain3, double gain3_value, 76 | const char *gain4, double gain4_value, 77 | const char *rf_port_select, const char *filter = ""); 78 | 79 | virtual void set_params(unsigned long long frequency1, 80 | unsigned long long frequency2, 81 | unsigned long samplerate, unsigned long bandwidth, 82 | bool quadrature, bool rfdc, bool bbdc, 83 | const char *gain1, double gain1_value, 84 | const char *gain2, double gain2_value, 85 | const char *gain3, double gain3_value, 86 | const char *gain4, double gain4_value, 87 | const char *rf_port_select) = 0; 88 | }; 89 | 90 | class IIO_API fmcomms5_source_f32c : virtual public gr::hier_block2 91 | { 92 | public: 93 | typedef boost::shared_ptr sptr; 94 | 95 | static sptr make(const std::string &uri, 96 | unsigned long long frequency1, unsigned long long frequency2, 97 | unsigned long samplerate, 98 | unsigned long bandwidth, 99 | bool rx1_en, bool rx2_en, bool rx3_en, bool rx4_en, 100 | unsigned long buffer_size, bool quadrature, bool rfdc, 101 | bool bbdc, const char *gain1, double gain1_value, 102 | const char *gain2, double gain2_value, 103 | const char *gain3, double gain3_value, 104 | const char *gain4, double gain4_value, 105 | const char *rf_port_select, const char *filter = "") 106 | { 107 | fmcomms5_source::sptr block = fmcomms5_source::make(uri, 108 | frequency1, frequency2, samplerate, 109 | bandwidth, rx1_en, rx1_en, rx2_en, 110 | rx2_en, rx3_en, rx3_en, rx4_en, 111 | rx4_en, buffer_size, quadrature, 112 | rfdc, bbdc, gain1, gain1_value, 113 | gain2, gain2_value, gain3, gain3_value, 114 | gain4, gain4_value, rf_port_select, 115 | filter); 116 | 117 | return gnuradio::get_initial_sptr( 118 | new fmcomms5_source_f32c(rx1_en, rx2_en, rx3_en, rx4_en, block)); 119 | } 120 | 121 | void set_params(unsigned long long frequency1, 122 | unsigned long long frequency2, 123 | unsigned long samplerate, unsigned long bandwidth, 124 | bool quadrature, bool rfdc, bool bbdc, 125 | const char *gain1, double gain1_value, 126 | const char *gain2, double gain2_value, 127 | const char *gain3, double gain3_value, 128 | const char *gain4, double gain4_value, 129 | const char *rf_port_select) 130 | { 131 | fmcomms5_block->set_params(frequency1, frequency2, samplerate, bandwidth, 132 | quadrature, rfdc, bbdc, gain1, gain1_value, 133 | gain2, gain2_value, gain3, gain3_value, 134 | gain4, gain4_value, rf_port_select); 135 | } 136 | private: 137 | fmcomms5_source::sptr fmcomms5_block; 138 | 139 | protected: 140 | explicit fmcomms5_source_f32c(bool rx1_en, bool rx2_en, 141 | bool rx3_en, bool rx4_en, fmcomms5_source::sptr block); 142 | }; 143 | 144 | } // namespace iio 145 | } // namespace gr 146 | 147 | #endif /* INCLUDED_IIO_FMCOMMS5_SOURCE_H */ 148 | -------------------------------------------------------------------------------- /include/gnuradio/iio/math.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_MATH_H 24 | #define INCLUDED_IIO_MATH_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | class IIO_API iio_math : virtual public gr::hier_block2 32 | { 33 | public: 34 | typedef boost::shared_ptr sptr; 35 | 36 | static sptr make(const std::string &function, 37 | int ninputs = 1); 38 | }; 39 | 40 | class IIO_API iio_math_gen : virtual public gr::hier_block2 41 | { 42 | public: 43 | typedef boost::shared_ptr sptr; 44 | 45 | static sptr make(double sampling_freq, double wav_freq, 46 | const std::string &function); 47 | }; 48 | } 49 | } 50 | 51 | #endif /* INCLUDED_IIO_MATH_H */ 52 | -------------------------------------------------------------------------------- /include/gnuradio/iio/modulo_const_ff.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_GR_IIO_MODULO_CONST_FF_H 24 | #define INCLUDED_GR_IIO_MODULO_CONST_FF_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | class IIO_API modulo_const_ff : virtual public sync_block 32 | { 33 | public: 34 | typedef boost::shared_ptr sptr; 35 | 36 | static sptr make(float modulo, size_t vlen=1); 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif /* INCLUDED_GR_IIO_MODULO_CONST_FF_H */ 43 | -------------------------------------------------------------------------------- /include/gnuradio/iio/modulo_ff.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_GR_IIO_MODULO_FF_H 24 | #define INCLUDED_GR_IIO_MODULO_FF_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | class IIO_API modulo_ff : virtual public sync_block 32 | { 33 | public: 34 | typedef boost::shared_ptr sptr; 35 | 36 | static sptr make(size_t vlen=1); 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif /* INCLUDED_GR_IIO_MODULO_FF_H */ 43 | -------------------------------------------------------------------------------- /include/gnuradio/iio/pluto_sink.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_PLUTO_SINK_H 24 | #define INCLUDED_IIO_PLUTO_SINK_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | /*! 32 | * \brief Sink block for the PlutoSDR 33 | * \ingroup iio 34 | * 35 | */ 36 | class IIO_API pluto_sink : virtual public gr::hier_block2 37 | { 38 | public: 39 | typedef boost::shared_ptr sptr; 40 | 41 | static sptr make(const std::string &uri, 42 | unsigned long long frequency, 43 | unsigned long samplerate, 44 | unsigned long bandwidth, 45 | unsigned long buffer_size, 46 | bool cyclic, 47 | double attenuation, 48 | const char *filter = "", 49 | bool auto_filter = true); 50 | 51 | virtual void set_params(unsigned long long frequency, 52 | unsigned long samplerate, 53 | unsigned long bandwidth, 54 | double attenuation, 55 | const char *filter = "", 56 | bool auto_filter = true) = 0; 57 | }; 58 | 59 | } // namespace iio 60 | } // namespace gr 61 | 62 | #endif /* INCLUDED_IIO_PLUTO_SINK_H */ 63 | -------------------------------------------------------------------------------- /include/gnuradio/iio/pluto_source.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef INCLUDED_IIO_PLUTO_SOURCE_H 24 | #define INCLUDED_IIO_PLUTO_SOURCE_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | /*! 32 | * \brief Source block for the PlutoSDR 33 | * \ingroup iio 34 | * 35 | */ 36 | class IIO_API pluto_source : virtual public gr::hier_block2 37 | { 38 | public: 39 | typedef boost::shared_ptr sptr; 40 | 41 | static sptr make(const std::string &uri, 42 | unsigned long long frequency, 43 | unsigned long samplerate, 44 | unsigned long bandwidth, 45 | unsigned long buffer_size, 46 | bool quadrature, bool rfdc, 47 | bool bbdc, 48 | const char *gain, 49 | double gain_value, 50 | const char *filter = "", 51 | bool auto_filter = true); 52 | 53 | virtual void set_params(unsigned long long frequency, 54 | unsigned long samplerate, 55 | unsigned long bandwidth, 56 | bool quadrature, bool rfdc, bool bbdc, 57 | const char *gain, double gain_value, 58 | const char *filter = "", 59 | bool auto_filter = true) = 0; 60 | }; 61 | } // namespace iio 62 | } // namespace gr 63 | 64 | #endif /* INCLUDED_IIO_PLUTO_SOURCE_H */ 65 | -------------------------------------------------------------------------------- /include/gnuradio/iio/power_ff.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_GR_IIO_POWER_FF_H 24 | #define INCLUDED_GR_IIO_POWER_FF_H 25 | 26 | #include 27 | #include 28 | 29 | namespace gr { 30 | namespace iio { 31 | class IIO_API power_ff : virtual public sync_block 32 | { 33 | public: 34 | typedef boost::shared_ptr sptr; 35 | 36 | static sptr make(size_t vlen=1); 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif /* INCLUDED_GR_IIO_POWER_FF_H */ 43 | -------------------------------------------------------------------------------- /lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011,2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Setup library 22 | ######################################################################## 23 | include(GrPlatform) #define LIB_SUFFIX 24 | 25 | include_directories(${Boost_INCLUDE_DIR} ${IIO_INCLUDE_DIRS} ${AD9361_INCLUDE_DIRS}) 26 | link_directories(${Boost_LIBRARY_DIRS}) 27 | 28 | include(FindFLEX REQUIRED) 29 | find_package(BISON "3.0.2" REQUIRED) 30 | 31 | flex_target(lexer 32 | ${CMAKE_CURRENT_SOURCE_DIR}/iio_math_lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c) 33 | bison_target(parser 34 | ${CMAKE_CURRENT_SOURCE_DIR}/iio_math_parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c) 35 | 36 | list(APPEND iio_sources 37 | device_source_impl.cc 38 | device_sink_impl.cc 39 | fmcomms2_source_impl.cc 40 | fmcomms2_sink_impl.cc 41 | fmcomms5_source_impl.cc 42 | fmcomms5_sink_impl.cc 43 | pluto_source_impl.cc 44 | pluto_sink_impl.cc 45 | attr_sink_impl.cc 46 | attr_source_impl.cc 47 | converter_ss_impl.cc 48 | iio_math_impl.cc 49 | iio_math_gen_impl.cc 50 | iio_power_ff_impl.cc 51 | iio_modulo_ff_impl.cc 52 | iio_modulo_const_ff_impl.cc 53 | ${FLEX_lexer_OUTPUTS} 54 | ${BISON_parser_OUTPUTS} 55 | ) 56 | 57 | set(iio_sources "${iio_sources}" PARENT_SCOPE) 58 | if(NOT iio_sources) 59 | MESSAGE(STATUS "No C++ sources... skipping lib/") 60 | return() 61 | endif(NOT iio_sources) 62 | 63 | if ("${PC_GNURADIO_RUNTIME_VERSION}" VERSION_LESS 3.8.0) 64 | set(GR_IS_VERSION_3_7_OR_LESS ON) 65 | endif() 66 | 67 | option(COMPAT_GR_3_7_OR_LESS "Compile for GNU Radio version 3.7 or less" ${GR_IS_VERSION_3_7_OR_LESS}) 68 | if (COMPAT_GR_3_7_OR_LESS) 69 | add_definitions(-DGR_VERSION_3_7_OR_LESS) 70 | endif() 71 | 72 | add_library(gnuradio-iio SHARED ${iio_sources}) 73 | target_link_libraries(gnuradio-iio 74 | ${Boost_LIBRARIES} 75 | ${IIO_LIBRARIES} 76 | ${AD9361_LIBRARIES} 77 | ${GNURADIO_ALL_LIBRARIES}) 78 | set_target_properties(gnuradio-iio PROPERTIES 79 | VERSION ${GR_IIO_VERSION} 80 | SOVERSION ${GR_IIO_VERSION_MAJOR} 81 | DEFINE_SYMBOL "gnuradio_iio_EXPORTS" 82 | ) 83 | 84 | if(APPLE) 85 | set_target_properties(gnuradio-iio PROPERTIES 86 | INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" 87 | ) 88 | endif(APPLE) 89 | 90 | ######################################################################## 91 | # Install built library files 92 | ######################################################################## 93 | install(TARGETS gnuradio-iio 94 | LIBRARY DESTINATION ${GR_LIBRARY_DIR} # .so/.dylib file 95 | ARCHIVE DESTINATION ${GR_LIBRARY_DIR} # .lib file 96 | RUNTIME DESTINATION ${GR_RUNTIME_DIR} # .dll file 97 | ) 98 | 99 | 100 | ######################################################################## 101 | # Setup the include and linker paths 102 | ######################################################################## 103 | #include_directories( 104 | # ${GR_IIO_INCLUDE_DIRS} 105 | # ${GNURADIO_RUNTIME_INCLUDE_DIRS} 106 | # ${Boost_INCLUDE_DIRS} 107 | -------------------------------------------------------------------------------- /lib/attr_sink_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2018 Analog Devices Inc. 4 | * Author: Travis Collins 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include "attr_sink_impl.h" 28 | #include 29 | #include 30 | #include 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | attr_sink::sptr 36 | attr_sink::make(const std::string &uri, const std::string &device, 37 | const std::string &channel, int type, bool output, bool required_enable) 38 | { 39 | return gnuradio::get_initial_sptr 40 | (new attr_sink_impl(uri, device, channel, type, output, required_enable)); 41 | } 42 | 43 | /* 44 | * The private constructor 45 | */ 46 | attr_sink_impl::attr_sink_impl(const std::string &uri, const std::string &device, 47 | const std::string &channel, int type, bool output, bool required_enable) 48 | : gr::block("attr_sink", 49 | gr::io_signature::make(0, 0, 0), 50 | gr::io_signature::make(0, 0, 0)), 51 | device(device), 52 | channel(channel), 53 | uri(uri), 54 | type(type), 55 | output(output), 56 | required_enable(required_enable) 57 | { 58 | 59 | ctx = device_source_impl::get_context(uri); 60 | if (!ctx) 61 | throw std::runtime_error("Unable to create context"); 62 | 63 | dev = iio_context_find_device(ctx, device.c_str()); 64 | if (!dev) { 65 | iio_context_destroy(ctx); 66 | throw std::runtime_error("Device not found"); 67 | } 68 | 69 | if (type==0) 70 | { 71 | chan = iio_device_find_channel(dev, channel.c_str(), output); 72 | if (!chan) { 73 | iio_context_destroy(ctx); 74 | throw std::runtime_error("Channel not found"); 75 | } 76 | } 77 | 78 | // Required for MathWorks generated IP 79 | if ((type==4) && required_enable) 80 | { 81 | // int ret = iio_device_debug_attr_write(dev, "direct_reg_access", "enabled"); 82 | int ret = iio_device_attr_write(dev, "reg_access", "enabled"); 83 | 84 | if (ret < 0) { 85 | char error[1024]; 86 | sprintf(error, "Failed to enabled register for device: %s [%d]", device.c_str(), ret); 87 | throw std::runtime_error(error); 88 | } 89 | } 90 | 91 | message_port_register_in(pmt::mp("attr")); 92 | set_msg_handler(pmt::mp("attr"), boost::bind(&attr_sink_impl::write_attribute, this, boost::placeholders::_1)); 93 | 94 | } 95 | 96 | /* 97 | * Our virtual destructor. 98 | */ 99 | attr_sink_impl::~attr_sink_impl() 100 | { 101 | } 102 | 103 | void 104 | attr_sink_impl::write_attribute(pmt::pmt_t pdu) 105 | { 106 | int ret = 0; 107 | uint16_t k; 108 | std::string value, attribute; 109 | pmt::pmt_t keys; 110 | 111 | if (!is_dict(pdu)) 112 | throw std::runtime_error("Message not a dictionary!\n"); 113 | 114 | keys = pmt::dict_keys(pdu); 115 | 116 | for (k=0; k(attribute); 137 | uint32_t value32 = boost::lexical_cast(value); 138 | ret = iio_device_reg_write(dev, address, value32); 139 | } 140 | catch (const boost::bad_lexical_cast &e) 141 | { 142 | std::cerr << e.what() << '\n'; 143 | } 144 | break; 145 | } 146 | 147 | if (ret < 0) { 148 | char error[1024]; 149 | sprintf(error, "Attribute write '%s' failed to %s:%s:%s\n", value.c_str(), 150 | device.c_str(), channel.c_str(), attribute.c_str()); 151 | throw std::runtime_error(error); 152 | } 153 | } 154 | } 155 | 156 | 157 | } /* namespace iio */ 158 | } /* namespace gr */ 159 | -------------------------------------------------------------------------------- /lib/attr_sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2018 Analog Devices Inc. 4 | * Author: Travis Collins 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_ATTR_SINK_IMPL_H 23 | #define INCLUDED_IIO_ATTR_SINK_IMPL_H 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "device_source_impl.h" 30 | 31 | namespace gr { 32 | namespace iio { 33 | 34 | class attr_sink_impl : public attr_sink 35 | { 36 | private: 37 | std::string device; 38 | std::string channel; 39 | std::string uri; 40 | int type; 41 | bool output; 42 | bool required_enable; 43 | 44 | protected: 45 | struct iio_context *ctx; 46 | struct iio_device *dev; 47 | struct iio_channel * chan; 48 | 49 | public: 50 | attr_sink_impl(const std::string &uri, const std::string &device, 51 | const std::string &channel, int type, bool output, bool required_enable); 52 | ~attr_sink_impl(); 53 | 54 | void write_attribute(pmt::pmt_t pdu); 55 | }; 56 | 57 | } // namespace iio 58 | } // namespace gr 59 | 60 | #endif /* INCLUDED_IIO_ATTR_SINK_IMPL_H */ 61 | -------------------------------------------------------------------------------- /lib/attr_source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2018 Analog Devices Inc. 4 | * Author: Travis Collins 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_ATTR_SOURCE_IMPL_H 23 | #define INCLUDED_IIO_ATTR_SOURCE_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include "device_source_impl.h" 29 | 30 | namespace gr { 31 | namespace iio { 32 | 33 | class attr_source_impl : public attr_source 34 | { 35 | private: 36 | std::string device; 37 | std::string channel; 38 | std::string uri; 39 | std::string attribute; 40 | int update_interval_ms; 41 | int samples_per_update; 42 | int data_type; 43 | int attr_type; 44 | int m_attr_type; 45 | bool output; 46 | int ret; 47 | uint32_t address; 48 | bool required_enable; 49 | 50 | protected: 51 | struct iio_context *ctx; 52 | struct iio_device *dev; 53 | struct iio_channel * chan; 54 | 55 | public: 56 | attr_source_impl(const std::string &uri, const std::string &device, const std::string &channel, 57 | const std::string &attribute, int update_interval_ms, int samples_per_update, 58 | int data_type, int attr_type, bool output, uint32_t address, bool required_enable); 59 | ~attr_source_impl(); 60 | 61 | // Where all the action really happens 62 | int work(int noutput_items, 63 | gr_vector_const_void_star &input_items, 64 | gr_vector_void_star &output_items); 65 | 66 | size_t type_sizeof(int data_type, int attr_type); 67 | void get_attribute_data(const std::string& attribute, double* value); 68 | void get_attribute_data(const std::string& attribute, float* value); 69 | void get_attribute_data(const std::string& attribute, long long* value); 70 | void get_attribute_data(const std::string& attribute, int* value); 71 | void get_attribute_data(const std::string& attribute, uint8_t* value); 72 | void get_register_data(uint32_t address, int* value); 73 | void check(int ret); 74 | 75 | }; 76 | 77 | } // namespace iio 78 | } // namespace gr 79 | 80 | #endif /* INCLUDED_IIO_ATTR_SOURCE_IMPL_H */ 81 | -------------------------------------------------------------------------------- /lib/converter_ss_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "converter_ss_impl.h" 23 | 24 | #include 25 | 26 | using namespace gr::iio; 27 | 28 | converter_ss::sptr converter_ss::make(const struct iio_channel *chn, bool inv) 29 | { 30 | return gnuradio::get_initial_sptr(new converter_ss_impl(chn, inv)); 31 | } 32 | 33 | converter_ss_impl::converter_ss_impl(const struct iio_channel *_chn, bool inv) : 34 | gr::sync_block("iio_converter_ss", 35 | gr::io_signature::make(1, 1, sizeof(short)), 36 | gr::io_signature::make(1, 1, sizeof(short))), 37 | chn(_chn), inverse(inv) 38 | { 39 | } 40 | 41 | converter_ss_impl::~converter_ss_impl() 42 | { 43 | } 44 | 45 | int converter_ss_impl::work(int noutput_items, 46 | gr_vector_const_void_star &input_items, 47 | gr_vector_void_star &output_items) 48 | { 49 | if (inverse) 50 | for (int i = 0; i < noutput_items; i++) 51 | iio_channel_convert_inverse(chn, 52 | &((short *)output_items[0])[i], 53 | &((const short *)input_items[0])[i]); 54 | else 55 | for (int i = 0; i < noutput_items; i++) 56 | iio_channel_convert(chn, &((short *)output_items[0])[i], 57 | &((const short *)input_items[0])[i]); 58 | 59 | consume(0, noutput_items); 60 | return noutput_items; 61 | } 62 | -------------------------------------------------------------------------------- /lib/converter_ss_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_CONVERTER_SS_IMPL_H 23 | #define INCLUDED_IIO_CONVERTER_SS_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | namespace gr { 29 | namespace iio { 30 | class converter_ss_impl : public converter_ss 31 | { 32 | private: 33 | const struct iio_channel *chn; 34 | bool inverse; 35 | 36 | public: 37 | converter_ss_impl(const struct iio_channel *channel, 38 | bool inverse); 39 | ~converter_ss_impl(); 40 | 41 | int work(int noutput_items, 42 | gr_vector_const_void_star &input_items, 43 | gr_vector_void_star &output_items); 44 | }; 45 | } 46 | } 47 | 48 | #endif /* INCLUDED_IIO_CONVERTER_SS_IMPL_H */ 49 | -------------------------------------------------------------------------------- /lib/device_sink_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | #include "device_sink_impl.h" 28 | #include "device_source_impl.h" 29 | 30 | #include 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | device_sink::sptr 36 | device_sink::make(const std::string &uri, const std::string &device, 37 | const std::vector &channels, 38 | const std::string &device_phy, 39 | const std::vector ¶ms, 40 | unsigned int buffer_size, unsigned int interpolation, 41 | bool cyclic) 42 | { 43 | return gnuradio::get_initial_sptr 44 | (new device_sink_impl(device_source_impl::get_context(uri), true, 45 | device, channels, device_phy, params, 46 | buffer_size, interpolation, cyclic)); 47 | } 48 | 49 | device_sink::sptr 50 | device_sink::make_from(struct iio_context *ctx, const std::string &device, 51 | const std::vector &channels, 52 | const std::string &device_phy, 53 | const std::vector ¶ms, 54 | unsigned int buffer_size, unsigned int interpolation, 55 | bool cyclic) 56 | { 57 | return gnuradio::get_initial_sptr 58 | (new device_sink_impl(ctx, false, device, channels, 59 | device_phy, params, 60 | buffer_size, interpolation, cyclic)); 61 | } 62 | 63 | void device_sink_impl::set_params(const std::vector ¶ms) 64 | { 65 | device_source_impl::set_params(this->phy, params); 66 | } 67 | 68 | /* 69 | * The private constructor 70 | */ 71 | device_sink_impl::device_sink_impl(struct iio_context *ctx, 72 | bool destroy_ctx, const std::string &device, 73 | const std::vector &channels, 74 | const std::string &device_phy, 75 | const std::vector ¶ms, 76 | unsigned int buffer_size, unsigned int interpolation, 77 | bool cyclic) 78 | : gr::sync_block("device_sink", 79 | gr::io_signature::make(1, -1, sizeof(short)), 80 | gr::io_signature::make(0, 0, 0)), 81 | ctx(ctx), 82 | interpolation(interpolation), 83 | buffer_size(buffer_size), 84 | destroy_ctx(destroy_ctx) 85 | { 86 | unsigned int nb_channels, i; 87 | unsigned short vid, pid; 88 | 89 | /* Set minimum input size */ 90 | set_output_multiple(buffer_size / (interpolation + 1)); 91 | 92 | if (!ctx) 93 | throw std::runtime_error("Unable to create context"); 94 | 95 | dev = iio_context_find_device(ctx, device.c_str()); 96 | phy = iio_context_find_device(ctx, device_phy.c_str()); 97 | if (!dev || !phy) { 98 | if (destroy_ctx) 99 | iio_context_destroy(ctx); 100 | throw std::runtime_error("Device not found"); 101 | } 102 | 103 | /* First disable all channels */ 104 | nb_channels = iio_device_get_channels_count(dev); 105 | for (i = 0; i < nb_channels; i++) 106 | iio_channel_disable(iio_device_get_channel(dev, i)); 107 | 108 | if (channels.empty()) { 109 | for (i = 0; i < nb_channels; i++) { 110 | struct iio_channel *chn = 111 | iio_device_get_channel(dev, i); 112 | 113 | iio_channel_enable(chn); 114 | channel_list.push_back(chn); 115 | } 116 | } else { 117 | for (std::vector::const_iterator it = 118 | channels.begin(); 119 | it != channels.end(); ++it) { 120 | struct iio_channel *chn = 121 | iio_device_find_channel(dev, 122 | it->c_str(), true); 123 | if (!chn) { 124 | if (destroy_ctx) 125 | iio_context_destroy(ctx); 126 | throw std::runtime_error( 127 | "Channel not found"); 128 | } 129 | 130 | iio_channel_enable(chn); 131 | if (!iio_channel_is_enabled(chn)) 132 | throw std::runtime_error( 133 | "Channel not enabled"); 134 | channel_list.push_back(chn); 135 | } 136 | } 137 | 138 | set_params(params); 139 | 140 | buf = iio_device_create_buffer(dev, buffer_size, cyclic); 141 | if (!buf) 142 | throw std::runtime_error("Unable to create buffer: " + boost::to_string(-errno)); 143 | } 144 | 145 | /* 146 | * Our virtual destructor. 147 | */ 148 | device_sink_impl::~device_sink_impl() 149 | { 150 | iio_buffer_destroy(buf); 151 | device_source_impl::remove_ctx_history(ctx,destroy_ctx); 152 | } 153 | 154 | void 155 | device_sink_impl::channel_write(const struct iio_channel *chn, 156 | const void *src, size_t len) 157 | { 158 | uintptr_t dst_ptr, src_ptr = (uintptr_t) src, end = src_ptr + len; 159 | unsigned int length = iio_channel_get_data_format(chn)->length / 8; 160 | uintptr_t buf_end = (uintptr_t) iio_buffer_end(buf); 161 | ptrdiff_t buf_step = iio_buffer_step(buf) * (interpolation + 1); 162 | 163 | for (dst_ptr = (uintptr_t) iio_buffer_first(buf, chn); 164 | dst_ptr < buf_end && src_ptr + length <= end; 165 | dst_ptr += buf_step, src_ptr += length) 166 | iio_channel_convert_inverse(chn, 167 | (void *) dst_ptr, (const void *) src_ptr); 168 | } 169 | 170 | int 171 | device_sink_impl::work(int noutput_items, 172 | gr_vector_const_void_star &input_items, 173 | gr_vector_void_star &output_items) 174 | { 175 | int ret; 176 | 177 | if (interpolation >= 1) { 178 | ptrdiff_t len = (intptr_t) iio_buffer_end(buf) 179 | - (intptr_t) iio_buffer_start(buf); 180 | memset(iio_buffer_start(buf), 0, len); 181 | } 182 | 183 | for (unsigned int i = 0; i < input_items.size(); i++) 184 | channel_write(channel_list[i], input_items[i], 185 | noutput_items * sizeof(short)); 186 | 187 | ret = iio_buffer_push(buf); 188 | if (ret < 0) { 189 | char buf[256]; 190 | iio_strerror(-ret, buf, sizeof(buf)); 191 | std::string error(buf); 192 | 193 | std::cerr << "Unable to push buffer: " << error << std::endl; 194 | return -1; /* EOF */ 195 | } 196 | 197 | consume_each(buffer_size / (interpolation + 1)); 198 | return 0; 199 | } 200 | 201 | void 202 | device_sink_impl::forecast(int noutput_items, 203 | gr_vector_int &ninput_items_required) 204 | { 205 | for (unsigned int i = 0; i < ninput_items_required.size(); i++) 206 | ninput_items_required[i] = noutput_items; 207 | } 208 | 209 | } /* namespace iio */ 210 | } /* namespace gr */ 211 | -------------------------------------------------------------------------------- /lib/device_sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_DEVICE_SINK_IMPL_H 23 | #define INCLUDED_IIO_DEVICE_SINK_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | namespace gr { 32 | namespace iio { 33 | 34 | class device_sink_impl : public device_sink 35 | { 36 | private: 37 | void channel_write(const struct iio_channel *chn, 38 | const void *src, size_t len); 39 | 40 | protected: 41 | struct iio_context *ctx; 42 | struct iio_device *dev, *phy; 43 | struct iio_buffer *buf; 44 | std::vector channel_list; 45 | unsigned int buffer_size; 46 | unsigned int interpolation; 47 | bool destroy_ctx; 48 | 49 | public: 50 | device_sink_impl(struct iio_context *ctx, bool destroy_ctx, 51 | const std::string &device, 52 | const std::vector &channels, 53 | const std::string &device_phy, 54 | const std::vector ¶ms, 55 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 56 | unsigned int interpolation = 0, 57 | bool cyclic = false); 58 | ~device_sink_impl(); 59 | 60 | void set_params(const std::vector ¶ms); 61 | 62 | // Where all the action really happens 63 | int work(int noutput_items, 64 | gr_vector_const_void_star &input_items, 65 | gr_vector_void_star &output_items); 66 | 67 | void forecast(int noutput_items, gr_vector_int &ninput_items_required); 68 | }; 69 | 70 | } // namespace iio 71 | } // namespace gr 72 | 73 | #endif /* INCLUDED_IIO_DEVICE_SINK_IMPL_H */ 74 | -------------------------------------------------------------------------------- /lib/device_source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_DEVICE_SOURCE_IMPL_H 23 | #define INCLUDED_IIO_DEVICE_SOURCE_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | struct ctxInfo{std::string uri; struct iio_context * ctx; int count;}; 36 | static std::vector contexts; 37 | static boost::mutex ctx_mutex; 38 | 39 | typedef std::vector::iterator ctx_it; 40 | 41 | class device_source_impl : public device_source 42 | { 43 | private: 44 | void channel_read(const struct iio_channel *chn, 45 | void *dst, size_t len); 46 | 47 | boost::mutex iio_mutex; 48 | boost::condition_variable iio_cond, iio_cond2; 49 | unsigned long items_in_buffer; 50 | off_t byte_offset; 51 | volatile bool please_refill_buffer, thread_stopped; 52 | pmt::pmt_t port_id; 53 | 54 | boost::thread refill_thd; 55 | 56 | unsigned long timeout; 57 | 58 | void refill_thread(); 59 | 60 | protected: 61 | struct iio_context *ctx; 62 | struct iio_device *dev, *phy; 63 | struct iio_buffer *buf; 64 | std::vector channel_list; 65 | unsigned int buffer_size; 66 | unsigned int decimation; 67 | bool destroy_ctx; 68 | 69 | public: 70 | device_source_impl(struct iio_context *ctx, bool destroy_ctx, 71 | const std::string &device, 72 | const std::vector &channels, 73 | const std::string &device_phy, 74 | const std::vector ¶ms, 75 | unsigned int buffer_size = DEFAULT_BUFFER_SIZE, 76 | unsigned int decimation = 0); 77 | ~device_source_impl(); 78 | 79 | static void set_params(struct iio_device *phy, 80 | const std::vector ¶ms); 81 | 82 | void set_params(const std::vector ¶ms); 83 | void set_buffer_size(unsigned int buffer_size); 84 | void set_timeout_ms(unsigned long timeout); 85 | 86 | // Where all the action really happens 87 | int work(int noutput_items, 88 | gr_vector_const_void_star &input_items, 89 | gr_vector_void_star &output_items); 90 | 91 | bool start(); 92 | bool stop(); 93 | 94 | static void remove_ctx_history(struct iio_context *ctx, bool destroy_ctx); 95 | 96 | static struct iio_context * get_context(const std::string &uri); 97 | static bool load_fir_filter(std::string &filter, struct iio_device *phy); 98 | }; 99 | 100 | } // namespace iio 101 | } // namespace gr 102 | 103 | #endif /* INCLUDED_IIO_DEVICE_SOURCE_IMPL_H */ 104 | -------------------------------------------------------------------------------- /lib/fmcomms2_sink_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include 27 | 28 | #include 29 | #include "fmcomms2_sink_impl.h" 30 | #include "device_source_impl.h" 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | using namespace gr::blocks; 38 | 39 | namespace gr { 40 | namespace iio { 41 | 42 | fmcomms2_sink_f32c::fmcomms2_sink_f32c(bool tx1_en, bool tx2_en, 43 | fmcomms2_sink::sptr sink_block) : 44 | hier_block2("fmcomms2_sink_f32c", 45 | io_signature::make( 46 | (int) tx1_en + (int) tx2_en, 47 | (int) tx1_en + (int) tx2_en, 48 | sizeof(gr_complex)), 49 | io_signature::make(0, 0, 0)), 50 | fmcomms2_block(sink_block) 51 | { 52 | basic_block_sptr hier = shared_from_this(); 53 | unsigned int num_streams = (int) tx1_en + (int) tx2_en; 54 | 55 | for (unsigned int i = 0; i < num_streams; i++) { 56 | float_to_short::sptr f2s1 = float_to_short::make(1, 32768.0); 57 | float_to_short::sptr f2s2 = float_to_short::make(1, 32768.0); 58 | complex_to_float::sptr c2f = complex_to_float::make(); 59 | 60 | connect(hier, i, c2f, 0); 61 | connect(c2f, 0, f2s1, 0); 62 | connect(c2f, 1, f2s2, 0); 63 | connect(f2s1, 0, sink_block, i * 2); 64 | connect(f2s2, 0, sink_block, i * 2 + 1); 65 | } 66 | } 67 | 68 | fmcomms2_sink::sptr 69 | fmcomms2_sink::make(const std::string &uri, unsigned long long frequency, 70 | unsigned long samplerate, 71 | unsigned long bandwidth, 72 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 73 | unsigned long buffer_size, bool cyclic, 74 | const char *rf_port_select, double attenuation1, 75 | double attenuation2, const char *filter, bool auto_filter) 76 | { 77 | return gnuradio::get_initial_sptr( 78 | new fmcomms2_sink_impl(device_source_impl::get_context(uri), true, 79 | frequency, samplerate, bandwidth, ch1_en, 80 | ch2_en, ch3_en, ch4_en, buffer_size, cyclic, rf_port_select, 81 | attenuation1, attenuation2, filter, auto_filter)); 82 | } 83 | 84 | fmcomms2_sink::sptr 85 | fmcomms2_sink::make_from(struct iio_context *ctx, 86 | unsigned long long frequency, unsigned long samplerate, 87 | unsigned long bandwidth, 88 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 89 | unsigned long buffer_size, bool cyclic, 90 | const char *rf_port_select, double attenuation1, 91 | double attenuation2, const char *filter, bool auto_filter) 92 | { 93 | return gnuradio::get_initial_sptr( 94 | new fmcomms2_sink_impl(ctx, false, frequency, samplerate, 95 | bandwidth, ch1_en, ch2_en, ch3_en, ch4_en, 96 | buffer_size, cyclic, rf_port_select, 97 | attenuation1, attenuation2, filter, auto_filter)); 98 | } 99 | 100 | std::vector fmcomms2_sink_impl::get_channels_vector( 101 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en) 102 | { 103 | std::vector channels; 104 | if (ch1_en) 105 | channels.push_back("voltage0"); 106 | if (ch2_en) 107 | channels.push_back("voltage1"); 108 | if (ch3_en) 109 | channels.push_back("voltage2"); 110 | if (ch4_en) 111 | channels.push_back("voltage3"); 112 | return channels; 113 | } 114 | 115 | fmcomms2_sink_impl::fmcomms2_sink_impl(struct iio_context *ctx, 116 | bool destroy_ctx, 117 | unsigned long long frequency, unsigned long samplerate, 118 | unsigned long bandwidth, 119 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 120 | unsigned long buffer_size, bool cyclic, 121 | const char *rf_port_select, double attenuation1, 122 | double attenuation2, const char *filter, bool auto_filter) 123 | : gr::sync_block("fmcomms2_sink", 124 | gr::io_signature::make(1, -1, sizeof(short)), 125 | gr::io_signature::make(0, 0, 0)), 126 | device_sink_impl(ctx, destroy_ctx, "cf-ad9361-dds-core-lpc", 127 | get_channels_vector(ch1_en, ch2_en, ch3_en, ch4_en), 128 | "ad9361-phy", std::vector(), 129 | buffer_size, 0, cyclic), 130 | cyclic(cyclic) 131 | { 132 | set_params(frequency, samplerate, bandwidth, rf_port_select, 133 | attenuation1, attenuation2, filter, auto_filter); 134 | } 135 | 136 | void fmcomms2_sink_impl::set_params(unsigned long long frequency, 137 | unsigned long samplerate, unsigned long bandwidth, 138 | const char *rf_port_select, double attenuation1, 139 | double attenuation2, const char *filter, bool auto_filter) 140 | { 141 | bool is_fmcomms4 = !iio_device_find_channel(phy, "voltage1", false); 142 | std::vector params; 143 | 144 | if (filter && filter[0]) 145 | auto_filter = false; 146 | 147 | params.push_back("out_altvoltage1_TX_LO_frequency=" + 148 | boost::to_string(frequency)); 149 | if (!auto_filter) { 150 | params.push_back("out_voltage_sampling_frequency=" + 151 | boost::to_string(samplerate)); 152 | } 153 | params.push_back("out_voltage_rf_bandwidth=" + 154 | boost::to_string(bandwidth)); 155 | params.push_back("out_voltage0_rf_port_select=" + 156 | boost::to_string(rf_port_select)); 157 | params.push_back("out_voltage0_hardwaregain=" + 158 | boost::to_string(-attenuation1)); 159 | 160 | if (!is_fmcomms4) { 161 | params.push_back("out_voltage1_hardwaregain=" + 162 | boost::to_string(-attenuation2)); 163 | } 164 | 165 | device_source_impl::set_params(this->phy, params); 166 | 167 | if (auto_filter) { 168 | int ret = ad9361_set_bb_rate(phy, samplerate); 169 | if (ret) { 170 | throw std::runtime_error("Unable to set BB rate"); 171 | } 172 | } else if (filter && filter[0]) { 173 | std::string f(filter); 174 | if (!device_source_impl::load_fir_filter(f, phy)) 175 | throw std::runtime_error("Unable to load filter file"); 176 | } 177 | } 178 | 179 | int fmcomms2_sink_impl::work(int noutput_items, 180 | gr_vector_const_void_star &input_items, 181 | gr_vector_void_star &output_items) 182 | { 183 | int ret = device_sink_impl::work(noutput_items, input_items, 184 | output_items); 185 | if (ret < 0 || !cyclic) 186 | return ret; 187 | else 188 | return WORK_DONE; 189 | } 190 | } /* namespace iio */ 191 | } /* namespace gr */ 192 | -------------------------------------------------------------------------------- /lib/fmcomms2_sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_FMCOMMS2_SINK_IMPL_H 23 | #define INCLUDED_IIO_FMCOMMS2_SINK_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "device_sink_impl.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class fmcomms2_sink_impl : public fmcomms2_sink, public device_sink_impl 36 | { 37 | private: 38 | bool cyclic; 39 | 40 | std::vector get_channels_vector( 41 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en); 42 | 43 | public: 44 | fmcomms2_sink_impl(struct iio_context *ctx, bool destroy_ctx, 45 | unsigned long long frequency, unsigned long samplerate, 46 | unsigned long bandwidth, 47 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 48 | unsigned long buffer_size, bool cyclic, 49 | const char *rf_port_select, double attenuation1, 50 | double attenuation2, const char *filter, 51 | bool auto_filter); 52 | 53 | int work(int noutput_items, 54 | gr_vector_const_void_star &input_items, 55 | gr_vector_void_star &output_items); 56 | 57 | void set_params(unsigned long long frequency, 58 | unsigned long samplerate, unsigned long bandwidth, 59 | const char *rf_port_select, double attenuation1, 60 | double attenuation2, const char *filter, 61 | bool auto_filter); 62 | }; 63 | 64 | } // namespace iio 65 | } // namespace gr 66 | 67 | #endif /* INCLUDED_IIO_FMCOMMS2_SINK_IMPL_H */ 68 | -------------------------------------------------------------------------------- /lib/fmcomms2_source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H 23 | #define INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "device_source_impl.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class fmcomms2_source_impl : public fmcomms2_source 36 | , public device_source_impl 37 | { 38 | private: 39 | std::vector get_channels_vector( 40 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en); 41 | 42 | public: 43 | fmcomms2_source_impl(struct iio_context *ctx, bool destroy_ctx, 44 | unsigned long long frequency, unsigned long samplerate, 45 | unsigned long bandwidth, 46 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 47 | unsigned long buffer_size, bool quadrature, bool rfdc, 48 | bool bbdc, const char *gain1, double gain1_value, 49 | const char *gain2, double gain2_value, 50 | const char *rf_port_select, const char *filter, 51 | bool auto_filter); 52 | 53 | void set_params(unsigned long long frequency, 54 | unsigned long samplerate, unsigned long bandwidth, 55 | bool quadrature, bool rfdc, bool bbdc, 56 | const char *gain1, double gain1_value, 57 | const char *gain2, double gain2_value, 58 | const char *rf_port_select, 59 | const char *filter, 60 | bool auto_filter); 61 | }; 62 | 63 | } // namespace iio 64 | } // namespace gr 65 | 66 | #endif /* INCLUDED_IIO_FMCOMMS2_SOURCE_IMPL_H */ 67 | -------------------------------------------------------------------------------- /lib/fmcomms5_sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_FMCOMMS5_SINK_IMPL_H 23 | #define INCLUDED_IIO_FMCOMMS5_SINK_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "device_sink_impl.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class fmcomms5_sink_impl : public fmcomms5_sink, public device_sink_impl 36 | { 37 | private: 38 | bool cyclic; 39 | unsigned long samplerate; 40 | struct iio_device *phy2; 41 | 42 | static void set_params(struct iio_device *phy_device, 43 | unsigned long long frequency, unsigned long samplerate, 44 | unsigned long bandwidth, const char *rf_port_select, 45 | double attenuation1, double attenuation2); 46 | 47 | std::vector get_channels_vector( 48 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 49 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en); 50 | 51 | public: 52 | fmcomms5_sink_impl(struct iio_context *ctx, bool destroy_ctx, 53 | unsigned long long frequency1, 54 | unsigned long long frequency2, unsigned long samplerate, 55 | unsigned long bandwidth, 56 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 57 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 58 | unsigned long buffer_size, bool cyclic, 59 | const char *rf_port_select, 60 | double attenuation1, double attenuation2, 61 | double attenuation3, double attenuation4, 62 | const char *filter); 63 | 64 | int work(int noutput_items, 65 | gr_vector_const_void_star &input_items, 66 | gr_vector_void_star &output_items); 67 | 68 | void set_params(unsigned long long frequency1, 69 | unsigned long long frequency2, unsigned long samplerate, 70 | unsigned long bandwidth, const char *rf_port_select, 71 | double attenuation1, double attenuation2, 72 | double attenuation3, double attenuation4); 73 | }; 74 | 75 | } // namespace iio 76 | } // namespace gr 77 | 78 | #endif /* INCLUDED_IIO_FMCOMMS2_SINK_IMPL_H */ 79 | -------------------------------------------------------------------------------- /lib/fmcomms5_source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2014 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_FMCOMMS5_SOURCE_IMPL_H 23 | #define INCLUDED_IIO_FMCOMMS5_SOURCE_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include "device_source_impl.h" 31 | 32 | namespace gr { 33 | namespace iio { 34 | 35 | class fmcomms5_source_impl : public fmcomms5_source 36 | , public device_source_impl 37 | { 38 | private: 39 | unsigned long samplerate; 40 | struct iio_device *phy2; 41 | 42 | static void set_params(struct iio_device *phy_device, 43 | unsigned long long frequency, 44 | unsigned long samplerate, unsigned long bandwidth, 45 | bool quadrature, bool rfdc, bool bbdc, 46 | const char *gain1, double gain1_value, 47 | const char *gain2, double gain2_value, 48 | const char *port_select); 49 | 50 | std::vector get_channels_vector( 51 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 52 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en); 53 | 54 | public: 55 | fmcomms5_source_impl(struct iio_context *ctx, 56 | bool destroy_ctx, unsigned long long frequency1, 57 | unsigned long long frequency2, unsigned long samplerate, 58 | unsigned long bandwidth, 59 | bool ch1_en, bool ch2_en, bool ch3_en, bool ch4_en, 60 | bool ch5_en, bool ch6_en, bool ch7_en, bool ch8_en, 61 | unsigned long buffer_size, bool quadrature, bool rfdc, 62 | bool bbdc, const char *gain1, double gain1_value, 63 | const char *gain2, double gain2_value, 64 | const char *gain3, double gain3_value, 65 | const char *gain4, double gain4_value, 66 | const char *rf_port_select, const char *filter); 67 | 68 | void set_params(unsigned long long frequency1, 69 | unsigned long long frequency2, 70 | unsigned long samplerate, unsigned long bandwidth, 71 | bool quadrature, bool rfdc, bool bbdc, 72 | const char *gain1, double gain1_value, 73 | const char *gain2, double gain2_value, 74 | const char *gain3, double gain3_value, 75 | const char *gain4, double gain4_value, 76 | const char *rf_port_select); 77 | }; 78 | 79 | } // namespace iio 80 | } // namespace gr 81 | 82 | #endif /* INCLUDED_IIO_FMCOMMS5_SOURCE_IMPL_H */ 83 | -------------------------------------------------------------------------------- /lib/iio_math_gen_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #define _USE_MATH_DEFINES 27 | #include 28 | 29 | #include "iio_math_impl.h" 30 | #ifdef GR_VERSION_3_7_OR_LESS 31 | #include 32 | #else 33 | #include 34 | #endif 35 | #include 36 | #include 37 | 38 | using namespace gr; 39 | using namespace gr::iio; 40 | 41 | iio_math_gen::sptr iio_math_gen::make(double sampling_freq, double wav_freq, 42 | const std::string &function) 43 | { 44 | return gnuradio::get_initial_sptr(new iio_math_gen_impl( 45 | sampling_freq, wav_freq, function)); 46 | } 47 | 48 | iio_math_gen_impl::iio_math_gen_impl(double sampling_freq, double wav_freq, 49 | const std::string &function) : hier_block2("math_gen", 50 | io_signature::make(0, 0, 0), 51 | io_signature::make(1, 1, sizeof(float))) 52 | { 53 | src_block = analog::sig_source_f::make(sampling_freq / wav_freq, 54 | analog::GR_SAW_WAVE, 1, 2.0 * M_PI, -M_PI); 55 | 56 | int ret = parse_function(function); 57 | if (ret) 58 | throw std::runtime_error("Invalid function"); 59 | 60 | cleanup(); 61 | src_block.reset(); 62 | } 63 | 64 | gr::basic_block_sptr iio_math_gen_impl::get_src_block() 65 | { 66 | return src_block; 67 | } 68 | 69 | void iio_math_gen_impl::connect_to_output(gr::basic_block_sptr block, unsigned int port) 70 | { 71 | basic_block_sptr hier = shared_from_this(); 72 | 73 | connect(block, 0, hier, 0); 74 | } 75 | -------------------------------------------------------------------------------- /lib/iio_math_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_GR_IIO_MATH_IMPL_H 23 | #define INCLUDED_GR_IIO_MATH_IMPL_H 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | extern "C" { 31 | #include "parser.h" 32 | 33 | int yyparse(yyscan_t scanner); 34 | void *yy_scan_string(const char *str, yyscan_t scanner); 35 | void yy_delete_buffer(void *buf, yyscan_t scanner); 36 | } 37 | 38 | namespace gr { 39 | namespace iio { 40 | class iio_math_impl : public iio_math 41 | { 42 | public: 43 | iio_math_impl(const std::string &function, int ninputs); 44 | ~iio_math_impl(); 45 | 46 | struct block; 47 | 48 | void register_block(struct block *block); 49 | void set_port_used(unsigned int port); 50 | virtual gr::basic_block_sptr get_src_block(); 51 | virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port = 0); 52 | 53 | private: 54 | std::vector blocks; 55 | std::vector connected_ports; 56 | 57 | void connect_null_sinks(); 58 | 59 | protected: 60 | iio_math_impl() {} 61 | 62 | int parse_function(const std::string &function); 63 | void cleanup(); 64 | }; 65 | 66 | class iio_math_gen_impl : public iio_math_impl, 67 | public iio_math_gen 68 | { 69 | public: 70 | iio_math_gen_impl(double sampling_freq, double wav_freq, 71 | const std::string &function); 72 | 73 | virtual gr::basic_block_sptr get_src_block(); 74 | virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port = 0); 75 | 76 | private: 77 | gr::basic_block_sptr src_block; 78 | }; 79 | } 80 | } 81 | 82 | #endif /* INCLUDED_GR_IIO_MATH_IMPL_H */ 83 | -------------------------------------------------------------------------------- /lib/iio_math_lexer.l: -------------------------------------------------------------------------------- 1 | %{ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "parser.h" 23 | 24 | #define _USE_MATH_DEFINES 25 | #include 26 | #include 27 | %} 28 | 29 | %option noyywrap reentrant bison-bridge nounistd always-interactive 30 | 31 | %s WANT_IN_PORT 32 | %s WANT_MULT 33 | %s WANT_TWO_PI 34 | %s WANT_END 35 | 36 | %% 37 | 38 | w { 39 | yyless(0); 40 | BEGIN(WANT_IN_PORT); 41 | return '('; 42 | } 43 | 44 | w { 45 | yyless(0); 46 | BEGIN(WANT_MULT); 47 | return IN_PORT; 48 | } 49 | 50 | w { 51 | yyless(0); 52 | BEGIN(WANT_TWO_PI); 53 | return '*'; 54 | } 55 | 56 | w { 57 | yyless(0); 58 | yylval->val = 2.0 * M_PI; 59 | BEGIN(WANT_END); 60 | return VALUE; 61 | } 62 | 63 | w { 64 | BEGIN(0); 65 | return ')'; 66 | } 67 | 68 | (x[0-9])|(t[0-9]) { 69 | yylval->ival = yytext[1] - '0'; 70 | return IN_PORT; 71 | } 72 | 73 | x|t { 74 | yylval->ival = 0; 75 | return IN_PORT; 76 | } 77 | 78 | e { 79 | yylval->val = M_E; 80 | return VALUE; 81 | } 82 | 83 | pi { 84 | yylval->val = M_PI; 85 | return VALUE; 86 | } 87 | 88 | (\*\*)|^ { 89 | return POWER; 90 | } 91 | 92 | [0-9]+([,.][0-9]+)? { 93 | yylval->val = atof(yytext); 94 | return VALUE; 95 | } 96 | 97 | [a-z]+[0-9]* { 98 | yylval->fname = strdup(yytext); 99 | return FNAME; 100 | } 101 | 102 | [ \t]+ { 103 | } 104 | 105 | . { 106 | return *yytext; 107 | } 108 | -------------------------------------------------------------------------------- /lib/iio_math_parser.y: -------------------------------------------------------------------------------- 1 | %{ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "parser.h" 23 | 24 | #include 25 | #include 26 | 27 | int yylex(YYSTYPE *type, yyscan_t scanner); 28 | void yyerror(yyscan_t scanner, const char *msg); 29 | %} 30 | 31 | %code requires { 32 | #ifndef YY_TYPEDEF_YY_SCANNER_T 33 | #define YY_TYPEDEF_YY_SCANNER_T 34 | typedef void *yyscan_t; 35 | #endif 36 | 37 | int yylex_init_extra(void *pdata, yyscan_t *scanner); 38 | int yylex_destroy(yyscan_t yyscanner); 39 | 40 | void * yyget_extra(yyscan_t scanner); 41 | 42 | void * src_block(void *pdata, unsigned int input); 43 | void * const_block(void *pdata, double value); 44 | void * add_block(void *pdata, void *left, void *right); 45 | void * sub_block(void *pdata, void *left, void *right); 46 | void * mult_block(void *pdata, void *left, void *right); 47 | void * div_block(void *pdata, void *left, void *right); 48 | void * pow_block(void *pdata, void *left, void *right); 49 | void * mod_block(void *pdata, void *left, void *right); 50 | void * func_block(void *pdata, void *input, const char *name); 51 | void * neg_block(void *pdata, void *input); 52 | 53 | void connect_to_output(void *pdata, void *input); 54 | void delete_block(void *pdata, void *block); 55 | } 56 | 57 | /* Bison declarations. */ 58 | %define api.pure 59 | %lex-param { yyscan_t scanner } 60 | %parse-param { yyscan_t scanner } 61 | 62 | %start Line 63 | 64 | %union { 65 | double val; 66 | unsigned int ival; 67 | char *fname; 68 | void *block; 69 | } 70 | 71 | %token FNAME; 72 | %token VALUE; 73 | %token IN_PORT; 74 | %type Element; 75 | %type Factor; 76 | %type Term; 77 | %token POWER; 78 | 79 | %left '-' '+' '*' '/' '%' 80 | %precedence PREFIX 81 | %right POWER 82 | 83 | %destructor { free($$); } 84 | %destructor { delete_block(yyget_extra(scanner), $$); } 85 | 86 | %% 87 | 88 | Element: 89 | IN_PORT[t] { 90 | $$ = src_block(yyget_extra(scanner), $t); 91 | } 92 | | VALUE[t] { 93 | $$ = const_block(yyget_extra(scanner), $t); 94 | } 95 | | FNAME[n] '(' Term[t] ')' { 96 | $$ = func_block(yyget_extra(scanner), $t, $n); 97 | } 98 | | '(' Term[t] ')' { 99 | $$ = $t; 100 | } 101 | | '-' Element[t] %prec PREFIX { 102 | $$ = neg_block(yyget_extra(scanner), $t); 103 | } 104 | | '+' Element[t] %prec PREFIX { 105 | $$ = $t; 106 | } 107 | ; 108 | 109 | Factor: 110 | Element 111 | | Factor[f1] '*' Factor[f2] { 112 | $$ = mult_block(yyget_extra(scanner), $f1, $f2); 113 | } 114 | | Factor[f1] '/' Factor[f2] { 115 | $$ = div_block(yyget_extra(scanner), $f1, $f2); 116 | } 117 | | Factor[f1] POWER Factor[f2] { 118 | $$ = pow_block(yyget_extra(scanner), $f1, $f2); 119 | } 120 | | Factor[f1] '%' Factor[f2] { 121 | $$ = mod_block(yyget_extra(scanner), $f1, $f2); 122 | /* TODO(pcercuei): Implement modulo */ 123 | } 124 | ; 125 | 126 | Term: 127 | Factor 128 | /* TODO(pcercuei): Implement const operations 129 | | Term '+' VALUE { } 130 | | Term '-' VALUE { } 131 | | VALUE '+' Term { } 132 | | VALUE '-' Term { } 133 | */ 134 | | Term[t1] '+' Term[t2] { 135 | $$ = add_block(yyget_extra(scanner), $t1, $t2); 136 | } 137 | | Term[t1] '-' Term[t2] { 138 | $$ = sub_block(yyget_extra(scanner), $t1, $t2); 139 | } 140 | ; 141 | 142 | Line: 143 | Term[t] { 144 | connect_to_output(yyget_extra(scanner), $[t]); 145 | } 146 | 147 | %% 148 | 149 | void yyerror(yyscan_t scanner, const char *msg) 150 | { 151 | printf("ERROR: %s\n", msg); 152 | } 153 | -------------------------------------------------------------------------------- /lib/iio_modulo_const_ff_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include "iio_modulo_const_ff_impl.h" 27 | 28 | #include 29 | #include 30 | 31 | using namespace gr::iio; 32 | 33 | modulo_const_ff::sptr modulo_const_ff::make(float modulo, size_t vlen) 34 | { 35 | return gnuradio::get_initial_sptr( 36 | new modulo_const_ff_impl(modulo, vlen)); 37 | } 38 | 39 | modulo_const_ff_impl::modulo_const_ff_impl(float modulo, size_t vlen) 40 | : sync_block("modulo_const_ff", 41 | io_signature::make (1, 1, sizeof(float)*vlen), 42 | io_signature::make (1, 1, sizeof(float)*vlen)), 43 | d_modulo(modulo), d_vlen(vlen) 44 | { 45 | } 46 | 47 | int 48 | modulo_const_ff_impl::work(int noutput_items, 49 | gr_vector_const_void_star &input_items, 50 | gr_vector_void_star &output_items) 51 | { 52 | float *out = (float *) output_items[0]; 53 | const float *in = (const float *) input_items[0]; 54 | int noi = d_vlen*noutput_items; 55 | 56 | for (size_t i = 0; i < noi; i++) 57 | out[i] = std::fmod(in[i], d_modulo); 58 | 59 | return noutput_items; 60 | } 61 | -------------------------------------------------------------------------------- /lib/iio_modulo_const_ff_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_IIO_MODULO_CONST_FF_IMPL_H 24 | #define INCLUDED_IIO_MODULO_CONST_FF_IMPL_H 25 | 26 | #include 27 | 28 | namespace gr { 29 | namespace iio { 30 | 31 | class IIO_API modulo_const_ff_impl : public modulo_const_ff 32 | { 33 | float d_modulo; 34 | size_t d_vlen; 35 | 36 | public: 37 | modulo_const_ff_impl(float modulo, size_t vlen); 38 | 39 | int work(int noutput_items, 40 | gr_vector_const_void_star &input_items, 41 | gr_vector_void_star &output_items); 42 | }; 43 | 44 | } /* namespace iio */ 45 | } /* namespace gr */ 46 | 47 | 48 | #endif /* INCLUDED_IIO_MODULO_CONST_FF_IMPL_H */ 49 | -------------------------------------------------------------------------------- /lib/iio_modulo_ff_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include "iio_modulo_ff_impl.h" 27 | 28 | #include 29 | #include 30 | 31 | using namespace gr::iio; 32 | 33 | modulo_ff::sptr modulo_ff::make(size_t vlen) 34 | { 35 | return gnuradio::get_initial_sptr(new modulo_ff_impl(vlen)); 36 | } 37 | 38 | modulo_ff_impl::modulo_ff_impl(size_t vlen) 39 | : sync_block("modulo_ff", 40 | io_signature::make (2, 2, sizeof(float)*vlen), 41 | io_signature::make (1, 1, sizeof(float)*vlen)), 42 | d_vlen(vlen) 43 | { 44 | } 45 | 46 | int 47 | modulo_ff_impl::work(int noutput_items, 48 | gr_vector_const_void_star &input_items, 49 | gr_vector_void_star &output_items) 50 | { 51 | float *out = (float *) output_items[0]; 52 | const float *in1 = (const float *) input_items[0]; 53 | const float *in2 = (const float *) input_items[1]; 54 | int noi = d_vlen*noutput_items; 55 | 56 | for (size_t i = 0; i < noi; i++) 57 | out[i] = std::fmod(in1[i], in2[i]); 58 | 59 | return noutput_items; 60 | } 61 | -------------------------------------------------------------------------------- /lib/iio_modulo_ff_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_IIO_MODULO_FF_IMPL_H 24 | #define INCLUDED_IIO_MODULO_FF_IMPL_H 25 | 26 | #include 27 | 28 | namespace gr { 29 | namespace iio { 30 | 31 | class IIO_API modulo_ff_impl : public modulo_ff 32 | { 33 | size_t d_vlen; 34 | 35 | public: 36 | modulo_ff_impl(size_t vlen); 37 | 38 | int work(int noutput_items, 39 | gr_vector_const_void_star &input_items, 40 | gr_vector_void_star &output_items); 41 | }; 42 | 43 | } /* namespace iio */ 44 | } /* namespace gr */ 45 | 46 | 47 | #endif /* INCLUDED_IIO_MODULO_FF_IMPL_H */ 48 | -------------------------------------------------------------------------------- /lib/iio_power_ff_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef HAVE_CONFIG_H 23 | #include "config.h" 24 | #endif 25 | 26 | #include "iio_power_ff_impl.h" 27 | 28 | #include 29 | #include 30 | 31 | using namespace gr::iio; 32 | 33 | power_ff::sptr power_ff::make(size_t vlen) 34 | { 35 | return gnuradio::get_initial_sptr(new power_ff_impl(vlen)); 36 | } 37 | 38 | power_ff_impl::power_ff_impl(size_t vlen) 39 | : sync_block("power_ff", 40 | io_signature::make (1, -1, sizeof(float)*vlen), 41 | io_signature::make (1, 1, sizeof(float)*vlen)), 42 | d_vlen(vlen) 43 | { 44 | const int alignment_multiple = volk_get_alignment() / sizeof(float); 45 | set_alignment(std::max(1, alignment_multiple)); 46 | } 47 | 48 | int 49 | power_ff_impl::work(int noutput_items, 50 | gr_vector_const_void_star &input_items, 51 | gr_vector_void_star &output_items) 52 | { 53 | float *out = (float *) output_items[0]; 54 | int noi = d_vlen*noutput_items; 55 | 56 | memcpy(out, input_items[0], noi*sizeof(float)); 57 | for(size_t i = 1; i < input_items.size(); i++) 58 | volk_32f_x2_pow_32f(out, (float*)input_items[i], out, noi); 59 | 60 | return noutput_items; 61 | } 62 | -------------------------------------------------------------------------------- /lib/iio_power_ff_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Free Software Foundation, Inc. 4 | * 5 | * This file is part of GNU Radio 6 | * 7 | * GNU Radio is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3, or (at your option) 10 | * any later version. 11 | * 12 | * GNU Radio is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with GNU Radio; see the file COPYING. If not, write to 19 | * the Free Software Foundation, Inc., 51 Franklin Street, 20 | * Boston, MA 02110-1301, USA. 21 | */ 22 | 23 | #ifndef INCLUDED_IIO_POWER_FF_IMPL_H 24 | #define INCLUDED_IIO_POWER_FF_IMPL_H 25 | 26 | #include 27 | 28 | namespace gr { 29 | namespace iio { 30 | 31 | class IIO_API power_ff_impl : public power_ff 32 | { 33 | size_t d_vlen; 34 | 35 | public: 36 | power_ff_impl(size_t vlen); 37 | 38 | int work(int noutput_items, 39 | gr_vector_const_void_star &input_items, 40 | gr_vector_void_star &output_items); 41 | }; 42 | 43 | } /* namespace iio */ 44 | } /* namespace gr */ 45 | 46 | 47 | #endif /* INCLUDED_IIO_POWER_FF_IMPL_H */ 48 | -------------------------------------------------------------------------------- /lib/pluto_sink_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "pluto_sink_impl.h" 23 | #include "pluto_source_impl.h" 24 | 25 | #include 26 | 27 | namespace gr { 28 | namespace iio { 29 | 30 | pluto_sink::sptr pluto_sink::make(const std::string& uri, 31 | unsigned long long frequency, 32 | unsigned long samplerate, 33 | unsigned long bandwidth, 34 | unsigned long buffer_size, 35 | bool cyclic, 36 | double attenuation, 37 | const char *filter, 38 | bool auto_filter) 39 | { 40 | fmcomms2_sink::sptr block = fmcomms2_sink::make( 41 | uri.empty() ? pluto_source_impl::get_uri() : uri, 42 | frequency, samplerate, 43 | bandwidth, true, true, false, false, 44 | buffer_size, cyclic, "A", 45 | attenuation, 0.0, filter, auto_filter); 46 | 47 | return gnuradio::get_initial_sptr( 48 | new pluto_sink_impl(block)); 49 | } 50 | 51 | pluto_sink_impl::pluto_sink_impl(fmcomms2_sink::sptr block) : 52 | hier_block2("pluto_sink", 53 | io_signature::make(1, 1, sizeof(gr_complex)), 54 | io_signature::make(0, 0, 0)), 55 | fmcomms2_sink_f32c(true, false, block) 56 | { 57 | } 58 | 59 | void pluto_sink_impl::set_params(unsigned long long frequency, 60 | unsigned long samplerate, 61 | unsigned long bandwidth, 62 | double attenuation, 63 | const char *filter, 64 | bool auto_filter) 65 | { 66 | fmcomms2_sink_f32c::set_params(frequency, samplerate, bandwidth, 67 | "A", attenuation, 0.0, filter, auto_filter); 68 | } 69 | 70 | } // namespace iio 71 | } // namespace gr 72 | -------------------------------------------------------------------------------- /lib/pluto_sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_PLUTO_SINK_IMPL_H 23 | #define INCLUDED_IIO_PLUTO_SINK_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "device_sink_impl.h" 32 | 33 | namespace gr { 34 | namespace iio { 35 | 36 | class pluto_sink_impl : public pluto_sink 37 | , public fmcomms2_sink_f32c 38 | { 39 | public: 40 | explicit pluto_sink_impl(fmcomms2_sink::sptr block); 41 | 42 | void set_params(unsigned long long frequency, 43 | unsigned long samplerate, 44 | unsigned long bandwidth, 45 | double attenuation, 46 | const char *filter, 47 | bool auto_filter); 48 | }; 49 | 50 | } // namespace iio 51 | } // namespace gr 52 | 53 | #endif /* INCLUDED_PLUTO_SINK_IMPL_H */ 54 | -------------------------------------------------------------------------------- /lib/pluto_source_impl.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "pluto_source_impl.h" 23 | 24 | #include 25 | #include 26 | 27 | namespace gr { 28 | namespace iio { 29 | 30 | pluto_source::sptr pluto_source::make(const std::string& uri, 31 | unsigned long long frequency, unsigned long samplerate, 32 | unsigned long bandwidth, 33 | unsigned long buffer_size, bool quadrature, bool rfdc, 34 | bool bbdc, const char *gain, double gain_value, 35 | const char *filter, bool auto_filter) 36 | { 37 | fmcomms2_source::sptr block = fmcomms2_source::make( 38 | uri.empty() ? pluto_source_impl::get_uri() : uri, 39 | frequency, samplerate, 40 | bandwidth, true, true, false, false, 41 | buffer_size, quadrature, rfdc, bbdc, 42 | gain, gain_value, NULL, 0.0, "A_BALANCED", 43 | filter, auto_filter); 44 | 45 | return gnuradio::get_initial_sptr( 46 | new pluto_source_impl(block)); 47 | } 48 | 49 | std::string pluto_source_impl::get_uri() 50 | { 51 | struct iio_scan_context *ctx = iio_create_scan_context("usb", 0); 52 | if (!ctx) 53 | throw std::runtime_error("Unable to create scan context"); 54 | 55 | struct iio_context_info **info; 56 | int ret = iio_scan_context_get_info_list(ctx, &info); 57 | if (ret < 0) { 58 | iio_scan_context_destroy(ctx); 59 | throw std::runtime_error("Unable to scan for Pluto devices"); 60 | } 61 | 62 | if (ret == 0) { 63 | iio_context_info_list_free(info); 64 | iio_scan_context_destroy(ctx); 65 | throw std::runtime_error("No Pluto device found"); 66 | } 67 | 68 | if (ret > 1) { 69 | printf("More than one Pluto found:\n"); 70 | 71 | for (unsigned int i = 0; i < (size_t) ret; i++) { 72 | printf("\t%d: %s [%s]\n", i, 73 | iio_context_info_get_description(info[i]), 74 | iio_context_info_get_uri(info[i])); 75 | } 76 | 77 | printf("We will use the first one.\n"); 78 | } 79 | 80 | std::string uri(iio_context_info_get_uri(info[0])); 81 | iio_context_info_list_free(info); 82 | iio_scan_context_destroy(ctx); 83 | 84 | return uri; 85 | } 86 | 87 | pluto_source_impl::pluto_source_impl(fmcomms2_source::sptr block) : 88 | hier_block2("pluto_source", 89 | io_signature::make(0, 0, 0), 90 | io_signature::make(1, 1, sizeof(gr_complex))), 91 | fmcomms2_source_f32c(true, false, block) 92 | { 93 | } 94 | 95 | void pluto_source_impl::set_params(unsigned long long frequency, 96 | unsigned long samplerate, 97 | unsigned long bandwidth, 98 | bool quadrature, bool rfdc, bool bbdc, 99 | const char *gain, double gain_value, 100 | const char *filter, bool auto_filter) 101 | { 102 | fmcomms2_source_f32c::set_params(frequency, samplerate, bandwidth, 103 | quadrature, rfdc, bbdc, gain, gain_value, NULL, 0.0, 104 | "A_BALANCED", filter, auto_filter); 105 | } 106 | 107 | } // namespace iio 108 | } // namespace gr 109 | -------------------------------------------------------------------------------- /lib/pluto_source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Analog Devices Inc. 4 | * Author: Paul Cercueil 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3, or (at your option) 9 | * any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; see the file COPYING. If not, write to 18 | * the Free Software Foundation, Inc., 51 Franklin Street, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifndef INCLUDED_IIO_PLUTO_SOURCE_IMPL_H 23 | #define INCLUDED_IIO_PLUTO_SOURCE_IMPL_H 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "device_source_impl.h" 32 | 33 | namespace gr { 34 | namespace iio { 35 | 36 | class pluto_source_impl : public pluto_source 37 | , public fmcomms2_source_f32c 38 | { 39 | public: 40 | explicit pluto_source_impl(fmcomms2_source::sptr block); 41 | 42 | static std::string get_uri(); 43 | 44 | void set_params(unsigned long long frequency, 45 | unsigned long samplerate, 46 | unsigned long bandwidth, 47 | bool quadrature, bool rfdc, bool bbdc, 48 | const char *gain, double gain_value, 49 | const char *filter, bool auto_filter); 50 | }; 51 | 52 | } // namespace iio 53 | } // namespace gr 54 | 55 | #endif /* INCLUDED_IIO_PLUTO_SOURCE_IMPL_H */ 56 | -------------------------------------------------------------------------------- /python/iio/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Include python install macros 22 | ######################################################################## 23 | include(GrPython) 24 | if(NOT PYTHONINTERP_FOUND) 25 | return() 26 | endif() 27 | 28 | ######################################################################## 29 | # Install python sources 30 | ######################################################################## 31 | GR_PYTHON_INSTALL( 32 | FILES 33 | __init__.py 34 | attr_updater.py 35 | DESTINATION ${GR_PYTHON_DIR}/gnuradio/iio 36 | ) 37 | -------------------------------------------------------------------------------- /python/iio/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2008,2009 Free Software Foundation, Inc. 3 | # 4 | # This application is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 3, or (at your option) 7 | # any later version. 8 | # 9 | # This application is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | # 18 | 19 | # The presence of this file turns this directory into a Python package 20 | 21 | ''' 22 | This is the GNU Radio IIO module. Place your Python package 23 | description here (python/__init__.py). 24 | ''' 25 | 26 | import os 27 | 28 | try: 29 | from iio_swig import * 30 | from iio_pluto_source_swig import * 31 | from iio_pluto_sink_swig import * 32 | except ImportError: 33 | dirname, filename = os.path.split(os.path.abspath(__file__)) 34 | __path__.append(os.path.join(dirname, "..", "..", "swig")) 35 | from iio_swig import * 36 | from iio_pluto_source_swig import * 37 | from iio_pluto_sink_swig import * 38 | 39 | from attr_updater import attr_updater 40 | -------------------------------------------------------------------------------- /python/iio/attr_updater.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2018 Analog Devices Inc. 5 | # Author: Travis Collins 6 | # 7 | # This is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 3, or (at your option) 10 | # any later version. 11 | # 12 | # This software is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this software; see the file COPYING. If not, write to 19 | # the Free Software Foundation, Inc., 51 Franklin Street, 20 | # Boston, MA 02110-1301, USA. 21 | # 22 | 23 | import numpy 24 | from gnuradio import gr 25 | import threading 26 | import pmt 27 | from time import sleep 28 | 29 | class attr_updater(gr.basic_block): 30 | """ 31 | attr_updater: Utility for creating PMT dictionaries in a format for interfacing 32 | with IIO Attribute blocks. 33 | """ 34 | def __init__(self, attribute, value, interval): 35 | gr.basic_block.__init__(self, 36 | name="attr_updater", 37 | in_sig=None, 38 | out_sig=None) 39 | 40 | self.attribute = attribute 41 | self.value = value 42 | self.interval = interval 43 | self.port = pmt.intern("out") 44 | self.message_port_register_out(self.port) 45 | self.lock = threading.Lock() 46 | self.run = True 47 | self.thread = threading.Thread(target=self.sender, args=()) 48 | self.thread.start() 49 | 50 | def __del__(self): 51 | self.lock.acquire() 52 | self.run = False 53 | self.lock.release() 54 | self.thread.join() 55 | 56 | def update_value(self, value): 57 | self.value = value 58 | 59 | def sender(self): 60 | while 1: 61 | self.lock.acquire() 62 | if not self.run: 63 | self.lock.release() 64 | return 65 | self.lock.release() 66 | 67 | key0 = pmt.intern(str(self.attribute)) 68 | val0 = pmt.intern(str(self.value)) 69 | msg_dic = pmt.make_dict() 70 | msg_dic = pmt.dict_add(msg_dic, key0, val0) 71 | try: 72 | self.message_port_pub(self.port, msg_dic) 73 | except: 74 | print "Error: Failed to publish message" 75 | return 76 | 77 | sleep(self.interval/1000) 78 | -------------------------------------------------------------------------------- /swig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # GNU Radio is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 9 | # 10 | # GNU Radio is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with GNU Radio; see the file COPYING. If not, write to 17 | # the Free Software Foundation, Inc., 51 Franklin Street, 18 | # Boston, MA 02110-1301, USA. 19 | 20 | ######################################################################## 21 | # Check if there is C++ code at all 22 | ######################################################################## 23 | if(NOT iio_sources) 24 | MESSAGE(STATUS "No C++ sources... skipping swig/") 25 | return() 26 | endif(NOT iio_sources) 27 | 28 | ######################################################################## 29 | # Include swig generation macros 30 | ######################################################################## 31 | find_package(SWIG) 32 | find_package(PythonLibs 2) 33 | if(NOT SWIG_FOUND OR NOT PYTHONLIBS_FOUND) 34 | return() 35 | endif() 36 | include(GrSwig) 37 | include(GrPython) 38 | 39 | ######################################################################## 40 | # Setup swig generation 41 | ######################################################################## 42 | foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) 43 | list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) 44 | endforeach(incdir) 45 | 46 | set(GR_SWIG_LIBRARIES gnuradio-iio) 47 | GR_SWIG_MAKE(iio_swig iio_swig.i) 48 | GR_SWIG_MAKE(iio_pluto_source_swig iio_pluto_source_swig.i) 49 | GR_SWIG_MAKE(iio_pluto_sink_swig iio_pluto_sink_swig.i) 50 | 51 | ######################################################################## 52 | # Install the build swig module 53 | ######################################################################## 54 | GR_SWIG_INSTALL(TARGETS iio_swig iio_pluto_source_swig iio_pluto_sink_swig 55 | DESTINATION ${GR_PYTHON_DIR}/gnuradio/iio) 56 | 57 | ######################################################################## 58 | # Install swig .i files for development 59 | ######################################################################## 60 | install( 61 | FILES 62 | iio_swig.i 63 | iio_pluto_source_swig.i 64 | iio_pluto_sink_swig.i 65 | DESTINATION ${GR_INCLUDE_DIR}/swig 66 | ) 67 | -------------------------------------------------------------------------------- /swig/iio_pluto_sink_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | /* The PlutoSDR block is in a separate file, because Swig chokes on it 4 | * and produces incorrect Python code if it is present in iio_swig.i... */ 5 | 6 | #define IIO_API 7 | 8 | %include "gnuradio.i" 9 | 10 | %{ 11 | #include "gnuradio/iio/pluto_sink.h" 12 | %} 13 | 14 | %include "gnuradio/iio/pluto_sink.h" 15 | 16 | GR_SWIG_BLOCK_MAGIC2(iio, pluto_sink); 17 | -------------------------------------------------------------------------------- /swig/iio_pluto_source_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | /* The PlutoSDR block is in a separate file, because Swig chokes on it 4 | * and produces incorrect Python code if it is present in iio_swig.i... */ 5 | 6 | #define IIO_API 7 | 8 | %include "gnuradio.i" 9 | 10 | %{ 11 | #include "gnuradio/iio/pluto_source.h" 12 | %} 13 | 14 | %include "gnuradio/iio/pluto_source.h" 15 | 16 | GR_SWIG_BLOCK_MAGIC2(iio, pluto_source); 17 | -------------------------------------------------------------------------------- /swig/iio_swig.i: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | 3 | #define IIO_API 4 | 5 | %include "gnuradio.i" 6 | 7 | %{ 8 | #include "gnuradio/iio/device_source.h" 9 | #include "gnuradio/iio/device_sink.h" 10 | #include "gnuradio/iio/fmcomms2_source.h" 11 | #include "gnuradio/iio/fmcomms2_sink.h" 12 | #include "gnuradio/iio/fmcomms5_source.h" 13 | #include "gnuradio/iio/fmcomms5_sink.h" 14 | #include "gnuradio/iio/math.h" 15 | #include "gnuradio/iio/power_ff.h" 16 | #include "gnuradio/iio/modulo_ff.h" 17 | #include "gnuradio/iio/modulo_const_ff.h" 18 | #include "gnuradio/iio/attr_sink.h" 19 | #include "gnuradio/iio/attr_source.h" 20 | %} 21 | 22 | %include "gnuradio/iio/device_source.h" 23 | %include "gnuradio/iio/device_sink.h" 24 | %include "gnuradio/iio/fmcomms2_source.h" 25 | %include "gnuradio/iio/fmcomms2_sink.h" 26 | %include "gnuradio/iio/fmcomms5_source.h" 27 | %include "gnuradio/iio/fmcomms5_sink.h" 28 | %include "gnuradio/iio/math.h" 29 | %include "gnuradio/iio/power_ff.h" 30 | %include "gnuradio/iio/modulo_ff.h" 31 | %include "gnuradio/iio/modulo_const_ff.h" 32 | %include "gnuradio/iio/attr_sink.h" 33 | %include "gnuradio/iio/attr_source.h" 34 | 35 | GR_SWIG_BLOCK_MAGIC2(iio, device_source); 36 | GR_SWIG_BLOCK_MAGIC2(iio, device_sink); 37 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms2_source); 38 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms2_source_f32c); 39 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms2_sink); 40 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms2_sink_f32c); 41 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms5_source); 42 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms5_source_f32c); 43 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms5_sink); 44 | GR_SWIG_BLOCK_MAGIC2(iio, fmcomms5_sink_f32c); 45 | GR_SWIG_BLOCK_MAGIC2(iio, iio_math); 46 | GR_SWIG_BLOCK_MAGIC2(iio, iio_math_gen); 47 | GR_SWIG_BLOCK_MAGIC2(iio, power_ff); 48 | GR_SWIG_BLOCK_MAGIC2(iio, modulo_ff); 49 | GR_SWIG_BLOCK_MAGIC2(iio, modulo_const_ff); 50 | GR_SWIG_BLOCK_MAGIC2(iio, attr_sink); 51 | GR_SWIG_BLOCK_MAGIC2(iio, attr_source); 52 | --------------------------------------------------------------------------------