├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── MANIFEST.md ├── README.md ├── apps ├── CMakeLists.txt ├── osmocom_fft ├── osmocom_siggen ├── osmocom_siggen_base.py ├── osmocom_siggen_nogui └── osmocom_spectrum_sense ├── cmake ├── Modules │ ├── FindGnuradioFuncube.cmake │ ├── FindLibAIRSPY.cmake │ ├── FindLibAIRSPYHF.cmake │ ├── FindLibFreeSRP.cmake │ ├── FindLibHackRF.cmake │ ├── FindLibMiriSDR.cmake │ ├── FindLibRTLSDR.cmake │ ├── FindLibSDRplay.cmake │ ├── FindLibXTRX.cmake │ ├── FindLibbladeRF.cmake │ ├── FindUHD.cmake │ └── targetConfig.cmake.in └── cmake_uninstall.cmake.in ├── debian ├── changelog ├── compat ├── control ├── copyright ├── gr-osmosdr.install ├── gr-osmosdr.manpages ├── libgnuradio-osmosdr0.1.4.install ├── osmocom_fft.1 ├── osmocom_siggen.1 ├── osmocom_siggen_nogui.1 ├── osmocom_spectrum_sense.1 ├── rules ├── source │ └── format └── watch ├── docs ├── CMakeLists.txt └── doxygen │ ├── CMakeLists.txt │ ├── Doxyfile.in │ ├── Doxyfile.swig_doc.in │ ├── doxyxml │ ├── __init__.py │ ├── base.py │ ├── doxyindex.py │ ├── generated │ │ ├── __init__.py │ │ ├── compound.py │ │ ├── compoundsuper.py │ │ ├── index.py │ │ └── indexsuper.py │ └── text.py │ ├── other │ ├── group_defs.dox │ └── main_page.dox │ ├── pydoc_macros.h │ └── update_pydoc.py ├── grc ├── CMakeLists.txt └── gen_osmosdr_blocks.py ├── include └── osmosdr │ ├── CMakeLists.txt │ ├── api.h │ ├── device.h │ ├── pimpl.h │ ├── ranges.h │ ├── sink.h │ ├── source.h │ └── time_spec.h ├── lib ├── CMakeLists.txt ├── airspy │ ├── CMakeLists.txt │ ├── airspy_fir_kernels.h │ ├── airspy_source_c.cc │ └── airspy_source_c.h ├── airspyhf │ ├── CMakeLists.txt │ ├── airspyhf_source_c.cc │ └── airspyhf_source_c.h ├── arg_helpers.h ├── bladerf │ ├── CMakeLists.txt │ ├── bladerf_common.cc │ ├── bladerf_common.h │ ├── bladerf_compat.h │ ├── bladerf_sink_c.cc │ ├── bladerf_sink_c.h │ ├── bladerf_source_c.cc │ └── bladerf_source_c.h ├── config.h.in ├── device.cc ├── fcd │ ├── CMakeLists.txt │ ├── fcd_source_c.cc │ └── fcd_source_c.h ├── file │ ├── CMakeLists.txt │ ├── file_sink_c.cc │ ├── file_sink_c.h │ ├── file_source_c.cc │ └── file_source_c.h ├── freesrp │ ├── CMakeLists.txt │ ├── freesrp_common.cc │ ├── freesrp_common.h │ ├── freesrp_sink_c.cc │ ├── freesrp_sink_c.h │ ├── freesrp_source_c.cc │ ├── freesrp_source_c.h │ └── readerwriterqueue │ │ ├── LICENSE.md │ │ ├── README.md │ │ ├── atomicops.h │ │ └── readerwriterqueue.h ├── hackrf │ ├── CMakeLists.txt │ ├── hackrf_common.cc │ ├── hackrf_common.h │ ├── hackrf_sink_c.cc │ ├── hackrf_sink_c.h │ ├── hackrf_source_c.cc │ └── hackrf_source_c.h ├── miri │ ├── CMakeLists.txt │ ├── miri_source_c.cc │ └── miri_source_c.h ├── ranges.cc ├── redpitaya │ ├── CMakeLists.txt │ ├── redpitaya_common.cc │ ├── redpitaya_common.h │ ├── redpitaya_sink_c.cc │ ├── redpitaya_sink_c.h │ ├── redpitaya_source_c.cc │ └── redpitaya_source_c.h ├── rfspace │ ├── CMakeLists.txt │ ├── rfspace_source_c.cc │ └── rfspace_source_c.h ├── rtl │ ├── CMakeLists.txt │ ├── rtl_source_c.cc │ └── rtl_source_c.h ├── rtl_tcp │ ├── CMakeLists.txt │ ├── rtl_tcp_source_c.cc │ └── rtl_tcp_source_c.h ├── sdrplay │ ├── CMakeLists.txt │ ├── sdrplay_source_c.cc │ └── sdrplay_source_c.h ├── sink_iface.h ├── sink_impl.cc ├── sink_impl.h ├── soapy │ ├── CMakeLists.txt │ ├── soapy_common.cc │ ├── soapy_common.h │ ├── soapy_sink_c.cc │ ├── soapy_sink_c.h │ ├── soapy_source_c.cc │ └── soapy_source_c.h ├── source_iface.h ├── source_impl.cc ├── source_impl.h ├── time_spec.cc ├── uhd │ ├── CMakeLists.txt │ ├── uhd_sink_c.cc │ ├── uhd_sink_c.h │ ├── uhd_source_c.cc │ └── uhd_source_c.h └── xtrx │ ├── CMakeLists.txt │ ├── xtrx_obj.cc │ ├── xtrx_obj.h │ ├── xtrx_sink_c.cc │ ├── xtrx_sink_c.h │ ├── xtrx_source_c.cc │ └── xtrx_source_c.h └── python ├── CMakeLists.txt ├── __init__.py └── bindings ├── CMakeLists.txt ├── README.md ├── bind_oot_file.py ├── device_python.cc ├── docstrings ├── README.md ├── sink_pydoc_template.h └── source_pydoc_template.h ├── header_utils.py ├── python_bindings.cc ├── ranges_python.cc ├── sink_python.cc ├── source_python.cc └── time_spec_python.cc /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode/* 2 | /build/* 3 | *.pyc 4 | *.pyo 5 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Dimitri Stolnikov 2 | Steve Markgraf 3 | Hoernchen 4 | Nuand LLC folks 5 | Josh Blum 6 | SDRplay Ltd. 7 | Pavel Demin 8 | Marcus Müller 9 | Lukas Lao Beyer 10 | -------------------------------------------------------------------------------- /MANIFEST.md: -------------------------------------------------------------------------------- 1 | title: gr-osmosdr 2 | brief: GNU Radio block for interfacing with various radio hardware 3 | tags: 4 | - rtlsdr 5 | - bladerf 6 | - airspy 7 | - rfspace 8 | - hackrf 9 | - soapy 10 | - sdrplay 11 | - uhd 12 | - osmocom 13 | author: 14 | - Dimitri Stolnikov 15 | copyright_owner: 16 | - Dimitri Stolnikov 17 | license: GPLv3 18 | repo: https://gitea.osmocom.org/sdr/gr-osmosdr 19 | website: http://sdr.osmocom.org/trac/wiki/GrOsmoSDR 20 | --- 21 | GNU Radio block for interfacing with various radio hardware 22 | 23 | ![FFT](http://sdr.osmocom.org/trac/raw-attachment/wiki/GrOsmoSDR/fft-lte.png "osmocom_fft") 24 | ![SIG](http://sdr.osmocom.org/trac/raw-attachment/wiki/GrOsmoSDR/siggen-gsm.png "osmocom_siggen") 25 | ![GS2](http://sdr.osmocom.org/trac/raw-attachment/wiki/GrOsmoSDR/gsm-hackrf-8M.png "osmocom_siggen with hackrf") 26 | 27 | Support for gr-fosphor in `osmocom_fft` is available through the -F option. 28 | 29 | ![LTE](http://sdr.osmocom.org/trac/raw-attachment/wiki/GrOsmoSDR/fosphor.png "LTE") 30 | ![GSM](http://sdr.osmocom.org/trac/raw-attachment/wiki/GrOsmoSDR/fosphor2.png "GSM") 31 | 32 | Please refer to the documentation on http://sdr.osmocom.org/trac/wiki/GrOsmoSDR 33 | for installation instructions. 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | gr-osmosdr - generic gnuradio SDR I/O block 2 | =========================================== 3 | 4 | While originally being developed for the 5 | [OsmoSDR](https://osmocom.org/projects/osmosdr/wiki) hardware, this 6 | block has become a generic SDR I/O block for a variety of SDR 7 | hardware, including: 8 | 9 | * FUNcube Dongle / Pro+ through [gr-funcube](https://github.com/dl1ksv/gr-funcube) 10 | * RTL2832U based DVB-T dongles through [librtlsdr](https://osmocom.org/projects/rtl-sdr/wiki) 11 | * RTL-TCP spectrum server (see librtlsdr project) 12 | * MSi2500 based DVB-T dongles through [libmirisdr](https://gitea.osmocom.org/sdr/libmirisdr) 13 | * SDRplay RSP through SDRplay API library 14 | * gnuradio .cfile input through libgnuradio-blocks 15 | * RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option), Cloud-IQ, and CloudSDR 16 | * AirSpy Wideband Receiver through [libairspy](https://github.com/airspy/airspyone_host) 17 | * CCCamp 2015 rad1o Badge through [libhackrf](https://github.com/greatscottgadgets/hackrf) 18 | * Great Scott Gadgets HackRF through [libhackrf](https://github.com/greatscottgadgets/hackrf) 19 | * Nuand LLC bladeRF through [libbladeRF library](https://www.nuand.com/libbladeRF-doc/) 20 | * Ettus USRP Devices through [Ettus UHD library](https://github.com/EttusResearch/uhd) 21 | * Fairwaves UmTRX through [Fairwaves' module for UHD](https://github.com/fairwaves/UHD-Fairwaves) 22 | * Fairwaves XTRX through [libxtrx](https://github.com/myriadrf/libxtrx) 23 | * Red Pitaya SDR transceiver 24 | * FreeSRP through [libfreesrp](https://github.com/myriadrf/libfreesrp) 25 | 26 | By using the gr-osmosdr block you can take advantage of a common software API in 27 | your application(s) independent of the underlying radio hardware. 28 | 29 | Homepage + Documentation 30 | ------------------------ 31 | 32 | For installation and usage guidelines please read the documentation available 33 | at 34 | 35 | For the impatient :) a short excerpt: 36 | 37 | The Gnu Radio block requires a recent gnuradio (>= v3.7) to be installed. 38 | 39 | Before building the block you have to make sure that all the dependencies 40 | (see list of supported devices above) you are intend to work with are 41 | properly installed. The build system of gr-osmosdr will recognize them and 42 | enable specific source/sink components thereafter. 43 | 44 | Please note: prior pulling a new version from git and compiling it, 45 | please do a `make uninstall` first to properly remove the previous version. 46 | 47 | Building with cmake: 48 | ``` 49 | git clone https://gitea.osmocom.org/sdr/gr-osmosdr 50 | cd gr-osmosdr/ 51 | mkdir build 52 | cd build/ 53 | cmake ../ 54 | make 55 | sudo make install 56 | sudo ldconfig 57 | ``` 58 | 59 | NOTE: The osmocom blocks will appear under *Sources* and *Sinks* categories 60 | in GRC menu. 61 | 62 | Forum 63 | ----- 64 | 65 | We welcome any gr-osmosdr related discussions in the 66 | [SDR](https://discourse.osmocom.org/c/sdr/) 67 | section of the osmocom discourse (web based Forum). 68 | 69 | Mailing List 70 | ------------ 71 | 72 | Discussions related to libosmocore are happening on the 73 | osmocom-sdr@lists.osmocom.org mailing list, please see 74 | for subscription 75 | options and the list archive. 76 | 77 | Please observe the [Osmocom Mailing List 78 | Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules) 79 | when posting. 80 | 81 | 82 | Issue tracker 83 | ------------- 84 | 85 | We are using the Osmocom redmine at 86 | 87 | Contributing 88 | ------------ 89 | 90 | We maintain our source code in a self-hosted instance of gitea at 91 | . You can send pull requests there, or send 92 | patches the old-fashioned way (git send-email) to the above-mentioned mailing list. 93 | -------------------------------------------------------------------------------- /apps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | include(GrPython) 21 | 22 | GR_PYTHON_INSTALL( 23 | FILES 24 | osmocom_siggen_base.py 25 | DESTINATION ${GR_PYTHON_DIR}/osmosdr 26 | ) 27 | 28 | GR_PYTHON_INSTALL( 29 | PROGRAMS 30 | osmocom_fft 31 | # osmocom_siggen 32 | osmocom_siggen_nogui 33 | # osmocom_spectrum_sense 34 | DESTINATION ${GR_RUNTIME_DIR} 35 | ) 36 | -------------------------------------------------------------------------------- /apps/osmocom_siggen_nogui: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # 3 | # Copyright 2008,2009,2011,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 | from gnuradio import gr 24 | from osmosdr import osmocom_siggen_base as osmocom_siggen 25 | import sys 26 | 27 | def main(): 28 | if gr.enable_realtime_scheduling() != gr.RT_OK: 29 | print("Note: failed to enable realtime scheduling, continuing") 30 | 31 | # Grab command line options and create top block 32 | try: 33 | (options, args) = osmocom_siggen.get_options() 34 | tb = osmocom_siggen.top_block(options, args) 35 | 36 | except RuntimeError as e: 37 | print(e) 38 | sys.exit(1) 39 | 40 | tb.start() 41 | input('Press Enter to quit: ') 42 | tb.stop() 43 | tb.wait() 44 | 45 | # Make sure to create the top block (tb) within a function: 46 | # That code in main will allow tb to go out of scope on return, 47 | # which will call the decontructor on usrp and stop transmit. 48 | # Whats odd is that grc works fine with tb in the __main__, 49 | # perhaps its because the try/except clauses around tb. 50 | if __name__ == "__main__": 51 | main() 52 | -------------------------------------------------------------------------------- /cmake/Modules/FindGnuradioFuncube.cmake: -------------------------------------------------------------------------------- 1 | if(NOT GNURADIO_FUNCUBE_FOUND) 2 | pkg_check_modules (GNURADIO_FUNCUBE_PKG libgnuradio-funcube) 3 | find_path(GNURADIO_FUNCUBE_INCLUDE_DIRS NAMES funcube/api.h 4 | PATHS 5 | ${GNURADIO_FUNCUBE_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(GNURADIO_FUNCUBE_LIBRARIES NAMES gnuradio-funcube 11 | PATHS 12 | ${GNURADIO_FUNCUBE_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(GNURADIO_FUNCUBE_INCLUDE_DIRS AND GNURADIO_FUNCUBE_LIBRARIES) 18 | set(GNURADIO_FUNCUBE_FOUND TRUE CACHE INTERNAL "gnuradio-funcube found") 19 | message(STATUS "Found gnuradio-funcube: ${GNURADIO_FUNCUBE_INCLUDE_DIRS}, ${GNURADIO_FUNCUBE_LIBRARIES}") 20 | else(GNURADIO_FUNCUBE_INCLUDE_DIRS AND GNURADIO_FUNCUBE_LIBRARIES) 21 | set(GNURADIO_FUNCUBE_FOUND FALSE CACHE INTERNAL "gnuradio-funcube found") 22 | message(STATUS "gnuradio-funcube not found.") 23 | endif(GNURADIO_FUNCUBE_INCLUDE_DIRS AND GNURADIO_FUNCUBE_LIBRARIES) 24 | 25 | mark_as_advanced(GNURADIO_FUNCUBE_LIBRARIES GNURADIO_FUNCUBE_INCLUDE_DIRS) 26 | 27 | endif(NOT GNURADIO_FUNCUBE_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibAIRSPY.cmake: -------------------------------------------------------------------------------- 1 | if(NOT PKG_CONFIG_FOUND) 2 | INCLUDE(FindPkgConfig) 3 | endif() 4 | PKG_CHECK_MODULES(PC_LIBAIRSPY libairspy) 5 | 6 | FIND_PATH( 7 | LIBAIRSPY_INCLUDE_DIRS 8 | NAMES libairspy/airspy.h 9 | HINTS $ENV{LIBAIRSPY_DIR}/include 10 | ${PC_LIBAIRSPY_INCLUDEDIR} 11 | PATHS /usr/local/include 12 | /usr/include 13 | ) 14 | 15 | FIND_LIBRARY( 16 | LIBAIRSPY_LIBRARIES 17 | NAMES airspy 18 | HINTS $ENV{LIBAIRSPY_DIR}/lib 19 | ${PC_LIBAIRSPY_LIBDIR} 20 | PATHS /usr/local/lib 21 | /usr/lib 22 | ) 23 | 24 | INCLUDE(FindPackageHandleStandardArgs) 25 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibAIRSPY DEFAULT_MSG LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS) 26 | MARK_AS_ADVANCED(LIBAIRSPY_LIBRARIES LIBAIRSPY_INCLUDE_DIRS) 27 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibAIRSPYHF.cmake: -------------------------------------------------------------------------------- 1 | if(NOT PKG_CONFIG_FOUND) 2 | INCLUDE(FindPkgConfig) 3 | endif() 4 | PKG_CHECK_MODULES(PC_LIBAIRSPYHF libairspyhf) 5 | 6 | FIND_PATH( 7 | LIBAIRSPYHF_INCLUDE_DIRS 8 | NAMES libairspyhf/airspyhf.h 9 | HINTS $ENV{LIBAIRSPYHF_DIR}/include 10 | ${PC_LIBAIRSPYHF_INCLUDEDIR} 11 | PATHS /usr/local/include 12 | /usr/include 13 | ) 14 | 15 | FIND_LIBRARY( 16 | LIBAIRSPYHF_LIBRARIES 17 | NAMES airspyhf 18 | HINTS $ENV{LIBAIRSPYHF_DIR}/lib 19 | ${PC_LIBAIRSPYHF_LIBDIR} 20 | PATHS /usr/local/lib 21 | /usr/lib 22 | ) 23 | 24 | INCLUDE(FindPackageHandleStandardArgs) 25 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibAIRSPYHF DEFAULT_MSG LIBAIRSPYHF_LIBRARIES LIBAIRSPYHF_INCLUDE_DIRS) 26 | MARK_AS_ADVANCED(LIBAIRSPYHF_LIBRARIES LIBAIRSPYHF_INCLUDE_DIRS) 27 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibFreeSRP.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBFREESRP_FOUND) 2 | pkg_check_modules (LIBFREESRP_PKG libfreesrp) 3 | find_path(LIBFREESRP_INCLUDE_DIRS NAMES freesrp.hpp 4 | PATHS 5 | ${LIBFREESRP_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(LIBFREESRP_LIBRARIES NAMES freesrp 11 | PATHS 12 | ${LIBFREESRP_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(LIBFREESRP_INCLUDE_DIRS AND LIBFREESRP_LIBRARIES) 18 | set(LIBFREESRP_FOUND TRUE CACHE INTERNAL "libfreesrp found") 19 | message(STATUS "Found libfreesrp: ${LIBFREESRP_INCLUDE_DIRS}, ${LIBFREESRP_LIBRARIES}") 20 | else(LIBFREESRP_INCLUDE_DIRS AND LIBFREESRP_LIBRARIES) 21 | set(LIBFREESRP_FOUND FALSE CACHE INTERNAL "libfreesrp found") 22 | message(STATUS "libfreesrp not found.") 23 | endif(LIBFREESRP_INCLUDE_DIRS AND LIBFREESRP_LIBRARIES) 24 | 25 | mark_as_advanced(LIBFREESRP_LIBRARIES LIBFREESRP_INCLUDE_DIRS) 26 | 27 | endif(NOT LIBFREESRP_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibHackRF.cmake: -------------------------------------------------------------------------------- 1 | if(NOT PKG_CONFIG_FOUND) 2 | INCLUDE(FindPkgConfig) 3 | endif() 4 | PKG_CHECK_MODULES(PC_LIBHACKRF libhackrf) 5 | 6 | FIND_PATH( 7 | LIBHACKRF_INCLUDE_DIRS 8 | NAMES libhackrf/hackrf.h 9 | HINTS $ENV{LIBHACKRF_DIR}/include 10 | ${PC_LIBHACKRF_INCLUDEDIR} 11 | PATHS /usr/local/include 12 | /usr/include 13 | ) 14 | 15 | FIND_LIBRARY( 16 | LIBHACKRF_LIBRARIES 17 | NAMES hackrf 18 | HINTS $ENV{LIBHACKRF_DIR}/lib 19 | ${PC_LIBHACKRF_LIBDIR} 20 | PATHS /usr/local/lib 21 | /usr/lib 22 | ) 23 | 24 | INCLUDE(FindPackageHandleStandardArgs) 25 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibHackRF DEFAULT_MSG LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIRS) 26 | MARK_AS_ADVANCED(LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIRS) 27 | 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibMiriSDR.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBMIRISDR_FOUND) 2 | pkg_check_modules (LIBMIRISDR_PKG libmirisdr) 3 | find_path(LIBMIRISDR_INCLUDE_DIRS NAMES mirisdr.h 4 | PATHS 5 | ${LIBMIRISDR_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(LIBMIRISDR_LIBRARIES NAMES mirisdr 11 | PATHS 12 | ${LIBMIRISDR_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) 18 | set(LIBMIRISDR_FOUND TRUE CACHE INTERNAL "libmirisdr found") 19 | message(STATUS "Found libmirisdr: ${LIBMIRISDR_INCLUDE_DIRS}, ${LIBMIRISDR_LIBRARIES}") 20 | else(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) 21 | set(LIBMIRISDR_FOUND FALSE CACHE INTERNAL "libmirisdr found") 22 | message(STATUS "libmirisdr not found.") 23 | endif(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES) 24 | 25 | mark_as_advanced(LIBMIRISDR_LIBRARIES LIBMIRISDR_INCLUDE_DIRS) 26 | 27 | endif(NOT LIBMIRISDR_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibRTLSDR.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBRTLSDR_FOUND) 2 | pkg_check_modules (LIBRTLSDR_PKG librtlsdr) 3 | find_path(LIBRTLSDR_INCLUDE_DIRS NAMES rtl-sdr.h 4 | PATHS 5 | ${LIBRTLSDR_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(LIBRTLSDR_LIBRARIES NAMES rtlsdr 11 | PATHS 12 | ${LIBRTLSDR_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(LIBRTLSDR_INCLUDE_DIRS AND LIBRTLSDR_LIBRARIES) 18 | set(LIBRTLSDR_FOUND TRUE CACHE INTERNAL "librtlsdr found") 19 | message(STATUS "Found librtlsdr: ${LIBRTLSDR_INCLUDE_DIRS}, ${LIBRTLSDR_LIBRARIES}") 20 | else(LIBRTLSDR_INCLUDE_DIRS AND LIBRTLSDR_LIBRARIES) 21 | set(LIBRTLSDR_FOUND FALSE CACHE INTERNAL "librtlsdr found") 22 | message(STATUS "librtlsdr not found.") 23 | endif(LIBRTLSDR_INCLUDE_DIRS AND LIBRTLSDR_LIBRARIES) 24 | 25 | mark_as_advanced(LIBRTLSDR_LIBRARIES LIBRTLSDR_INCLUDE_DIRS) 26 | 27 | endif(NOT LIBRTLSDR_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibSDRplay.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBSDRPLAY_FOUND) 2 | pkg_check_modules (LIBSDRPLAY_PKG libsdrplay) 3 | find_path(LIBSDRPLAY_INCLUDE_DIRS NAMES mirsdrapi-rsp.h 4 | PATHS 5 | ${LIBSDRPLAY_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(LIBSDRPLAY_LIBRARIES NAMES mirsdrapi-rsp 11 | PATHS 12 | ${LIBSDRPLAY_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(LIBSDRPLAY_INCLUDE_DIRS AND LIBSDRPLAY_LIBRARIES) 18 | set(LIBSDRPLAY_FOUND TRUE CACHE INTERNAL "libsdrplay found") 19 | message(STATUS "Found libsdrplay: ${LIBSDRPLAY_INCLUDE_DIRS}, ${LIBSDRPLAY_LIBRARIES}") 20 | else(LIBSDRPLAY_INCLUDE_DIRS AND LIBSDRPLAY_LIBRARIES) 21 | set(LIBSDRPLAY_FOUND FALSE CACHE INTERNAL "libsdrplay found") 22 | message(STATUS "libsdrplay not found.") 23 | endif(LIBSDRPLAY_INCLUDE_DIRS AND LIBSDRPLAY_LIBRARIES) 24 | 25 | mark_as_advanced(LIBSDRPLAY_LIBRARIES LIBSDRPLAY_INCLUDE_DIRS) 26 | 27 | endif(NOT LIBSDRPLAY_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibXTRX.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBXTRX_FOUND) 2 | pkg_check_modules (LIBXTRX_PKG libxtrx) 3 | find_path(LIBXTRX_INCLUDE_DIRS NAMES xtrx_api.h 4 | PATHS 5 | ${LIBXTRX_PKG_INCLUDE_DIRS} 6 | /usr/include 7 | /usr/local/include 8 | ) 9 | 10 | find_library(LIBXTRX_LIBRARIES NAMES xtrx 11 | PATHS 12 | ${LIBXTRX_PKG_LIBRARY_DIRS} 13 | /usr/lib 14 | /usr/local/lib 15 | ) 16 | 17 | if(LIBXTRX_INCLUDE_DIRS AND LIBXTRX_LIBRARIES) 18 | set(LIBXTRX_FOUND TRUE CACHE INTERNAL "libxtrx found") 19 | message(STATUS "Found libxtrx: ${LIBXTRX_INCLUDE_DIRS}, ${LIBXTRX_LIBRARIES}") 20 | else(LIBXTRX_INCLUDE_DIRS AND LIBXTRX_LIBRARIES) 21 | set(LIBXTRX_FOUND FALSE CACHE INTERNAL "libxtrx found") 22 | message(STATUS "libxtrx not found.") 23 | endif(LIBXTRX_INCLUDE_DIRS AND LIBXTRX_LIBRARIES) 24 | 25 | mark_as_advanced(LIBXTRX_LIBRARIES LIBXTRX_INCLUDE_DIRS) 26 | 27 | endif(NOT LIBXTRX_FOUND) 28 | -------------------------------------------------------------------------------- /cmake/Modules/FindLibbladeRF.cmake: -------------------------------------------------------------------------------- 1 | if(NOT LIBBLADERF_FOUND) 2 | pkg_check_modules (LIBBLADERF_PKG libbladeRF) 3 | if (LIBBLADERF_PKG_FOUND AND LIBBLADERF_PKG_VERSION VERSION_LESS "2") 4 | message( FATAL_ERROR "Install version 2 or greater of libbladeRF." 5 | " Current version ( ${LIBBLADERF_PKG_VERSION} ) is out of date." ) 6 | endif() 7 | find_path(LIBBLADERF_INCLUDE_DIRS NAMES libbladeRF.h 8 | PATHS 9 | ${LIBBLADERF_PKG_INCLUDE_DIRS} 10 | /usr/include 11 | /usr/local/include 12 | ) 13 | 14 | find_library(LIBBLADERF_LIBRARIES NAMES bladeRF 15 | PATHS 16 | ${LIBBLADERF_PKG_LIBRARY_DIRS} 17 | /usr/lib 18 | /usr/local/lib 19 | ) 20 | 21 | if(LIBBLADERF_INCLUDE_DIRS AND LIBBLADERF_LIBRARIES) 22 | set(LIBBLADERF_FOUND TRUE CACHE INTERNAL "libbladeRF found") 23 | message(STATUS "Found libbladeRF: ${LIBBLADERF_INCLUDE_DIRS}, ${LIBBLADERF_LIBRARIES}") 24 | else(LIBBLADERF_INCLUDE_DIRS AND LIBBLADERF_LIBRARIES) 25 | set(LIBBLADERF_FOUND FALSE CACHE INTERNAL "libbladeRF found") 26 | message(STATUS "libbladeRF not found.") 27 | endif(LIBBLADERF_INCLUDE_DIRS AND LIBBLADERF_LIBRARIES) 28 | 29 | mark_as_advanced(LIBBLADERF_LIBRARIES LIBBLADERF_INCLUDE_DIRS) 30 | 31 | endif(NOT LIBBLADERF_FOUND) 32 | -------------------------------------------------------------------------------- /cmake/Modules/FindUHD.cmake: -------------------------------------------------------------------------------- 1 | ######################################################################## 2 | # Find the library for the USRP Hardware Driver 3 | ######################################################################## 4 | 5 | INCLUDE(FindPkgConfig) 6 | PKG_CHECK_MODULES(PC_UHD uhd) 7 | 8 | FIND_PATH( 9 | UHD_INCLUDE_DIRS 10 | NAMES uhd/config.hpp 11 | HINTS $ENV{UHD_DIR}/include 12 | ${PC_UHD_INCLUDEDIR} 13 | PATHS /usr/local/include 14 | /usr/include 15 | ) 16 | 17 | FIND_LIBRARY( 18 | UHD_LIBRARIES 19 | NAMES uhd 20 | HINTS $ENV{UHD_DIR}/lib 21 | ${PC_UHD_LIBDIR} 22 | PATHS /usr/local/lib 23 | /usr/lib 24 | ) 25 | 26 | INCLUDE(FindPackageHandleStandardArgs) 27 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(UHD DEFAULT_MSG UHD_LIBRARIES UHD_INCLUDE_DIRS) 28 | MARK_AS_ADVANCED(UHD_LIBRARIES UHD_INCLUDE_DIRS) 29 | -------------------------------------------------------------------------------- /cmake/Modules/targetConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright 2018 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 | include(CMakeFindDependencyMacro) 21 | 22 | set(target_deps "@TARGET_DEPENDENCIES@") 23 | foreach(dep IN LISTS target_deps) 24 | find_dependency(${dep}) 25 | endforeach() 26 | include("${CMAKE_CURRENT_LIST_DIR}/@TARGET@Targets.cmake") 27 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: gr-osmosdr 2 | Section: libdevel 3 | Priority: optional 4 | Maintainer: Harald Welte 5 | Build-Depends: cmake, 6 | debhelper (>= 9.0.0~), 7 | dh-python, 8 | doxygen, 9 | gnuradio-dev (>=3.7.11), 10 | gr-fcdproplus (>=3.7.25.4b6464b-3) [!hurd-i386], 11 | gr-iqbal (>=0.37.2-8), 12 | libairspy-dev (>= 1.0.9~) [!hurd-i386], 13 | libairspyhf-dev [!hurd-i386], 14 | libbladerf-dev (>=0.2016.01~rc1) [!hurd-i386], 15 | libboost-dev, 16 | libboost-system-dev, 17 | libboost-thread-dev, 18 | libfreesrp-dev [!hurd-i386], 19 | libhackrf-dev [linux-any], 20 | liblog4cpp5-dev, 21 | libmirisdr-dev [!hurd-i386], 22 | libosmosdr-dev [!hurd-i386], 23 | librtlsdr-dev [!hurd-i386], 24 | libsoapysdr-dev, 25 | libuhd-dev (>=3.10), 26 | pkg-config, 27 | python-dev, 28 | python-soapysdr, 29 | swig 30 | X-Python-Version: >= 2.7, << 2.8 31 | Standards-Version: 4.1.0 32 | Homepage: https://osmocom.org/projects/gr-osmosdr/wiki 33 | Vcs-Git: https://gitea.osmocom.org/sdr/gr-osmosdr 34 | Vcs-Browser: https://gitea.osmocom.org/sdr/gr-osmosdr 35 | 36 | Package: gr-osmosdr 37 | Architecture: any 38 | Pre-Depends: ${misc:Pre-Depends} 39 | Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends} 40 | Recommends: gnuradio, gr-fosphor 41 | Description: Gnuradio blocks from the OsmoSDR project 42 | The Osmocom project is a family of projects regarding Open source 43 | mobile communications. 44 | . 45 | While primarily being developed for the OsmoSDR hardware, this block 46 | as well supports: 47 | - FUNcube Dongle through libgnuradio-fcd 48 | - FUNcube Dongle Pro+ through gr-fcdproplus 49 | - sysmocom OsmoSDR Devices through libosmosdr 50 | - RTL2832U based DVB-T dongles through librtlsdr 51 | - RTL-TCP spectrum server (see librtlsdr project) 52 | - MSi2500 based DVB-T dongles through libmirisdr 53 | - gnuradio .cfile input through libgnuradio-blocks 54 | - RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option) 55 | - Great Scott Gadgets HackRF through libhackrf 56 | - Nuand LLC bladeRF through libbladeRF library 57 | - Ettus USRP Devices through Ettus UHD library 58 | - Fairwaves UmTRX through Fairwaves' fork of UHD 59 | - AIRSPY Receiver 60 | - AIRSPY HF+ Receiver 61 | - SoapySDR support 62 | - Red Pitaya SDR transceiver (http://bazaar.redpitaya.com) 63 | - FreeSRP through libfreesrp 64 | . 65 | By using the OsmoSDR block you can take advantage of a common 66 | software API in your application(s) independent of the underlying 67 | radio hardware. 68 | 69 | Package: libgnuradio-osmosdr0.1.4 70 | Section: libs 71 | Architecture: any 72 | Pre-Depends: ${misc:Pre-Depends} 73 | Depends: ${misc:Depends}, ${shlibs:Depends} 74 | Multi-Arch: same 75 | Description: Gnuradio blocks from the OsmoSDR project - library 76 | The Osmocom project is a family of projects regarding Open source 77 | mobile communications. 78 | . 79 | This package contains the shared library. 80 | -------------------------------------------------------------------------------- /debian/gr-osmosdr.install: -------------------------------------------------------------------------------- 1 | usr/bin/* 2 | usr/include/* 3 | usr/lib/*/lib*.so 4 | usr/lib/*/pkgconfig/* 5 | usr/lib/python* 6 | usr/share/* 7 | -------------------------------------------------------------------------------- /debian/gr-osmosdr.manpages: -------------------------------------------------------------------------------- 1 | debian/osmocom_fft.1 2 | debian/osmocom_siggen.1 3 | debian/osmocom_siggen_nogui.1 4 | debian/osmocom_spectrum_sense.1 5 | -------------------------------------------------------------------------------- /debian/libgnuradio-osmosdr0.1.4.install: -------------------------------------------------------------------------------- 1 | usr/lib/*/lib*.so.* 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) 3 | export DEB_HOST_MULTIARCH 4 | DEB_DEBIAN_DIR=$(dir $(firstword $(MAKEFILE_LIST))) 5 | VER=$(shell dpkg-parsechangelog -l$(DEB_DEBIAN_DIR)/changelog \ 6 | | sed -rne 's,^Version: ([^-]+).*,\1,p') 7 | GITREV=$(shell echo $(VER) | sed -rne 's,[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.([0-f]+),\1,p') 8 | 9 | %: 10 | dh $@ --with python2 11 | 12 | override_dh_auto_configure: 13 | dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" -DPythonLibs_FIND_VERSION:STRING="2.7" -DPYTHON_EXECUTABLE:STRING="/usr/bin/python" 14 | 15 | override_dh_auto_install: 16 | dh_auto_install 17 | rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyc 18 | rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyo 19 | 20 | override_dh_makeshlibs: 21 | dh_makeshlibs -V 'libgnuradio-osmosdr0.1.4 (>= 0.1.4-13)' 22 | 23 | version-to-get: 24 | echo $(VER) is $(GITREV) 25 | 26 | get-orig-source: version-to-get 27 | git clone https://gitea.osmocom.org/sdr/gr-osmosdr 28 | cd gr-osmosdr && git archive --format=tar --prefix=gr-osmosdr-$(VER)/ $(GITREV) | xz > ../gr-osmosdr_$(VER).orig.tar.xz 29 | rm -rf gr-osmosdr 30 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | opts="downloadurlmangle=s/refs\/tags/snapshot/,uversionmangle=s|(.*)git|1|" \ 3 | http://cgit.osmocom.org/gr-osmosdr/refs/tags /gr-osmosdr/snapshot/gr-osmosdr-(\d.*)\.tar\.xz 4 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # Begin conditional configuration 22 | ######################################################################## 23 | if(ENABLE_DOXYGEN) 24 | 25 | ######################################################################## 26 | # Add subdirectories 27 | ######################################################################## 28 | add_subdirectory(doxygen) 29 | 30 | endif(ENABLE_DOXYGEN) 31 | -------------------------------------------------------------------------------- /docs/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file was generated by gr_modtool, a tool from the GNU Radio framework 4 | # This file is a part of gr-osmosdr 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 | # Create the doxygen configuration file 23 | ######################################################################## 24 | file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} top_srcdir) 25 | file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} top_builddir) 26 | file(TO_NATIVE_PATH ${CMAKE_SOURCE_DIR} abs_top_srcdir) 27 | file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR} abs_top_builddir) 28 | 29 | set(HAVE_DOT ${DOXYGEN_DOT_FOUND}) 30 | set(enable_html_docs YES) 31 | set(enable_latex_docs NO) 32 | set(enable_xml_docs YES) 33 | 34 | configure_file( 35 | ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 36 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 37 | @ONLY) 38 | 39 | set(BUILT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/xml ${CMAKE_CURRENT_BINARY_DIR}/html) 40 | 41 | ######################################################################## 42 | # Make and install doxygen docs 43 | ######################################################################## 44 | add_custom_command( 45 | OUTPUT ${BUILT_DIRS} 46 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 47 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 48 | COMMENT "Generating documentation with doxygen" 49 | ) 50 | 51 | add_custom_target(doxygen_target ALL DEPENDS ${BUILT_DIRS}) 52 | 53 | install(DIRECTORY ${BUILT_DIRS} DESTINATION ${GR_PKG_DOC_DIR}) 54 | -------------------------------------------------------------------------------- /docs/doxygen/doxyxml/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file was generated by gr_modtool, a tool from the GNU Radio framework 5 | # This file is a part of gr-osmosdr 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 | Python interface to contents of doxygen xml documentation. 24 | 25 | Example use: 26 | See the contents of the example folder for the C++ and 27 | doxygen-generated xml used in this example. 28 | 29 | >>> # Parse the doxygen docs. 30 | >>> import os 31 | >>> this_dir = os.path.dirname(globals()['__file__']) 32 | >>> xml_path = this_dir + "/example/xml/" 33 | >>> di = DoxyIndex(xml_path) 34 | 35 | Get a list of all top-level objects. 36 | 37 | >>> print([mem.name() for mem in di.members()]) 38 | [u'Aadvark', u'aadvarky_enough', u'main'] 39 | 40 | Get all functions. 41 | 42 | >>> print([mem.name() for mem in di.in_category(DoxyFunction)]) 43 | [u'aadvarky_enough', u'main'] 44 | 45 | Check if an object is present. 46 | 47 | >>> di.has_member(u'Aadvark') 48 | True 49 | >>> di.has_member(u'Fish') 50 | False 51 | 52 | Get an item by name and check its properties. 53 | 54 | >>> aad = di.get_member(u'Aadvark') 55 | >>> print(aad.brief_description) 56 | Models the mammal Aadvark. 57 | >>> print(aad.detailed_description) 58 | Sadly the model is incomplete and cannot capture all aspects of an aadvark yet. 59 | 60 | This line is uninformative and is only to test line breaks in the comments. 61 | >>> [mem.name() for mem in aad.members()] 62 | [u'aadvarkness', u'print', u'Aadvark', u'get_aadvarkness'] 63 | >>> aad.get_member(u'print').brief_description 64 | u'Outputs the vital aadvark statistics.' 65 | 66 | """ 67 | from __future__ import unicode_literals 68 | 69 | from .doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther 70 | 71 | def _test(): 72 | import os 73 | this_dir = os.path.dirname(globals()['__file__']) 74 | xml_path = this_dir + "/example/xml/" 75 | di = DoxyIndex(xml_path) 76 | # Get the Aadvark class 77 | aad = di.get_member('Aadvark') 78 | aad.brief_description 79 | import doctest 80 | return doctest.testmod() 81 | 82 | if __name__ == "__main__": 83 | _test() 84 | 85 | -------------------------------------------------------------------------------- /docs/doxygen/doxyxml/generated/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Contains generated files produced by generateDS.py. 3 | 4 | These do the real work of parsing the doxygen xml files but the 5 | resultant classes are not very friendly to navigate so the rest of the 6 | doxyxml module processes them further. 7 | """ 8 | from __future__ import unicode_literals 9 | -------------------------------------------------------------------------------- /docs/doxygen/doxyxml/generated/index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Generated Mon Feb 9 19:08:05 2009 by generateDS.py. 5 | """ 6 | from __future__ import absolute_import 7 | from __future__ import unicode_literals 8 | 9 | from xml.dom import minidom 10 | 11 | import os 12 | import sys 13 | from . import compound 14 | 15 | from . import indexsuper as supermod 16 | 17 | class DoxygenTypeSub(supermod.DoxygenType): 18 | def __init__(self, version=None, compound=None): 19 | supermod.DoxygenType.__init__(self, version, compound) 20 | 21 | def find_compounds_and_members(self, details): 22 | """ 23 | Returns a list of all compounds and their members which match details 24 | """ 25 | 26 | results = [] 27 | for compound in self.compound: 28 | members = compound.find_members(details) 29 | if members: 30 | results.append([compound, members]) 31 | else: 32 | if details.match(compound): 33 | results.append([compound, []]) 34 | 35 | return results 36 | 37 | supermod.DoxygenType.subclass = DoxygenTypeSub 38 | # end class DoxygenTypeSub 39 | 40 | 41 | class CompoundTypeSub(supermod.CompoundType): 42 | def __init__(self, kind=None, refid=None, name='', member=None): 43 | supermod.CompoundType.__init__(self, kind, refid, name, member) 44 | 45 | def find_members(self, details): 46 | """ 47 | Returns a list of all members which match details 48 | """ 49 | 50 | results = [] 51 | 52 | for member in self.member: 53 | if details.match(member): 54 | results.append(member) 55 | 56 | return results 57 | 58 | supermod.CompoundType.subclass = CompoundTypeSub 59 | # end class CompoundTypeSub 60 | 61 | 62 | class MemberTypeSub(supermod.MemberType): 63 | 64 | def __init__(self, kind=None, refid=None, name=''): 65 | supermod.MemberType.__init__(self, kind, refid, name) 66 | 67 | supermod.MemberType.subclass = MemberTypeSub 68 | # end class MemberTypeSub 69 | 70 | 71 | def parse(inFilename): 72 | 73 | doc = minidom.parse(inFilename) 74 | rootNode = doc.documentElement 75 | rootObj = supermod.DoxygenType.factory() 76 | rootObj.build(rootNode) 77 | 78 | return rootObj 79 | 80 | -------------------------------------------------------------------------------- /docs/doxygen/doxyxml/text.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2010 Free Software Foundation, Inc. 3 | # 4 | # This file was generated by gr_modtool, a tool from the GNU Radio framework 5 | # This file is a part of gr-osmosdr 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 | Utilities for extracting text from generated classes. 24 | """ 25 | from __future__ import unicode_literals 26 | 27 | def is_string(txt): 28 | if isinstance(txt, str): 29 | return True 30 | try: 31 | if isinstance(txt, str): 32 | return True 33 | except NameError: 34 | pass 35 | return False 36 | 37 | def description(obj): 38 | if obj is None: 39 | return None 40 | return description_bit(obj).strip() 41 | 42 | def description_bit(obj): 43 | if hasattr(obj, 'content'): 44 | contents = [description_bit(item) for item in obj.content] 45 | result = ''.join(contents) 46 | elif hasattr(obj, 'content_'): 47 | contents = [description_bit(item) for item in obj.content_] 48 | result = ''.join(contents) 49 | elif hasattr(obj, 'value'): 50 | result = description_bit(obj.value) 51 | elif is_string(obj): 52 | return obj 53 | else: 54 | raise Exception('Expecting a string or something with content, content_ or value attribute') 55 | # If this bit is a paragraph then add one some line breaks. 56 | if hasattr(obj, 'name') and obj.name == 'para': 57 | result += "\n\n" 58 | return result 59 | -------------------------------------------------------------------------------- /docs/doxygen/other/group_defs.dox: -------------------------------------------------------------------------------- 1 | /*! 2 | * \defgroup block GNU Radio TEST C++ Signal Processing Blocks 3 | * \brief All C++ blocks that can be used from the TEST GNU Radio 4 | * module are listed here or in the subcategories below. 5 | * 6 | */ 7 | 8 | -------------------------------------------------------------------------------- /docs/doxygen/other/main_page.dox: -------------------------------------------------------------------------------- 1 | /*! \mainpage 2 | 3 | Welcome to the GNU Radio TEST Block 4 | 5 | This is the intro page for the Doxygen manual generated for the TEST 6 | block (docs/doxygen/other/main_page.dox). Edit it to add more detailed 7 | documentation about the new GNU Radio modules contained in this 8 | project. 9 | 10 | */ 11 | -------------------------------------------------------------------------------- /docs/doxygen/pydoc_macros.h: -------------------------------------------------------------------------------- 1 | #ifndef PYDOC_MACROS_H 2 | #define PYDOC_MACROS_H 3 | 4 | #define __EXPAND(x) x 5 | #define __COUNT(_1, _2, _3, _4, _5, _6, _7, COUNT, ...) COUNT 6 | #define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1)) 7 | #define __CAT1(a, b) a##b 8 | #define __CAT2(a, b) __CAT1(a, b) 9 | #define __DOC1(n1) __doc_##n1 10 | #define __DOC2(n1, n2) __doc_##n1##_##n2 11 | #define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 12 | #define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 13 | #define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5 14 | #define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6 15 | #define __DOC7(n1, n2, n3, n4, n5, n6, n7) \ 16 | __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7 17 | #define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) 18 | 19 | #endif // PYDOC_MACROS_H -------------------------------------------------------------------------------- /grc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # Rules for generating the source and sink yml wrappers 22 | ######################################################################## 23 | include(GrPython) 24 | 25 | macro(GEN_BLOCK_YAML _generator _yaml_block) 26 | set(generator ${CMAKE_CURRENT_SOURCE_DIR}/${_generator}) 27 | set(yaml_block ${CMAKE_CURRENT_BINARY_DIR}/${_yaml_block}) 28 | list(APPEND yaml_blocks ${yaml_block}) 29 | add_custom_command( 30 | DEPENDS ${generator} OUTPUT ${yaml_block} 31 | COMMAND ${PYTHON_EXECUTABLE} ${generator} ${yaml_block} 32 | ) 33 | endmacro(GEN_BLOCK_YAML) 34 | 35 | GEN_BLOCK_YAML(gen_osmosdr_blocks.py rtlsdr_source.block.yml) 36 | GEN_BLOCK_YAML(gen_osmosdr_blocks.py osmosdr_source.block.yml) 37 | GEN_BLOCK_YAML(gen_osmosdr_blocks.py osmosdr_sink.block.yml) 38 | 39 | add_custom_target(osmosdr_grc_yaml_blocks ALL DEPENDS ${yaml_blocks}) 40 | 41 | install(FILES 42 | ${yaml_blocks} 43 | DESTINATION share/gnuradio/grc/blocks 44 | ) 45 | -------------------------------------------------------------------------------- /include/osmosdr/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | pimpl.h 26 | ranges.h 27 | time_spec.h 28 | device.h 29 | source.h 30 | sink.h 31 | DESTINATION include/osmosdr 32 | ) 33 | -------------------------------------------------------------------------------- /include/osmosdr/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_OSMOSDR_API_H 23 | #define INCLUDED_OSMOSDR_API_H 24 | 25 | #include 26 | 27 | #ifdef gnuradio_osmosdr_EXPORTS 28 | # define OSMOSDR_API __GR_ATTR_EXPORT 29 | #else 30 | # define OSMOSDR_API __GR_ATTR_IMPORT 31 | #endif 32 | 33 | #endif /* INCLUDED_OSMOSDR_API_H */ 34 | -------------------------------------------------------------------------------- /include/osmosdr/device.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef INCLUDED_OSMOSDR_DEVICE_H 22 | #define INCLUDED_OSMOSDR_DEVICE_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | typedef std::map string_string_dict_t; 34 | 35 | namespace osmosdr { 36 | 37 | /*! 38 | * Mapping of key/value pairs for locating devices on the system. 39 | * When left empty, the device discovery routines will search 40 | * all available transports on the system (ethernet, usb...). 41 | * 42 | * The logical device can also be used to pass arguments into 43 | * the transport layer control to set (for example) buffer sizes. 44 | * 45 | * An arguments string, is a way to represent a device address 46 | * using a single string with delimiter characters. 47 | */ 48 | class OSMOSDR_API device_t : public string_string_dict_t 49 | { 50 | public: 51 | /*! 52 | * Create a logical device from an args string. 53 | * \param args the arguments string 54 | */ 55 | device_t(const std::string &args = ""); 56 | 57 | /*! 58 | * Convert a logical device into a pretty print string. 59 | * \return a printable string representing the device 60 | */ 61 | std::string to_pp_string(void) const; 62 | 63 | /*! 64 | * Convert the logical device into an args string. 65 | * The args string contains delimiter symbols. 66 | * \return a string with delimiter markup 67 | */ 68 | std::string to_string(void) const; 69 | 70 | /*! 71 | * Lexically cast a parameter to the specified type, 72 | * or use the default value if the key is not found. 73 | * \param key the key as one of the parameters 74 | * \param def the value to use when key is not present 75 | * \return the casted value as type T or the default 76 | * \throw error when the parameter cannot be casted 77 | */ 78 | template T cast(const std::string &key, const T &def) const 79 | { 80 | if (!this->count(key)) return def; 81 | try { return boost::lexical_cast(this->at(key)); } 82 | catch(const boost::bad_lexical_cast &) { 83 | throw std::runtime_error("cannot cast " + key + " = " + this->at(key)); 84 | } 85 | } 86 | }; 87 | 88 | //! A typedef for a vector of logical devices 89 | typedef std::vector devices_t; 90 | 91 | /*! 92 | * The device interface represents the underyling hardware. 93 | * The api allows for discovery, configuration, and streaming. 94 | */ 95 | class OSMOSDR_API device : boost::noncopyable 96 | { 97 | public: 98 | /*! 99 | * \brief Find logical radio devices attached to the host. 100 | * 101 | * The device hint should be used to narrow down the search 102 | * to particular transport types and/or transport arguments. 103 | * 104 | * The device hint "nofake" switches off dummy devices created 105 | * by "file" (and other) implementations. 106 | * 107 | * \param hint a partially (or fully) filled in logical device 108 | * \return a vector of logical devices for all radios on the system 109 | */ 110 | static devices_t find(const device_t &hint = osmosdr::device_t()); 111 | }; 112 | 113 | } //namespace osmosdr 114 | 115 | #endif /* INCLUDED_OSMOSDR_DEVICE_H */ 116 | -------------------------------------------------------------------------------- /include/osmosdr/pimpl.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 Ettus Research LLC 3 | // 4 | // This program 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 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program 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 15 | // along with this program. If not, see . 16 | // 17 | 18 | #ifndef INCLUDED_OSMOSDR_PIMPL_H 19 | #define INCLUDED_OSMOSDR_PIMPL_H 20 | 21 | #include 22 | 23 | /*! \file pimpl.h 24 | * "Pimpl idiom" (pointer to implementation idiom). 25 | * The OSMOSDR_PIMPL_* macros simplify code overhead for declaring and making pimpls. 26 | * 27 | * Each pimpl is implemented as a shared pointer to the implementation: 28 | * - The container class will not have to deallocate the pimpl. 29 | * - The container class will use the pimpl as a regular pointer. 30 | * - Usage: _impl->method(arg0, arg1) 31 | * - Usage: _impl->member = value; 32 | * 33 | * \see http://en.wikipedia.org/wiki/Opaque_pointer 34 | */ 35 | 36 | /*! 37 | * Make a declaration for a pimpl in a header file. 38 | * - Usage: OSMOSDR_PIMPL_DECL(impl) _impl; 39 | * \param _name the name of the pimpl class 40 | */ 41 | #define OSMOSDR_PIMPL_DECL(_name) \ 42 | struct _name; std::shared_ptr<_name> 43 | 44 | /*! 45 | * Make an instance of a pimpl in a source file. 46 | * - Usage: _impl = OSMOSDR_PIMPL_MAKE(impl, ()); 47 | * - Usage: _impl = OSMOSDR_PIMPL_MAKE(impl, (a0, a1)); 48 | * \param _name the name of the pimpl class 49 | * \param _args the constructor args for the pimpl 50 | */ 51 | #define OSMOSDR_PIMPL_MAKE(_name, _args) \ 52 | std::shared_ptr<_name>(new _name _args) 53 | 54 | #endif /* INCLUDED_OSMOSDR_PIMPL_H */ 55 | -------------------------------------------------------------------------------- /include/osmosdr/ranges.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010-2011 Ettus Research LLC 3 | // 4 | // This program 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 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program 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 15 | // along with this program. If not, see . 16 | // 17 | 18 | #ifndef INCLUDED_OSMOSDR_RANGES_H 19 | #define INCLUDED_OSMOSDR_RANGES_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | namespace osmosdr{ 27 | 28 | //! A wildcard motherboard index 29 | static const size_t ALL_MBOARDS = size_t(~0); 30 | 31 | //! A wildcard channel index 32 | static const size_t ALL_CHANS = size_t(~0); 33 | 34 | /*! 35 | * A range object describes a set of discrete values of the form: 36 | * y = start + step*n, where n is an integer between 0 and (stop - start)/step 37 | */ 38 | class OSMOSDR_API range_t{ 39 | public: 40 | 41 | /*! 42 | * Create a range from a single value. 43 | * The step size will be taken as zero. 44 | * \param value the only possible value in this range 45 | */ 46 | range_t(double value = 0); 47 | 48 | /*! 49 | * Create a range from a full set of values. 50 | * A step size of zero implies infinite precision. 51 | * \param start the minimum value for this range 52 | * \param stop the maximum value for this range 53 | * \param step the step size for this range 54 | */ 55 | range_t(double start, double stop, double step = 0); 56 | 57 | //! Get the start value for this range. 58 | double start(void) const; 59 | 60 | //! Get the stop value for this range. 61 | double stop(void) const; 62 | 63 | //! Get the step value for this range. 64 | double step(void) const; 65 | 66 | //! Convert this range to a printable string 67 | const std::string to_pp_string(void) const; 68 | 69 | private: OSMOSDR_PIMPL_DECL(impl) _impl; 70 | }; 71 | 72 | /*! 73 | * A meta-range object holds a list of individual ranges. 74 | */ 75 | struct OSMOSDR_API meta_range_t : std::vector{ 76 | 77 | //! A default constructor for an empty meta-range 78 | meta_range_t(void); 79 | 80 | /*! 81 | * Input iterator constructor: 82 | * Makes boost::assign::list_of work. 83 | * \param first the begin iterator 84 | * \param last the end iterator 85 | */ 86 | template 87 | meta_range_t(InputIterator first, InputIterator last): 88 | std::vector(first, last){ /* NOP */ } 89 | 90 | /*! 91 | * A convenience constructor for a single range. 92 | * A step size of zero implies infinite precision. 93 | * \param start the minimum value for this range 94 | * \param stop the maximum value for this range 95 | * \param step the step size for this range 96 | */ 97 | meta_range_t(double start, double stop, double step = 0); 98 | 99 | //! Get the overall start value for this meta-range. 100 | double start(void) const; 101 | 102 | //! Get the overall stop value for this meta-range. 103 | double stop(void) const; 104 | 105 | //! Get the overall step value for this meta-range. 106 | double step(void) const; 107 | 108 | /*! 109 | * Clip the target value to a possible range value. 110 | * \param value the value to clip to this range 111 | * \param clip_step if true, clip to steps as well 112 | * \return a value that is in one of the ranges 113 | */ 114 | double clip(double value, bool clip_step = false) const; 115 | 116 | /*! return a vector containing all values of the range */ 117 | std::vector values() const; 118 | 119 | //! Convert this meta-range to a printable string 120 | const std::string to_pp_string(void) const; 121 | 122 | }; 123 | 124 | typedef meta_range_t gain_range_t; 125 | typedef meta_range_t freq_range_t; 126 | 127 | } //namespace osmosdr 128 | 129 | #endif /* INCLUDED_OSMOSDR_RANGES_H */ 130 | -------------------------------------------------------------------------------- /lib/airspy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBAIRSPY_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | gnuradio::gnuradio-filter 31 | ${Gnuradio-blocks_LIBRARIES} 32 | ${LIBAIRSPY_LIBRARIES} 33 | ) 34 | 35 | list(APPEND gr_osmosdr_srcs 36 | ${CMAKE_CURRENT_SOURCE_DIR}/airspy_source_c.cc 37 | ) 38 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 39 | -------------------------------------------------------------------------------- /lib/airspy/airspy_fir_kernels.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define KERNEL_16_110_LEN 7 4 | const float KERNEL_16_110[] = 5 | { 6 | -0.031835079193115234f, 7 | 0.000000000000000000f, 8 | 0.281831502914428710f, 9 | 0.500007271766662600f, 10 | 0.281831502914428710f, 11 | 0.000000000000000000f, 12 | -0.031835079193115234f 13 | }; 14 | 15 | #define KERNEL_8_100_LEN 11 16 | const float KERNEL_8_100[] = 17 | { 18 | 0.006633400917053223f, 19 | 0.000000000000000000f, 20 | -0.051035523414611816f, 21 | 0.000000000000000000f, 22 | 0.294403314590454100f, 23 | 0.499997496604919430f, 24 | 0.294403314590454100f, 25 | 0.000000000000000000f, 26 | -0.051035523414611816f, 27 | 0.000000000000000000f, 28 | 0.006633400917053223f 29 | }; 30 | 31 | #define KERNEL_4_90_LEN 15 32 | const float KERNEL_4_90[] = 33 | { 34 | -0.002474188804626465f, 35 | 0.000000000000000000f, 36 | 0.016965746879577637f, 37 | 0.000000000000000000f, 38 | -0.067680597305297852f, 39 | 0.000000000000000000f, 40 | 0.303180575370788570f, 41 | 0.500017046928405760f, 42 | 0.303180575370788570f, 43 | 0.000000000000000000f, 44 | -0.067680597305297852f, 45 | 0.000000000000000000f, 46 | 0.016965746879577637f, 47 | 0.000000000000000000f, 48 | -0.002474188804626465f 49 | }; 50 | 51 | #define KERNEL_2_80_LEN 47 52 | const float KERNEL_2_80[KERNEL_2_80_LEN] = 53 | { 54 | -0.000198006629943848f, 55 | 0.000000000000000000f, 56 | 0.000576853752136230f, 57 | 0.000000000000000000f, 58 | -0.001352190971374512f, 59 | 0.000000000000000000f, 60 | 0.002729177474975586f, 61 | 0.000000000000000000f, 62 | -0.004988193511962891f, 63 | 0.000000000000000000f, 64 | 0.008499503135681152f, 65 | 0.000000000000000000f, 66 | -0.013788580894470215f, 67 | 0.000000000000000000f, 68 | 0.021713137626647949f, 69 | 0.000000000000000000f, 70 | -0.033980011940002441f, 71 | 0.000000000000000000f, 72 | 0.054944872856140137f, 73 | 0.000000000000000000f, 74 | -0.100657463073730470f, 75 | 0.000000000000000000f, 76 | 0.316457390785217290f, 77 | 0.500000000000000000f, 78 | 0.316457390785217290f, 79 | 0.000000000000000000f, 80 | -0.100657463073730470f, 81 | 0.000000000000000000f, 82 | 0.054944872856140137f, 83 | 0.000000000000000000f, 84 | -0.033980011940002441f, 85 | 0.000000000000000000f, 86 | 0.021713137626647949f, 87 | 0.000000000000000000f, 88 | -0.013788580894470215f, 89 | 0.000000000000000000f, 90 | 0.008499503135681152f, 91 | 0.000000000000000000f, 92 | -0.004988193511962891f, 93 | 0.000000000000000000f, 94 | 0.002729177474975586f, 95 | 0.000000000000000000f, 96 | -0.001352190971374512f, 97 | 0.000000000000000000f, 98 | 0.000576853752136230f, 99 | 0.000000000000000000f, 100 | -0.000198006629943848f 101 | }; 102 | -------------------------------------------------------------------------------- /lib/airspyhf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBAIRSPYHF_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${Gnuradio-blocks_LIBRARIES} 31 | ${LIBAIRSPYHF_LIBRARIES} 32 | ) 33 | 34 | list(APPEND gr_osmosdr_srcs 35 | ${CMAKE_CURRENT_SOURCE_DIR}/airspyhf_source_c.cc 36 | ) 37 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 38 | -------------------------------------------------------------------------------- /lib/airspyhf/airspyhf_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2013 Dimitri Stolnikov 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 | #ifndef INCLUDED_AIRSPYHF_SOURCE_C_H 23 | #define INCLUDED_AIRSPYHF_SOURCE_C_H 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include 33 | 34 | #include "source_iface.h" 35 | 36 | class airspyhf_source_c; 37 | 38 | typedef std::shared_ptr airspyhf_source_c_sptr; 39 | 40 | /*! 41 | * \brief Return a shared_ptr to a new instance of airspyhf_source_c. 42 | * 43 | * To avoid accidental use of raw pointers, airspyhf_source_c's 44 | * constructor is private. make_airspyhf_source_c is the public 45 | * interface for creating new instances. 46 | */ 47 | airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args = ""); 48 | 49 | /*! 50 | * \brief Provides a stream of complex samples. 51 | * \ingroup block 52 | */ 53 | class airspyhf_source_c : 54 | public gr::sync_block, 55 | public source_iface 56 | { 57 | private: 58 | // The friend declaration allows make_airspyhf_source_c to 59 | // access the private constructor. 60 | 61 | friend airspyhf_source_c_sptr make_airspyhf_source_c (const std::string & args); 62 | 63 | airspyhf_source_c (const std::string & args); 64 | 65 | public: 66 | ~airspyhf_source_c (); 67 | 68 | bool start(); 69 | bool stop(); 70 | 71 | int work( int noutput_items, 72 | gr_vector_const_void_star &input_items, 73 | gr_vector_void_star &output_items ); 74 | 75 | static std::vector< std::string > get_devices(); 76 | 77 | size_t get_num_channels( void ); 78 | 79 | osmosdr::meta_range_t get_sample_rates( void ); 80 | double set_sample_rate( double rate ); 81 | double get_sample_rate( void ); 82 | 83 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 84 | double set_center_freq( double freq, size_t chan = 0 ); 85 | double get_center_freq( size_t chan = 0 ); 86 | double set_freq_corr( double ppm, size_t chan = 0 ); 87 | double get_freq_corr( size_t chan = 0 ); 88 | 89 | std::vector get_gain_names( size_t chan = 0 ); 90 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 91 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 92 | double set_gain( double gain, size_t chan = 0 ); 93 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 94 | double get_gain( size_t chan = 0 ); 95 | double get_gain( const std::string & name, size_t chan = 0 ); 96 | 97 | std::vector< std::string > get_antennas( size_t chan = 0 ); 98 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 99 | std::string get_antenna( size_t chan = 0 ); 100 | 101 | 102 | private: 103 | static int _airspyhf_rx_callback(airspyhf_transfer_t* transfer); 104 | int airspyhf_rx_callback(void *samples, int sample_count); 105 | 106 | airspyhf_device *_dev; 107 | 108 | boost::circular_buffer *_fifo; 109 | std::mutex _fifo_lock; 110 | std::condition_variable _samp_avail; 111 | 112 | std::vector< std::pair > _sample_rates; 113 | double _sample_rate; 114 | double _center_freq; 115 | double _freq_corr; 116 | }; 117 | 118 | #endif /* INCLUDED_AIRSPY_SOURCE_C_H */ 119 | -------------------------------------------------------------------------------- /lib/arg_helpers.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef OSMOSDR_ARG_HELPERS_H 22 | #define OSMOSDR_ARG_HELPERS_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | typedef std::map< std::string, std::string > dict_t; 35 | typedef std::pair< std::string, std::string > pair_t; 36 | 37 | inline std::string dict_to_args_string( const dict_t &d ) 38 | { 39 | std::string out; 40 | for (const pair_t pair : d) 41 | { 42 | if (not out.empty()) out += ","; 43 | out += pair.first + "='" + pair.second + "'"; 44 | } 45 | return out; 46 | } 47 | 48 | inline std::vector< std::string > args_to_vector( const std::string &args ) 49 | { 50 | std::vector< std::string > result; 51 | 52 | boost::escaped_list_separator separator("\\", " ", "'"); 53 | typedef boost::tokenizer< boost::escaped_list_separator > tokenizer_t; 54 | tokenizer_t tokens(args, separator); 55 | 56 | for (std::string token : tokens) 57 | result.push_back(token); 58 | 59 | return result; 60 | } 61 | 62 | inline std::vector< std::string > params_to_vector( const std::string ¶ms ) 63 | { 64 | std::vector< std::string > result; 65 | 66 | boost::escaped_list_separator separator("\\", ",", "'"); 67 | typedef boost::tokenizer< boost::escaped_list_separator > tokenizer_t; 68 | tokenizer_t tokens(params, separator); 69 | 70 | for (std::string token : tokens) 71 | result.push_back(token); 72 | 73 | return result; 74 | } 75 | 76 | inline pair_t param_to_pair( const std::string ¶m ) 77 | { 78 | pair_t result; 79 | 80 | std::size_t pos = param.find('='); 81 | if(pos != std::string::npos) 82 | { 83 | result.first = param.substr(0, pos); 84 | result.second = param.substr(pos + 1); 85 | } 86 | else 87 | { 88 | result.first = param; 89 | result.second = ""; 90 | } 91 | 92 | return result; 93 | } 94 | 95 | inline dict_t params_to_dict( const std::string ¶ms ) 96 | { 97 | dict_t result; 98 | 99 | std::vector< std::string > param_list = params_to_vector( params ); 100 | for (std::string param : param_list) 101 | { 102 | pair_t pair = param_to_pair( param ); 103 | std::string value = pair.second; 104 | if (value.length() && value[0] == '\'' && value[ value.length() - 1 ] == '\'') 105 | value = value.substr(1, value.length() - 1); 106 | result[ pair.first ] = value; 107 | } 108 | 109 | return result; 110 | } 111 | 112 | struct is_nchan_argument 113 | { 114 | bool operator ()(const std::string &str) 115 | { 116 | return str.find("numchan=") == 0; 117 | } 118 | }; 119 | 120 | inline gr::io_signature::sptr args_to_io_signature( const std::string &args ) 121 | { 122 | size_t max_nchan = 0; 123 | size_t dev_nchan = 0; 124 | std::vector< std::string > arg_list = args_to_vector( args ); 125 | 126 | for (std::string arg : arg_list) 127 | { 128 | if ( arg.find( "numchan=" ) == 0 ) // try to parse global nchan value 129 | { 130 | pair_t pair = param_to_pair( arg ); 131 | max_nchan = boost::lexical_cast( pair.second ); 132 | } 133 | } 134 | 135 | arg_list.erase( std::remove_if( // remove any global nchan tokens 136 | arg_list.begin(), 137 | arg_list.end(), 138 | is_nchan_argument() ), 139 | arg_list.end() ); 140 | 141 | // try to parse device specific nchan values, assume 1 channel if none given 142 | 143 | for (std::string arg : arg_list) 144 | { 145 | dict_t dict = params_to_dict(arg); 146 | if (dict.count("nchan")) 147 | { 148 | dev_nchan += boost::lexical_cast( dict["nchan"] ); 149 | } 150 | else // no channels given via args 151 | { 152 | dev_nchan++; // assume one channel 153 | } 154 | } 155 | 156 | // if at least one nchan was given, perform a sanity check 157 | if ( max_nchan && dev_nchan && max_nchan != dev_nchan ) 158 | throw std::runtime_error("Wrong device arguments specified. Missing nchan?"); 159 | 160 | const size_t nchan = std::max(dev_nchan, 1); // assume at least one 161 | return gr::io_signature::make(nchan, nchan, sizeof(gr_complex)); 162 | } 163 | 164 | #endif // OSMOSDR_ARG_HELPERS_H 165 | -------------------------------------------------------------------------------- /lib/bladerf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2013 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBBLADERF_INCLUDE_DIRS} 27 | ${Volk_INCLUDE_DIRS} 28 | ) 29 | 30 | APPEND_LIB_LIST( 31 | ${LIBBLADERF_LIBRARIES} 32 | ${Volk_LIBRARIES} 33 | ) 34 | 35 | list(APPEND gr_osmosdr_srcs 36 | ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_source_c.cc 37 | ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_sink_c.cc 38 | ${CMAKE_CURRENT_SOURCE_DIR}/bladerf_common.cc 39 | ) 40 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 41 | -------------------------------------------------------------------------------- /lib/bladerf/bladerf_compat.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Nuand LLC 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 | #ifndef INCLUDED_BLADERF_COMPAT_H 21 | #define INCLUDED_BLADERF_COMPAT_H 22 | 23 | #if defined(LIBBLADERF_API_VERSION) && (LIBBLADERF_API_VERSION < 0x01080100) 24 | #warning Old libbladeRF detected: using compatibility workarounds. 25 | 26 | #define BLADERF_COMPATIBILITY 27 | 28 | /* New libbladeRF supports multiple channels, via various enums. */ 29 | typedef bladerf_module bladerf_channel; 30 | #define BLADERF_CHANNEL_RX(ch) BLADERF_MODULE_RX 31 | #define BLADERF_CHANNEL_TX(ch) BLADERF_MODULE_TX 32 | #define BLADERF_CHANNEL_INVALID BLADERF_MODULE_INVALID 33 | 34 | typedef bladerf_module bladerf_channel_layout; 35 | #define BLADERF_RX_X1 BLADERF_MODULE_RX 36 | #define BLADERF_TX_X1 BLADERF_MODULE_TX 37 | #define BLADERF_RX_X2 BLADERF_MODULE_INVALID 38 | #define BLADERF_TX_X2 BLADERF_MODULE_INVALID 39 | 40 | typedef bladerf_module bladerf_direction; 41 | #define BLADERF_RX BLADERF_MODULE_RX 42 | #define BLADERF_TX BLADERF_MODULE_TX 43 | #define BLADERF_DIRECTION_MASK (0x1) 44 | 45 | /* Changed API calls */ 46 | static 47 | int bladerf_get_frequency(struct bladerf *dev, 48 | bladerf_channel ch, 49 | uint64_t *freq) // was unsigned int *frequency 50 | { 51 | unsigned int f32 = 0; 52 | int status = bladerf_get_frequency(dev, ch, &f32); 53 | *freq = static_cast(f32); 54 | return status; 55 | } 56 | 57 | static 58 | int bladerf_sync_tx(struct bladerf *dev, 59 | void const *samples, // was void *samples 60 | unsigned int num_samples, 61 | struct bladerf_metadata *metadata, 62 | unsigned int timeout_ms) 63 | { 64 | void *s = const_cast(samples); 65 | return bladerf_sync_tx(dev, s, num_samples, metadata, timeout_ms); 66 | } 67 | 68 | /* Changed enums/defines */ 69 | #define BLADERF_GAIN_DEFAULT BLADERF_GAIN_MANUAL 70 | #define BLADERF_GAIN_MGC BLADERF_GAIN_MANUAL 71 | #define BLADERF_RX_MUX_BASEBAND BLADERF_RX_MUX_BASEBAND_LMS 72 | 73 | /* New functionality with no equivalent */ 74 | #define BLADERF_LB_AD9361_BIST BLADERF_LB_NONE 75 | #define bladerf_get_board_name(name) "bladerf1" 76 | 77 | #endif // libbladeRF < 1.8.1 78 | #endif // INCLUDED_BLADERF_COMPAT_H 79 | -------------------------------------------------------------------------------- /lib/config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef CONFIG_H_IN 2 | #define CONFIG_H_IN 3 | 4 | #define GR_OSMOSDR_VERSION "@VERSION@" 5 | #define GR_OSMOSDR_LIBVER "@LIBVER@" 6 | 7 | #cmakedefine ENABLE_FCD 8 | #cmakedefine ENABLE_FILE 9 | #cmakedefine ENABLE_RTL 10 | #cmakedefine ENABLE_RTL_TCP 11 | #cmakedefine ENABLE_UHD 12 | #cmakedefine ENABLE_MIRI 13 | #cmakedefine ENABLE_SDRPLAY 14 | #cmakedefine ENABLE_HACKRF 15 | #cmakedefine ENABLE_BLADERF 16 | #cmakedefine ENABLE_RFSPACE 17 | #cmakedefine ENABLE_AIRSPY 18 | #cmakedefine ENABLE_AIRSPYHF 19 | #cmakedefine ENABLE_SOAPY 20 | #cmakedefine ENABLE_REDPITAYA 21 | #cmakedefine ENABLE_FREESRP 22 | #cmakedefine ENABLE_XTRX 23 | 24 | //provide NAN define for MSVC older than VC12 25 | #if defined(_MSC_VER) && (_MSC_VER < 1800) 26 | #include 27 | #define NAN std::numeric_limits::quiet_NaN() 28 | #endif 29 | 30 | #endif // CONFIG_H_IN 31 | -------------------------------------------------------------------------------- /lib/fcd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${GNURADIO_FUNCUBE_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${GNURADIO_FUNCUBE_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/fcd_source_c.cc 35 | ) 36 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /lib/fcd/fcd_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2013 Dimitri Stolnikov 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 | #ifndef FCD_SOURCE_C_H 21 | #define FCD_SOURCE_C_H 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | #include "source_iface.h" 29 | 30 | class fcd_source_c; 31 | 32 | typedef std::shared_ptr< fcd_source_c > fcd_source_c_sptr; 33 | 34 | fcd_source_c_sptr make_fcd_source_c( const std::string & args = "" ); 35 | 36 | class fcd_source_c : 37 | public gr::hier_block2, 38 | public source_iface 39 | { 40 | private: 41 | friend fcd_source_c_sptr make_fcd_source_c(const std::string &args); 42 | 43 | fcd_source_c(const std::string &args); 44 | 45 | public: 46 | ~fcd_source_c(); 47 | 48 | enum dongle_type { 49 | FUNCUBE_UNKNOWN, 50 | FUNCUBE_V1, 51 | FUNCUBE_V2 52 | }; 53 | 54 | static std::vector< std::string > get_devices(); 55 | 56 | std::string name(); 57 | 58 | size_t get_num_channels( void ); 59 | 60 | osmosdr::meta_range_t get_sample_rates( void ); 61 | double set_sample_rate( double rate ); 62 | double get_sample_rate( void ); 63 | 64 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 65 | double set_center_freq( double freq, size_t chan = 0 ); 66 | double get_center_freq( size_t chan = 0 ); 67 | double set_freq_corr( double ppm, size_t chan = 0 ); 68 | double get_freq_corr( size_t chan = 0 ); 69 | 70 | std::vector get_gain_names( size_t chan = 0 ); 71 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 72 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 73 | double set_gain( double gain, size_t chan = 0 ); 74 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 75 | double get_gain( size_t chan = 0 ); 76 | double get_gain( const std::string & name, size_t chan = 0 ); 77 | 78 | std::vector< std::string > get_antennas( size_t chan = 0 ); 79 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 80 | std::string get_antenna( size_t chan = 0 ); 81 | 82 | private: 83 | dongle_type _type; 84 | gr::funcube::fcd::sptr _src_v1; 85 | gr::funcube::fcdpp::sptr _src_v2; 86 | double _lna_gain, _mix_gain, _bb_gain, _freq; 87 | double _correct; 88 | }; 89 | 90 | #endif // FCD_SOURCE_C_H 91 | -------------------------------------------------------------------------------- /lib/file/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ) 27 | 28 | APPEND_LIB_LIST( 29 | gnuradio::gnuradio-blocks 30 | ) 31 | message(STATUS ${gnuradio-blocks_LIBRARIES}) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/file_source_c.cc 35 | ${CMAKE_CURRENT_SOURCE_DIR}/file_sink_c.cc 36 | ) 37 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 38 | -------------------------------------------------------------------------------- /lib/file/file_sink_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef FILE_SINK_C_H 21 | #define FILE_SINK_C_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "sink_iface.h" 28 | 29 | class file_sink_c; 30 | 31 | typedef std::shared_ptr< file_sink_c > file_sink_c_sptr; 32 | 33 | file_sink_c_sptr make_file_sink_c( const std::string & args = "" ); 34 | 35 | class file_sink_c : 36 | public gr::hier_block2, 37 | public sink_iface 38 | { 39 | private: 40 | friend file_sink_c_sptr make_file_sink_c(const std::string &args); 41 | 42 | file_sink_c(const std::string &args); 43 | 44 | public: 45 | ~file_sink_c(); 46 | 47 | std::string name(); 48 | 49 | static std::vector< std::string > get_devices( bool fake = false ); 50 | 51 | size_t get_num_channels( void ); 52 | 53 | osmosdr::meta_range_t get_sample_rates( void ); 54 | double set_sample_rate( double rate ); 55 | double get_sample_rate( void ); 56 | 57 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 58 | double set_center_freq( double freq, size_t chan = 0 ); 59 | double get_center_freq( size_t chan = 0 ); 60 | double set_freq_corr( double ppm, size_t chan = 0 ); 61 | double get_freq_corr( size_t chan = 0 ); 62 | 63 | std::vector get_gain_names( size_t chan = 0 ); 64 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 65 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 66 | double set_gain( double gain, size_t chan = 0 ); 67 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 68 | double get_gain( size_t chan = 0 ); 69 | double get_gain( const std::string & name, size_t chan = 0 ); 70 | 71 | std::vector< std::string > get_antennas( size_t chan = 0 ); 72 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 73 | std::string get_antenna( size_t chan = 0 ); 74 | 75 | private: 76 | gr::blocks::file_sink::sptr _sink; 77 | gr::blocks::throttle::sptr _throttle; 78 | double _file_rate; 79 | double _freq, _rate; 80 | }; 81 | 82 | #endif // FILE_SINK_C_H 83 | -------------------------------------------------------------------------------- /lib/file/file_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef FILE_SOURCE_C_H 21 | #define FILE_SOURCE_C_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "source_iface.h" 28 | 29 | class file_source_c; 30 | 31 | typedef std::shared_ptr< file_source_c > file_source_c_sptr; 32 | 33 | file_source_c_sptr make_file_source_c( const std::string & args = "" ); 34 | 35 | class file_source_c : 36 | public gr::hier_block2, 37 | public source_iface 38 | { 39 | private: 40 | friend file_source_c_sptr make_file_source_c(const std::string &args); 41 | 42 | file_source_c(const std::string &args); 43 | 44 | public: 45 | ~file_source_c(); 46 | 47 | std::string name(); 48 | 49 | static std::vector< std::string > get_devices( bool fake = false ); 50 | 51 | size_t get_num_channels( void ); 52 | 53 | bool seek( long seek_point, int whence, size_t chan ); 54 | 55 | osmosdr::meta_range_t get_sample_rates( void ); 56 | double set_sample_rate( double rate ); 57 | double get_sample_rate( void ); 58 | 59 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 60 | double set_center_freq( double freq, size_t chan = 0 ); 61 | double get_center_freq( size_t chan = 0 ); 62 | double set_freq_corr( double ppm, size_t chan = 0 ); 63 | double get_freq_corr( size_t chan = 0 ); 64 | 65 | std::vector get_gain_names( size_t chan = 0 ); 66 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 67 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 68 | double set_gain( double gain, size_t chan = 0 ); 69 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 70 | double get_gain( size_t chan = 0 ); 71 | double get_gain( const std::string & name, size_t chan = 0 ); 72 | 73 | std::vector< std::string > get_antennas( size_t chan = 0 ); 74 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 75 | std::string get_antenna( size_t chan = 0 ); 76 | 77 | private: 78 | gr::blocks::file_source::sptr _source; 79 | gr::blocks::throttle::sptr _throttle; 80 | double _file_rate; 81 | double _freq, _rate; 82 | }; 83 | 84 | #endif // FILE_SOURCE_C_H 85 | -------------------------------------------------------------------------------- /lib/freesrp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBFREESRP_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBFREESRP_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/freesrp_common.cc 35 | ${CMAKE_CURRENT_SOURCE_DIR}/freesrp_source_c.cc 36 | ${CMAKE_CURRENT_SOURCE_DIR}/freesrp_sink_c.cc 37 | ) 38 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 39 | -------------------------------------------------------------------------------- /lib/freesrp/freesrp_common.h: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_FREESRP_COMMON_H 2 | #define INCLUDED_FREESRP_COMMON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "osmosdr/ranges.h" 9 | 10 | #include 11 | 12 | class freesrp_common 13 | { 14 | protected: 15 | freesrp_common(const std::string &args); 16 | public: 17 | static std::vector get_devices(); 18 | 19 | size_t get_num_channels( void ); 20 | osmosdr::meta_range_t get_sample_rates( void ); 21 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 22 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 23 | double set_freq_corr( double ppm, size_t chan = 0 ); 24 | double get_freq_corr( size_t chan = 0 ); 25 | protected: 26 | static std::shared_ptr<::FreeSRP::FreeSRP> _srp; 27 | bool _ignore_overflow = false; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/freesrp/freesrp_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Lukas Lao Beyer 4 | * Copyright 2013 Dimitri Stolnikov 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 | #ifndef INCLUDED_FREESRP_SOURCE_C_H 22 | #define INCLUDED_FREESRP_SOURCE_C_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "osmosdr/ranges.h" 29 | #include "source_iface.h" 30 | 31 | #include "freesrp_common.h" 32 | 33 | #include "readerwriterqueue/readerwriterqueue.h" 34 | 35 | #include 36 | 37 | #include 38 | #include 39 | 40 | class freesrp_source_c; 41 | 42 | /* 43 | * We use std::shared_ptr's instead of raw pointers for all access 44 | * to gr_blocks (and many other data structures). The shared_ptr gets 45 | * us transparent reference counting, which greatly simplifies storage 46 | * management issues. This is especially helpful in our hybrid 47 | * C++ / Python system. 48 | * 49 | * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 50 | * 51 | * As a convention, the _sptr suffix indicates a std::shared_ptr 52 | */ 53 | typedef std::shared_ptr freesrp_source_c_sptr; 54 | 55 | /*! 56 | * \brief Return a shared_ptr to a new instance of freesrp_source_c. 57 | * 58 | * To avoid accidental use of raw pointers, freesrp_source_c's 59 | * constructor is private. freesrp_make_source_c is the public 60 | * interface for creating new instances. 61 | */ 62 | freesrp_source_c_sptr make_freesrp_source_c (const std::string & args = ""); 63 | 64 | class freesrp_source_c : 65 | public gr::sync_block, 66 | public source_iface, 67 | public freesrp_common 68 | { 69 | private: 70 | // The friend declaration allows freesrp_make_source_c to 71 | // access the private constructor. 72 | friend freesrp_source_c_sptr make_freesrp_source_c (const std::string & args); 73 | 74 | freesrp_source_c (const std::string & args); // private constructor 75 | 76 | public: 77 | 78 | // From freesrp_common: 79 | static std::vector get_devices() { return freesrp_common::get_devices(); }; 80 | size_t get_num_channels( void ) { return freesrp_common::get_num_channels(); } 81 | osmosdr::meta_range_t get_sample_rates( void ) { return freesrp_common::get_sample_rates(); } 82 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ) { return freesrp_common::get_freq_range(chan); } 83 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ) { return freesrp_common::get_bandwidth_range(chan); } 84 | double set_freq_corr( double ppm, size_t chan = 0 ) { return freesrp_common::set_freq_corr(ppm, chan); } 85 | double get_freq_corr( size_t chan = 0 ) { return freesrp_common::get_freq_corr(chan); } 86 | 87 | bool start(); 88 | bool stop(); 89 | 90 | int work( int noutput_items, 91 | gr_vector_const_void_star &input_items, 92 | gr_vector_void_star &output_items ); 93 | 94 | double set_sample_rate( double rate ); 95 | double get_sample_rate( void ); 96 | 97 | double set_center_freq( double freq, size_t chan = 0 ); 98 | double get_center_freq( size_t chan = 0 ); 99 | 100 | std::vector get_gain_names( size_t chan = 0 ); 101 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 102 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 103 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 104 | bool get_gain_mode( size_t chan = 0 ); 105 | double set_gain( double gain, size_t chan = 0 ); 106 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 107 | double get_gain( size_t chan = 0 ); 108 | double get_gain( const std::string & name, size_t chan = 0 ); 109 | 110 | double set_bb_gain( double gain, size_t chan = 0 ); 111 | 112 | std::vector< std::string > get_antennas( size_t chan = 0 ); 113 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 114 | std::string get_antenna( size_t chan = 0 ); 115 | 116 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 117 | double get_bandwidth( size_t chan = 0 ); 118 | 119 | private: 120 | 121 | void freesrp_rx_callback(const std::vector &samples); 122 | 123 | bool _running = false; 124 | 125 | std::mutex _buf_mut{}; 126 | std::condition_variable _buf_cond{}; 127 | size_t _buf_num_samples = 0; 128 | moodycamel::ReaderWriterQueue _buf_queue{FREESRP_RX_TX_QUEUE_SIZE}; 129 | }; 130 | 131 | #endif /* INCLUDED_FREESRP_SOURCE_C_H */ 132 | -------------------------------------------------------------------------------- /lib/freesrp/readerwriterqueue/LICENSE.md: -------------------------------------------------------------------------------- 1 | This license applies to all the code in this repository except that written by third 2 | parties, namely the files in benchmarks/ext, which have their own licenses, and Jeff 3 | Preshing's semaphore implementation (used in the blocking queue) which has a zlib 4 | license (embedded in atomicops.h). 5 | 6 | Simplified BSD License: 7 | 8 | Copyright (c) 2013-2015, Cameron Desrochers 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without modification, 12 | are permitted provided that the following conditions are met: 13 | 14 | - Redistributions of source code must retain the above copyright notice, this list of 15 | conditions and the following disclaimer. 16 | - Redistributions in binary form must reproduce the above copyright notice, this list of 17 | conditions and the following disclaimer in the documentation and/or other materials 18 | provided with the distribution. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 21 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 22 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 | THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 25 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 28 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /lib/freesrp/readerwriterqueue/README.md: -------------------------------------------------------------------------------- 1 | # A single-producer, single-consumer lock-free queue for C++ 2 | 3 | This mini-repository has my very own implementation of a lock-free queue (that I designed from scratch) for C++. 4 | 5 | It only supports a two-thread use case (one consuming, and one producing). The threads can't switch roles, though 6 | you could use this queue completely from a single thread if you wish (but that would sort of defeat the purpose!). 7 | 8 | Note: If you need a general purpse multi-producer, multi-consumer lock free queue, I have [one of those too][mpmc]. 9 | 10 | 11 | ## Features 12 | 13 | - [Blazing fast][benchmarks] 14 | - Compatible with C++11 (supports moving objects instead of making copies) 15 | - Fully generic (templated container of any type) -- just like `std::queue`, you never need to allocate memory for elements yourself 16 | (which saves you the hassle of writing a lock-free memory manager to hold the elements you're queueing) 17 | - Allocates memory up front, in contiguous blocks 18 | - Provides a `try_enqueue` method which is guaranteed never to allocate memory (the queue starts with an initial capacity) 19 | - Also provides an `enqueue` method which can dynamically grow the size of the queue as needed 20 | - Also provides a blocking version with `wait_dequeue` 21 | - Completely "wait-free" (no compare-and-swap loop). Enqueue and dequeue are always O(1) (not counting memory allocation) 22 | - On x86, the memory barriers compile down to no-ops, meaning enqueue and dequeue are just a simple series of loads and stores (and branches) 23 | 24 | 25 | ## Use 26 | 27 | Simply drop the readerwriterqueue.h and atomicops.h files into your source code and include them :-) 28 | A modern compiler is required (MSVC2010+, GCC 4.7+, ICC 13+, or any C++11 compliant compiler should work). 29 | 30 | Note: If you're using GCC, you really do need GCC 4.7 or above -- [4.6 has a bug][gcc46bug] that prevents the atomic fence primitives 31 | from working correctly. 32 | 33 | Example: 34 | 35 | ```cpp 36 | using namespace moodycamel; 37 | 38 | ReaderWriterQueue q(100); // Reserve space for at least 100 elements up front 39 | 40 | q.enqueue(17); // Will allocate memory if the queue is full 41 | bool succeeded = q.try_enqueue(18); // Will only succeed if the queue has an empty slot (never allocates) 42 | assert(succeeded); 43 | 44 | int number; 45 | succeeded = q.try_dequeue(number); // Returns false if the queue was empty 46 | 47 | assert(succeeded && number == 17); 48 | 49 | // You can also peek at the front item of the queue (consumer only) 50 | int* front = q.peek(); 51 | assert(*front == 18); 52 | succeeded = q.try_dequeue(number); 53 | assert(succeeded && number == 18); 54 | front = q.peek(); 55 | assert(front == nullptr); // Returns nullptr if the queue was empty 56 | ``` 57 | 58 | The blocking version has the exact same API, with the addition of a `wait_dequeue` method: 59 | 60 | ```cpp 61 | BlockingReaderWriterQueue q; 62 | 63 | std::thread reader([&]() { 64 | int item; 65 | for (int i = 0; i != 100; ++i) { 66 | q.wait_dequeue(item); 67 | } 68 | }); 69 | std::thread writer([&]() { 70 | for (int i = 0; i != 100; ++i) { 71 | q.enqueue(i); 72 | } 73 | }); 74 | writer.join(); 75 | reader.join(); 76 | 77 | assert(q.size_approx() == 0); 78 | ``` 79 | 80 | Note that `wait_dequeue` will block indefinitely while the queue is empty; this 81 | means care must be taken to only call `wait_dequeue` if you're sure another element 82 | will come along eventually, or if the queue has a static lifetime. This is because 83 | destroying the queue while a thread is waiting on it will invoke undefined behaviour. 84 | 85 | 86 | ## Disclaimers 87 | 88 | The queue should only be used on platforms where aligned integer and pointer access is atomic; fortunately, that 89 | includes all modern processors (e.g. x86/x86-64, ARM, and PowerPC). *Not* for use with a DEC Alpha processor (which has very weak memory ordering) :-) 90 | 91 | Note that it's only been tested on x86(-64); if someone has access to other processors I'd love to run some tests on 92 | anything that's not x86-based. 93 | 94 | Finally, I am not an expert. This is my first foray into lock-free programming, and though I'm confident in the code, 95 | it's possible that there are bugs despite the effort I put into designing and testing this data structure. 96 | 97 | Use this code at your own risk; in particular, lock-free programming is a patent minefield, and this code may very 98 | well violate a pending patent (I haven't looked). It's worth noting that I came up with this algorithm and 99 | implementation from scratch, independent of any existing lock-free queues. 100 | 101 | 102 | ## More info 103 | 104 | See the [LICENSE.md][license] file for the license (simplified BSD). 105 | 106 | My [blog post][blog] introduces the context that led to this code, and may be of interest if you're curious 107 | about lock-free programming. 108 | 109 | 110 | [blog]: http://moodycamel.com/blog/2013/a-fast-lock-free-queue-for-c++ 111 | [license]: LICENSE.md 112 | [benchmarks]: http://moodycamel.com/blog/2013/a-fast-lock-free-queue-for-c++#benchmarks 113 | [gcc46bug]: http://stackoverflow.com/questions/16429669/stdatomic-thread-fence-has-undefined-reference 114 | [mpmc]: https://github.com/cameron314/concurrentqueue 115 | -------------------------------------------------------------------------------- /lib/hackrf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBHACKRF_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBHACKRF_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_common.cc 35 | ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_source_c.cc 36 | ${CMAKE_CURRENT_SOURCE_DIR}/hackrf_sink_c.cc 37 | ) 38 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 39 | -------------------------------------------------------------------------------- /lib/hackrf/hackrf_common.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2020 Clayton Smith 4 | * 5 | * gr-osmosdr 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 | * gr-osmosdr 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 gr-osmosdr; 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 | #ifndef INCLUDED_HACKRF_COMMON_H 21 | #define INCLUDED_HACKRF_COMMON_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | 34 | #define BUF_LEN (16 * 32 * 512) /* must be multiple of 512 */ 35 | #define BUF_NUM 15 36 | 37 | #define HACKRF_OC_PORT_COUNT 8 38 | #define HACKRF_OC_PORTS_PER_SIDE 4 39 | #define HACKRF_OC_PORT_INVALID -1 40 | 41 | #define BYTES_PER_SAMPLE 2 /* HackRF device produces/consumes 8 bit signed IQ data */ 42 | 43 | #define HACKRF_FORMAT_ERROR(ret, msg) \ 44 | boost::str( boost::format(msg " (%1%) %2%") \ 45 | % ret % hackrf_error_name((enum hackrf_error)ret) ) 46 | 47 | #define HACKRF_THROW_ON_ERROR(ret, msg) \ 48 | if ( ret != HACKRF_SUCCESS ) \ 49 | { \ 50 | throw std::runtime_error( HACKRF_FORMAT_ERROR(ret, msg) ); \ 51 | } 52 | 53 | #define HACKRF_FUNC_STR(func, arg) \ 54 | boost::str(boost::format(func "(%1%)") % arg) + " has failed" 55 | 56 | typedef std::shared_ptr hackrf_sptr; 57 | 58 | class hackrf_common 59 | { 60 | public: 61 | hackrf_common(const std::string &args); 62 | 63 | protected: 64 | static std::vector< std::string > get_devices(); 65 | 66 | osmosdr::meta_range_t get_sample_rates( void ); 67 | double set_sample_rate( double rate ); 68 | double get_sample_rate( void ); 69 | 70 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 71 | double set_center_freq( double freq, size_t chan = 0 ); 72 | double get_center_freq( size_t chan = 0 ); 73 | double set_freq_corr( double ppm, size_t chan = 0 ); 74 | double get_freq_corr( size_t chan = 0 ); 75 | 76 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 77 | bool get_gain_mode( size_t chan = 0 ); 78 | double set_gain( double gain, size_t chan = 0 ); 79 | double get_gain( size_t chan = 0 ); 80 | 81 | std::vector< std::string > get_antennas( size_t chan = 0 ); 82 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 83 | std::string get_antenna( size_t chan = 0 ); 84 | 85 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 86 | double get_bandwidth( size_t chan = 0 ); 87 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 88 | 89 | bool set_bias( bool bias ); 90 | bool get_bias(); 91 | 92 | void start(); 93 | void stop(); 94 | 95 | hackrf_sptr _dev; 96 | 97 | private: 98 | static void close(void *dev); 99 | 100 | #ifdef HACKRF_OPERACAKE_SUPPORT 101 | uint8_t get_operacake_address(); 102 | std::string port2str(int port); 103 | int str2port(std::string const &str); 104 | #endif 105 | 106 | static int _usage; 107 | static std::mutex _usage_mutex; 108 | 109 | static std::map> _devs; 110 | static std::mutex _devs_mutex; 111 | 112 | double _sample_rate; 113 | double _center_freq; 114 | double _freq_corr; 115 | bool _auto_gain; 116 | double _amp_gain; 117 | double _requested_bandwidth; 118 | double _bandwidth; 119 | bool _bias; 120 | bool _started; 121 | int _selected_port = HACKRF_OC_PORT_INVALID; 122 | }; 123 | 124 | #endif /* INCLUDED_HACKRF_COMMON_H */ 125 | -------------------------------------------------------------------------------- /lib/hackrf/hackrf_sink_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2013 Dimitri Stolnikov 4 | * Copyright 2020 Clayton Smith 5 | * 6 | * gr-osmosdr 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 | * gr-osmosdr 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 gr-osmosdr; 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 | #ifndef INCLUDED_HACKRF_SINK_C_H 22 | #define INCLUDED_HACKRF_SINK_C_H 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "sink_iface.h" 32 | #include "hackrf_common.h" 33 | 34 | class hackrf_sink_c; 35 | 36 | typedef struct circular_buffer 37 | { 38 | void *buffer; // data buffer 39 | void *buffer_end; // end of data buffer 40 | size_t capacity; // maximum number of items in the buffer 41 | size_t count; // number of items in the buffer 42 | size_t sz; // size of each item in the buffer 43 | void *head; // pointer to head 44 | void *tail; // pointer to tail 45 | } circular_buffer_t; 46 | 47 | /* 48 | * We use std::shared_ptr's instead of raw pointers for all access 49 | * to gr::blocks (and many other data structures). The shared_ptr gets 50 | * us transparent reference counting, which greatly simplifies storage 51 | * management issues. This is especially helpful in our hybrid 52 | * C++ / Python system. 53 | * 54 | * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 55 | * 56 | * As a convention, the _sptr suffix indicates a std::shared_ptr 57 | */ 58 | typedef std::shared_ptr hackrf_sink_c_sptr; 59 | 60 | /*! 61 | * \brief Return a shared_ptr to a new instance of hackrf_sink_c. 62 | * 63 | * To avoid accidental use of raw pointers, hackrf_sink_c's 64 | * constructor is private. make_hackrf_sink_c is the public 65 | * interface for creating new instances. 66 | */ 67 | hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args = ""); 68 | 69 | class hackrf_sink_c : 70 | public gr::sync_block, 71 | public sink_iface, 72 | protected hackrf_common 73 | { 74 | private: 75 | // The friend declaration allows hackrf_make_sink_c to 76 | // access the private constructor. 77 | friend hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args); 78 | 79 | hackrf_sink_c (const std::string & args); // private constructor 80 | 81 | public: 82 | ~hackrf_sink_c (); // public destructor 83 | 84 | bool start(); 85 | bool stop(); 86 | 87 | int work( int noutput_items, 88 | gr_vector_const_void_star &input_items, 89 | gr_vector_void_star &output_items ); 90 | 91 | static std::vector< std::string > get_devices(); 92 | 93 | size_t get_num_channels( void ); 94 | 95 | osmosdr::meta_range_t get_sample_rates( void ); 96 | double set_sample_rate( double rate ); 97 | double get_sample_rate( void ); 98 | 99 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 100 | double set_center_freq( double freq, size_t chan = 0 ); 101 | double get_center_freq( size_t chan = 0 ); 102 | double set_freq_corr( double ppm, size_t chan = 0 ); 103 | double get_freq_corr( size_t chan = 0 ); 104 | 105 | std::vector get_gain_names( size_t chan = 0 ); 106 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 107 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 108 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 109 | bool get_gain_mode( size_t chan = 0 ); 110 | double set_gain( double gain, size_t chan = 0 ); 111 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 112 | double get_gain( size_t chan = 0 ); 113 | double get_gain( const std::string & name, size_t chan = 0 ); 114 | 115 | double set_if_gain( double gain, size_t chan = 0 ); 116 | double set_bb_gain( double gain, size_t chan = 0 ); 117 | 118 | std::vector< std::string > get_antennas( size_t chan = 0 ); 119 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 120 | std::string get_antenna( size_t chan = 0 ); 121 | 122 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 123 | double get_bandwidth( size_t chan = 0 ); 124 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 125 | 126 | private: 127 | static int _hackrf_tx_callback(hackrf_transfer* transfer); 128 | int hackrf_tx_callback(unsigned char *buffer, uint32_t length); 129 | 130 | circular_buffer_t _cbuf; 131 | int8_t *_buf; 132 | unsigned int _buf_num; 133 | unsigned int _buf_used; 134 | bool _stopping; 135 | std::mutex _buf_mutex; 136 | std::condition_variable _buf_cond; 137 | 138 | double _vga_gain; 139 | }; 140 | 141 | #endif /* INCLUDED_HACKRF_SINK_C_H */ 142 | -------------------------------------------------------------------------------- /lib/hackrf/hackrf_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2013 Dimitri Stolnikov 4 | * Copyright 2020 Clayton Smith 5 | * 6 | * gr-osmosdr 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 | * gr-osmosdr 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 gr-osmosdr; 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 | #ifndef INCLUDED_HACKRF_SOURCE_C_H 22 | #define INCLUDED_HACKRF_SOURCE_C_H 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | #include "source_iface.h" 32 | #include "hackrf_common.h" 33 | 34 | class hackrf_source_c; 35 | 36 | /* 37 | * We use std::shared_ptr's instead of raw pointers for all access 38 | * to gr::blocks (and many other data structures). The shared_ptr gets 39 | * us transparent reference counting, which greatly simplifies storage 40 | * management issues. This is especially helpful in our hybrid 41 | * C++ / Python system. 42 | * 43 | * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 44 | * 45 | * As a convention, the _sptr suffix indicates a std::shared_ptr 46 | */ 47 | typedef std::shared_ptr hackrf_source_c_sptr; 48 | 49 | /*! 50 | * \brief Return a shared_ptr to a new instance of hackrf_source_c. 51 | * 52 | * To avoid accidental use of raw pointers, hackrf_source_c's 53 | * constructor is private. make_hackrf_source_c is the public 54 | * interface for creating new instances. 55 | */ 56 | hackrf_source_c_sptr make_hackrf_source_c (const std::string & args = ""); 57 | 58 | /*! 59 | * \brief Provides a stream of complex samples. 60 | * \ingroup block 61 | */ 62 | class hackrf_source_c : 63 | public gr::sync_block, 64 | public source_iface, 65 | protected hackrf_common 66 | { 67 | private: 68 | // The friend declaration allows make_hackrf_source_c to 69 | // access the private constructor. 70 | friend hackrf_source_c_sptr make_hackrf_source_c (const std::string & args); 71 | 72 | /*! 73 | * \brief Provides a stream of complex samples. 74 | */ 75 | hackrf_source_c (const std::string & args); // private constructor 76 | 77 | public: 78 | ~hackrf_source_c (); // public destructor 79 | 80 | bool start(); 81 | bool stop(); 82 | 83 | int work( int noutput_items, 84 | gr_vector_const_void_star &input_items, 85 | gr_vector_void_star &output_items ); 86 | 87 | static std::vector< std::string > get_devices(); 88 | 89 | size_t get_num_channels( void ); 90 | 91 | osmosdr::meta_range_t get_sample_rates( void ); 92 | double set_sample_rate( double rate ); 93 | double get_sample_rate( void ); 94 | 95 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 96 | double set_center_freq( double freq, size_t chan = 0 ); 97 | double get_center_freq( size_t chan = 0 ); 98 | double set_freq_corr( double ppm, size_t chan = 0 ); 99 | double get_freq_corr( size_t chan = 0 ); 100 | 101 | std::vector get_gain_names( size_t chan = 0 ); 102 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 103 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 104 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 105 | bool get_gain_mode( size_t chan = 0 ); 106 | double set_gain( double gain, size_t chan = 0 ); 107 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 108 | double get_gain( size_t chan = 0 ); 109 | double get_gain( const std::string & name, size_t chan = 0 ); 110 | 111 | double set_if_gain( double gain, size_t chan = 0 ); 112 | double set_bb_gain( double gain, size_t chan = 0 ); 113 | 114 | std::vector< std::string > get_antennas( size_t chan = 0 ); 115 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 116 | std::string get_antenna( size_t chan = 0 ); 117 | 118 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 119 | double get_bandwidth( size_t chan = 0 ); 120 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 121 | 122 | private: 123 | static int _hackrf_rx_callback(hackrf_transfer* transfer); 124 | int hackrf_rx_callback(unsigned char *buf, uint32_t len); 125 | 126 | std::vector _lut; 127 | 128 | unsigned char **_buf; 129 | unsigned int _buf_num; 130 | unsigned int _buf_len; 131 | unsigned int _buf_head; 132 | unsigned int _buf_used; 133 | std::mutex _buf_mutex; 134 | std::condition_variable _buf_cond; 135 | 136 | unsigned int _buf_offset; 137 | int _samp_avail; 138 | 139 | double _lna_gain; 140 | double _vga_gain; 141 | }; 142 | 143 | #endif /* INCLUDED_HACKRF_SOURCE_C_H */ 144 | -------------------------------------------------------------------------------- /lib/miri/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBMIRISDR_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBMIRISDR_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/miri_source_c.cc 35 | ) 36 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /lib/miri/miri_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef INCLUDED_MIRI_SOURCE_C_H 21 | #define INCLUDED_MIRI_SOURCE_C_H 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | #include "source_iface.h" 31 | 32 | class miri_source_c; 33 | typedef struct mirisdr_dev mirisdr_dev_t; 34 | 35 | typedef std::shared_ptr miri_source_c_sptr; 36 | 37 | /*! 38 | * \brief Return a shared_ptr to a new instance of miri_source_c. 39 | * 40 | * To avoid accidental use of raw pointers, miri_source_c's 41 | * constructor is private. make_miri_source_c is the public 42 | * interface for creating new instances. 43 | */ 44 | miri_source_c_sptr make_miri_source_c (const std::string & args = ""); 45 | 46 | /*! 47 | * \brief Provides a stream of complex samples. 48 | * \ingroup block 49 | */ 50 | class miri_source_c : 51 | public gr::sync_block, 52 | public source_iface 53 | { 54 | private: 55 | // The friend declaration allows make_miri_source_c to 56 | // access the private constructor. 57 | 58 | friend miri_source_c_sptr make_miri_source_c (const std::string & args); 59 | 60 | /*! 61 | * \brief Provides a stream of complex samples. 62 | */ 63 | miri_source_c (const std::string & args); // private constructor 64 | 65 | public: 66 | ~miri_source_c (); // public destructor 67 | 68 | int work( int noutput_items, 69 | gr_vector_const_void_star &input_items, 70 | gr_vector_void_star &output_items ); 71 | 72 | static std::vector< std::string > get_devices(); 73 | 74 | size_t get_num_channels( void ); 75 | 76 | osmosdr::meta_range_t get_sample_rates( void ); 77 | double set_sample_rate( double rate ); 78 | double get_sample_rate( void ); 79 | 80 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 81 | double set_center_freq( double freq, size_t chan = 0 ); 82 | double get_center_freq( size_t chan = 0 ); 83 | double set_freq_corr( double ppm, size_t chan = 0 ); 84 | double get_freq_corr( size_t chan = 0 ); 85 | 86 | std::vector get_gain_names( size_t chan = 0 ); 87 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 88 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 89 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 90 | bool get_gain_mode( size_t chan = 0 ); 91 | double set_gain( double gain, size_t chan = 0 ); 92 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 93 | double get_gain( size_t chan = 0 ); 94 | double get_gain( const std::string & name, size_t chan = 0 ); 95 | 96 | std::vector< std::string > get_antennas( size_t chan = 0 ); 97 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 98 | std::string get_antenna( size_t chan = 0 ); 99 | 100 | private: 101 | static void _mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx); 102 | void mirisdr_callback(unsigned char *buf, uint32_t len); 103 | static void _mirisdr_wait(miri_source_c *obj); 104 | void mirisdr_wait(); 105 | 106 | mirisdr_dev_t *_dev; 107 | gr::thread::thread _thread; 108 | unsigned short **_buf; 109 | unsigned int *_buf_lens; 110 | unsigned int _buf_num; 111 | unsigned int _buf_head; 112 | unsigned int _buf_used; 113 | std::mutex _buf_mutex; 114 | std::condition_variable _buf_cond; 115 | bool _running; 116 | 117 | unsigned int _buf_offset; 118 | int _samp_avail; 119 | 120 | bool _auto_gain; 121 | unsigned int _skipped; 122 | }; 123 | 124 | #endif /* INCLUDED_MIRI_SOURCE_C_H */ 125 | -------------------------------------------------------------------------------- /lib/redpitaya/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ) 27 | 28 | APPEND_LIB_LIST( 29 | ${Gnuradio-blocks_LIBRARIES} 30 | ) 31 | 32 | if(WIN32) 33 | APPEND_LIB_LIST( 34 | ws2_32 35 | ) 36 | endif() 37 | 38 | list(APPEND gr_osmosdr_srcs 39 | ${CMAKE_CURRENT_SOURCE_DIR}/redpitaya_source_c.cc 40 | ${CMAKE_CURRENT_SOURCE_DIR}/redpitaya_sink_c.cc 41 | ${CMAKE_CURRENT_SOURCE_DIR}/redpitaya_common.cc 42 | ) 43 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 44 | -------------------------------------------------------------------------------- /lib/redpitaya/redpitaya_common.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Pavel Demin 4 | * Copyright 2012 Dimitri Stolnikov 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 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "redpitaya_common.h" 28 | 29 | void redpitaya_send_command( SOCKET socket, uint32_t command ) 30 | { 31 | std::stringstream message; 32 | 33 | #if defined(_WIN32) 34 | int total = sizeof(command); 35 | int size; 36 | size = ::send( socket, (char *)&command, sizeof(command), 0 ); 37 | #else 38 | ssize_t total = sizeof(command); 39 | ssize_t size; 40 | size = ::send( socket, &command, sizeof(command), MSG_NOSIGNAL ); 41 | #endif 42 | 43 | if ( size != total ) 44 | { 45 | message << "Sending command failed: " << std::hex << command; 46 | throw std::runtime_error( message.str() ); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /lib/redpitaya/redpitaya_common.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Pavel Demin 4 | * Copyright 2015 Dimitri Stolnikov 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 | #ifndef REDPITAYA_COMMON_H 22 | #define REDPITAYA_COMMON_H 23 | 24 | #include 25 | 26 | #if defined(_WIN32) 27 | #include 28 | #include 29 | #include 30 | #define INVSOC INVALID_SOCKET 31 | #else 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #ifndef SOCKET 41 | #define SOCKET int 42 | #define INVSOC (-1) 43 | #endif 44 | #endif 45 | 46 | #if defined(__APPLE__) || defined(__MACH__) 47 | #ifndef MSG_NOSIGNAL 48 | #define MSG_NOSIGNAL SO_NOSIGPIPE 49 | #endif 50 | #endif 51 | 52 | void redpitaya_send_command( SOCKET socket, uint32_t command ); 53 | 54 | #endif // REDPITAYA_COMMON_H 55 | -------------------------------------------------------------------------------- /lib/redpitaya/redpitaya_sink_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Pavel Demin 4 | * Copyright 2015 Dimitri Stolnikov 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 | #ifndef REDPITAYA_SINK_C_H 22 | #define REDPITAYA_SINK_C_H 23 | 24 | #include 25 | 26 | #include "sink_iface.h" 27 | 28 | #include "redpitaya_common.h" 29 | 30 | class redpitaya_sink_c; 31 | 32 | typedef std::shared_ptr< redpitaya_sink_c > redpitaya_sink_c_sptr; 33 | 34 | redpitaya_sink_c_sptr make_redpitaya_sink_c( const std::string & args = "" ); 35 | 36 | class redpitaya_sink_c : 37 | public gr::sync_block, 38 | public sink_iface 39 | { 40 | private: 41 | friend redpitaya_sink_c_sptr make_redpitaya_sink_c(const std::string &args); 42 | 43 | redpitaya_sink_c(const std::string &args); 44 | 45 | public: 46 | ~redpitaya_sink_c(); 47 | 48 | int work( int noutput_items, 49 | gr_vector_const_void_star &input_items, 50 | gr_vector_void_star &output_items ); 51 | 52 | std::string name(); 53 | 54 | static std::vector< std::string > get_devices( bool fake = false ); 55 | 56 | size_t get_num_channels( void ); 57 | 58 | osmosdr::meta_range_t get_sample_rates( void ); 59 | double set_sample_rate( double rate ); 60 | double get_sample_rate( void ); 61 | 62 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 63 | double set_center_freq( double freq, size_t chan = 0 ); 64 | double get_center_freq( size_t chan = 0 ); 65 | double set_freq_corr( double ppm, size_t chan = 0 ); 66 | double get_freq_corr( size_t chan = 0 ); 67 | 68 | std::vector get_gain_names( size_t chan = 0 ); 69 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 70 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 71 | double set_gain( double gain, size_t chan = 0 ); 72 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 73 | double get_gain( size_t chan = 0 ); 74 | double get_gain( const std::string & name, size_t chan = 0 ); 75 | 76 | std::vector< std::string > get_antennas( size_t chan = 0 ); 77 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 78 | std::string get_antenna( size_t chan = 0 ); 79 | 80 | private: 81 | double _freq, _rate, _corr; 82 | SOCKET _sockets[2]; 83 | }; 84 | 85 | #endif // REDPITAYA_SINK_C_H 86 | -------------------------------------------------------------------------------- /lib/redpitaya/redpitaya_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 Pavel Demin 4 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef REDPITAYA_SOURCE_C_H 22 | #define REDPITAYA_SOURCE_C_H 23 | 24 | #include 25 | 26 | #include "source_iface.h" 27 | 28 | #include "redpitaya_common.h" 29 | 30 | class redpitaya_source_c; 31 | 32 | typedef std::shared_ptr< redpitaya_source_c > redpitaya_source_c_sptr; 33 | 34 | redpitaya_source_c_sptr make_redpitaya_source_c( const std::string & args = "" ); 35 | 36 | class redpitaya_source_c : 37 | public gr::sync_block, 38 | public source_iface 39 | { 40 | private: 41 | friend redpitaya_source_c_sptr make_redpitaya_source_c(const std::string &args); 42 | 43 | redpitaya_source_c(const std::string &args); 44 | 45 | public: 46 | ~redpitaya_source_c(); 47 | 48 | int work( int noutput_items, 49 | gr_vector_const_void_star &input_items, 50 | gr_vector_void_star &output_items ); 51 | 52 | std::string name(); 53 | 54 | static std::vector< std::string > get_devices( bool fake = false ); 55 | 56 | size_t get_num_channels( void ); 57 | 58 | osmosdr::meta_range_t get_sample_rates( void ); 59 | double set_sample_rate( double rate ); 60 | double get_sample_rate( void ); 61 | 62 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 63 | double set_center_freq( double freq, size_t chan = 0 ); 64 | double get_center_freq( size_t chan = 0 ); 65 | double set_freq_corr( double ppm, size_t chan = 0 ); 66 | double get_freq_corr( size_t chan = 0 ); 67 | 68 | std::vector get_gain_names( size_t chan = 0 ); 69 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 70 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 71 | double set_gain( double gain, size_t chan = 0 ); 72 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 73 | double get_gain( size_t chan = 0 ); 74 | double get_gain( const std::string & name, size_t chan = 0 ); 75 | 76 | std::vector< std::string > get_antennas( size_t chan = 0 ); 77 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 78 | std::string get_antenna( size_t chan = 0 ); 79 | 80 | private: 81 | double _freq, _rate, _corr; 82 | SOCKET _sockets[2]; 83 | }; 84 | 85 | #endif // REDPITAYA_SOURCE_C_H 86 | -------------------------------------------------------------------------------- /lib/rfspace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ) 27 | 28 | list(APPEND gr_osmosdr_srcs 29 | ${CMAKE_CURRENT_SOURCE_DIR}/rfspace_source_c.cc 30 | ) 31 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 32 | -------------------------------------------------------------------------------- /lib/rtl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBRTLSDR_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBRTLSDR_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/rtl_source_c.cc 35 | ) 36 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /lib/rtl/rtl_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef INCLUDED_RTLSDR_SOURCE_C_H 23 | #define INCLUDED_RTLSDR_SOURCE_C_H 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | #include 31 | 32 | #include "source_iface.h" 33 | 34 | class rtl_source_c; 35 | typedef struct rtlsdr_dev rtlsdr_dev_t; 36 | 37 | /* 38 | * We use std::shared_ptr's instead of raw pointers for all access 39 | * to gr::blocks (and many other data structures). The shared_ptr gets 40 | * us transparent reference counting, which greatly simplifies storage 41 | * management issues. This is especially helpful in our hybrid 42 | * C++ / Python system. 43 | * 44 | * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 45 | * 46 | * As a convention, the _sptr suffix indicates a std::shared_ptr 47 | */ 48 | typedef std::shared_ptr rtl_source_c_sptr; 49 | 50 | /*! 51 | * \brief Return a shared_ptr to a new instance of rtl_source_c. 52 | * 53 | * To avoid accidental use of raw pointers, rtl_source_c's 54 | * constructor is private. make_rtl_source_c is the public 55 | * interface for creating new instances. 56 | */ 57 | rtl_source_c_sptr make_rtl_source_c (const std::string & args = ""); 58 | 59 | /*! 60 | * \brief Provides a stream of complex samples. 61 | * \ingroup block 62 | * 63 | */ 64 | class rtl_source_c : 65 | public gr::sync_block, 66 | public source_iface 67 | { 68 | private: 69 | // The friend declaration allows make_rtl_source_c to 70 | // access the private constructor. 71 | 72 | friend rtl_source_c_sptr make_rtl_source_c (const std::string & args); 73 | 74 | /*! 75 | * \brief Provides a stream of complex samples. 76 | */ 77 | rtl_source_c (const std::string & args); // private constructor 78 | 79 | public: 80 | ~rtl_source_c (); // public destructor 81 | 82 | int work( int noutput_items, 83 | gr_vector_const_void_star &input_items, 84 | gr_vector_void_star &output_items ); 85 | 86 | static std::vector< std::string > get_devices(); 87 | 88 | size_t get_num_channels( void ); 89 | 90 | osmosdr::meta_range_t get_sample_rates( void ); 91 | double set_sample_rate( double rate ); 92 | double get_sample_rate( void ); 93 | 94 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 95 | double set_center_freq( double freq, size_t chan = 0 ); 96 | double get_center_freq( size_t chan = 0 ); 97 | double set_freq_corr( double ppm, size_t chan = 0 ); 98 | double get_freq_corr( size_t chan = 0 ); 99 | 100 | std::vector get_gain_names( size_t chan = 0 ); 101 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 102 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 103 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 104 | bool get_gain_mode( size_t chan = 0 ); 105 | double set_gain( double gain, size_t chan = 0 ); 106 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 107 | double get_gain( size_t chan = 0 ); 108 | double get_gain( const std::string & name, size_t chan = 0 ); 109 | 110 | double set_if_gain( double gain, size_t chan = 0 ); 111 | 112 | std::vector< std::string > get_antennas( size_t chan = 0 ); 113 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 114 | std::string get_antenna( size_t chan = 0 ); 115 | 116 | protected: 117 | bool start(); 118 | bool stop(); 119 | 120 | private: 121 | static void _rtlsdr_callback(unsigned char *buf, uint32_t len, void *ctx); 122 | void rtlsdr_callback(unsigned char *buf, uint32_t len); 123 | static void _rtlsdr_wait(rtl_source_c *obj); 124 | void rtlsdr_wait(); 125 | 126 | std::vector _lut; 127 | 128 | rtlsdr_dev_t *_dev; 129 | gr::thread::thread _thread; 130 | unsigned char **_buf; 131 | unsigned int _buf_num; 132 | unsigned int _buf_len; 133 | unsigned int _buf_head; 134 | unsigned int _buf_used; 135 | std::mutex _buf_mutex; 136 | std::condition_variable _buf_cond; 137 | bool _running; 138 | 139 | unsigned int _buf_offset; 140 | int _samp_avail; 141 | 142 | bool _no_tuner; 143 | bool _auto_gain; 144 | double _if_gain; 145 | unsigned int _skipped; 146 | }; 147 | 148 | #endif /* INCLUDED_RTLSDR_SOURCE_C_H */ 149 | -------------------------------------------------------------------------------- /lib/rtl_tcp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ) 27 | 28 | APPEND_LIB_LIST( 29 | ${Gnuradio-blocks_LIBRARIES} 30 | ) 31 | 32 | if(WIN32) 33 | APPEND_LIB_LIST( 34 | ws2_32 35 | ) 36 | endif() 37 | 38 | list(APPEND gr_osmosdr_srcs 39 | ${CMAKE_CURRENT_SOURCE_DIR}/rtl_tcp_source_c.cc 40 | ) 41 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 42 | -------------------------------------------------------------------------------- /lib/rtl_tcp/rtl_tcp_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- mode: c++; c-basic-offset: 2 -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef RTL_TCP_SOURCE_C_H 21 | #define RTL_TCP_SOURCE_C_H 22 | 23 | #include 24 | 25 | #include "source_iface.h" 26 | 27 | class rtl_tcp_source_c; 28 | 29 | typedef std::shared_ptr< rtl_tcp_source_c > rtl_tcp_source_c_sptr; 30 | 31 | rtl_tcp_source_c_sptr make_rtl_tcp_source_c( const std::string & args = "" ); 32 | 33 | class rtl_tcp_source_c : 34 | public gr::sync_block, 35 | public source_iface 36 | { 37 | private: 38 | /* copied from rtl sdr */ 39 | enum rtlsdr_tuner { 40 | RTLSDR_TUNER_UNKNOWN = 0, 41 | RTLSDR_TUNER_E4000, 42 | RTLSDR_TUNER_FC0012, 43 | RTLSDR_TUNER_FC0013, 44 | RTLSDR_TUNER_FC2580, 45 | RTLSDR_TUNER_R820T, 46 | RTLSDR_TUNER_R828D 47 | }; 48 | 49 | friend rtl_tcp_source_c_sptr make_rtl_tcp_source_c(const std::string &args); 50 | 51 | rtl_tcp_source_c(const std::string &args); 52 | const char * get_tuner_name(void); 53 | 54 | public: 55 | ~rtl_tcp_source_c(); 56 | 57 | int work(int noutput_items, 58 | gr_vector_const_void_star &input_items, 59 | gr_vector_void_star &output_items); 60 | 61 | std::string name(); 62 | 63 | static std::vector< std::string > get_devices( bool fake = false ); 64 | 65 | size_t get_num_channels( void ); 66 | 67 | osmosdr::meta_range_t get_sample_rates( void ); 68 | double set_sample_rate( double rate ); 69 | double get_sample_rate( void ); 70 | 71 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 72 | double set_center_freq( double freq, size_t chan = 0 ); 73 | double get_center_freq( size_t chan = 0 ); 74 | double set_freq_corr( double ppm, size_t chan = 0 ); 75 | double get_freq_corr( size_t chan = 0 ); 76 | 77 | std::vector get_gain_names( size_t chan = 0 ); 78 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 79 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 80 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 81 | bool get_gain_mode( size_t chan = 0 ); 82 | double set_gain( double gain, size_t chan = 0 ); 83 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 84 | double get_gain( size_t chan = 0 ); 85 | double get_gain( const std::string & name, size_t chan = 0 ); 86 | 87 | double set_if_gain( double gain, size_t chan = 0 ); 88 | 89 | std::vector< std::string > get_antennas( size_t chan = 0 ); 90 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 91 | std::string get_antenna( size_t chan = 0 ); 92 | 93 | private: 94 | int d_socket; // handle to socket 95 | double _freq, _rate, _gain, _corr; 96 | bool _no_tuner; 97 | bool _auto_gain; 98 | double _if_gain; 99 | 100 | enum rtlsdr_tuner d_tuner_type; 101 | unsigned int d_tuner_gain_count; 102 | unsigned int d_tuner_if_gain_count; 103 | unsigned char *d_temp_buff; // hold buffer between calls 104 | float *d_LUT; 105 | }; 106 | 107 | #endif // RTL_TCP_SOURCE_C_H 108 | -------------------------------------------------------------------------------- /lib/sdrplay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBSDRPLAY_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBSDRPLAY_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/sdrplay_source_c.cc 35 | ) 36 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 37 | -------------------------------------------------------------------------------- /lib/sdrplay/sdrplay_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2015 SDRplay Ltd 4 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef INCLUDED_SDRPLAY_SOURCE_C_H 22 | #define INCLUDED_SDRPLAY_SOURCE_C_H 23 | 24 | #include 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "osmosdr/ranges.h" 32 | 33 | #include "source_iface.h" 34 | 35 | class sdrplay_source_c; 36 | typedef struct sdrplay_dev sdrplay_dev_t; 37 | 38 | /* 39 | * We use std::shared_ptr's instead of raw pointers for all access 40 | * to gr::blocks (and many other data structures). The shared_ptr gets 41 | * us transparent reference counting, which greatly simplifies storage 42 | * management issues. This is especially helpful in our hybrid 43 | * C++ / Python system. 44 | * 45 | * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm 46 | * 47 | * As a convention, the _sptr suffix indicates a std::shared_ptr 48 | */ 49 | typedef std::shared_ptr sdrplay_source_c_sptr; 50 | 51 | /*! 52 | * \brief Return a shared_ptr to a new instance of sdrplay_source_c. 53 | * 54 | * To avoid accidental use of raw pointers, sdrplay_source_c's 55 | * constructor is private. make_sdrplay_source_c is the public 56 | * interface for creating new instances. 57 | */ 58 | sdrplay_source_c_sptr make_sdrplay_source_c (const std::string & args = ""); 59 | 60 | /*! 61 | * \brief Provides a stream of complex samples. 62 | * \ingroup block 63 | */ 64 | class sdrplay_source_c : 65 | public gr::sync_block, 66 | public source_iface 67 | { 68 | private: 69 | // The friend declaration allows make_sdrplay_source_c to 70 | // access the private constructor. 71 | 72 | friend sdrplay_source_c_sptr make_sdrplay_source_c (const std::string & args); 73 | 74 | /*! 75 | * \brief Provides a stream of complex samples. 76 | */ 77 | sdrplay_source_c (const std::string & args); // private constructor 78 | 79 | public: 80 | ~sdrplay_source_c (); // public destructor 81 | 82 | int work( int noutput_items, 83 | gr_vector_const_void_star &input_items, 84 | gr_vector_void_star &output_items ); 85 | 86 | static std::vector< std::string > get_devices(); 87 | 88 | size_t get_num_channels( void ); 89 | 90 | osmosdr::meta_range_t get_sample_rates( void ); 91 | double set_sample_rate( double rate ); 92 | double get_sample_rate( void ); 93 | 94 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 95 | double set_center_freq( double freq, size_t chan = 0 ); 96 | double get_center_freq( size_t chan = 0 ); 97 | double set_freq_corr( double ppm, size_t chan = 0 ); 98 | double get_freq_corr( size_t chan = 0 ); 99 | 100 | std::vector get_gain_names( size_t chan = 0 ); 101 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 102 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 103 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 104 | bool get_gain_mode( size_t chan = 0 ); 105 | double set_gain( double gain, size_t chan = 0 ); 106 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 107 | double get_gain( size_t chan = 0 ); 108 | double get_gain( const std::string & name, size_t chan = 0 ); 109 | 110 | std::vector< std::string > get_antennas( size_t chan = 0 ); 111 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 112 | std::string get_antenna( size_t chan = 0 ); 113 | 114 | void set_dc_offset_mode( int mode, size_t chan = 0 ); 115 | void set_dc_offset( const std::complex &offset, size_t chan = 0 ); 116 | 117 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 118 | double get_bandwidth( size_t chan = 0 ); 119 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 120 | 121 | private: 122 | void reinit_device(void); 123 | void set_gain_limits(double freq); 124 | 125 | sdrplay_dev_t *_dev; 126 | 127 | std::vector< short > _bufi; 128 | std::vector< short > _bufq; 129 | int _buf_offset; 130 | std::mutex _buf_mutex; 131 | 132 | bool _running; 133 | bool _uninit; 134 | bool _auto_gain; 135 | }; 136 | 137 | #endif /* INCLUDED_SDRPLAY_SOURCE_C_H */ 138 | -------------------------------------------------------------------------------- /lib/sink_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2013 Dimitri Stolnikov 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 | #ifndef INCLUDED_OSMOSDR_SINK_IMPL_H 21 | #define INCLUDED_OSMOSDR_SINK_IMPL_H 22 | 23 | #include "osmosdr/sink.h" 24 | 25 | #include "sink_iface.h" 26 | 27 | #include 28 | 29 | class sink_impl : public osmosdr::sink 30 | { 31 | public: 32 | sink_impl(const std::string & args); 33 | 34 | size_t get_num_channels( void ); 35 | 36 | osmosdr::meta_range_t get_sample_rates( void ); 37 | double set_sample_rate( double rate ); 38 | double get_sample_rate( void ); 39 | 40 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 41 | double set_center_freq( double freq, size_t chan = 0 ); 42 | double get_center_freq( size_t chan = 0 ); 43 | double set_freq_corr( double ppm, size_t chan = 0 ); 44 | double get_freq_corr( size_t chan = 0 ); 45 | 46 | std::vector get_gain_names( size_t chan = 0 ); 47 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 48 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 49 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 50 | bool get_gain_mode( size_t chan = 0 ); 51 | double set_gain( double gain, size_t chan = 0 ); 52 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 53 | double get_gain( size_t chan = 0 ); 54 | double get_gain( const std::string & name, size_t chan = 0 ); 55 | 56 | double set_if_gain( double gain, size_t chan = 0 ); 57 | double set_bb_gain( double gain, size_t chan = 0 ); 58 | 59 | std::vector< std::string > get_antennas( size_t chan = 0 ); 60 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 61 | std::string get_antenna( size_t chan = 0 ); 62 | 63 | void set_dc_offset( const std::complex &offset, size_t chan = 0 ); 64 | 65 | void set_iq_balance( const std::complex &balance, size_t chan = 0 ); 66 | 67 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 68 | double get_bandwidth( size_t chan = 0 ); 69 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 70 | 71 | void set_time_source(const std::string &source, const size_t mboard = 0); 72 | std::string get_time_source(const size_t mboard); 73 | std::vector get_time_sources(const size_t mboard); 74 | void set_clock_source(const std::string &source, const size_t mboard = 0); 75 | std::string get_clock_source(const size_t mboard); 76 | std::vector get_clock_sources(const size_t mboard); 77 | double get_clock_rate(size_t mboard = 0); 78 | void set_clock_rate(double rate, size_t mboard = 0); 79 | ::osmosdr::time_spec_t get_time_now(size_t mboard = 0); 80 | ::osmosdr::time_spec_t get_time_last_pps(size_t mboard = 0); 81 | void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard = 0); 82 | void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec); 83 | void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec); 84 | 85 | private: 86 | std::vector< sink_iface * > _devs; 87 | 88 | /* cache to prevent multiple device calls with the same value coming from grc */ 89 | double _sample_rate; 90 | std::map< size_t, double > _center_freq; 91 | std::map< size_t, double > _freq_corr; 92 | std::map< size_t, bool > _gain_mode; 93 | std::map< size_t, double > _gain; 94 | std::map< size_t, double > _if_gain; 95 | std::map< size_t, double > _bb_gain; 96 | std::map< size_t, std::string > _antenna; 97 | std::map< size_t, double > _bandwidth; 98 | }; 99 | 100 | #endif /* INCLUDED_OSMOSDR_SINK_IMPL_H */ 101 | -------------------------------------------------------------------------------- /lib/soapy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2015 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${SoapySDR_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${SoapySDR_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/soapy_common.cc 35 | ${CMAKE_CURRENT_SOURCE_DIR}/soapy_source_c.cc 36 | ${CMAKE_CURRENT_SOURCE_DIR}/soapy_sink_c.cc 37 | ) 38 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 39 | -------------------------------------------------------------------------------- /lib/soapy/soapy_common.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Josh Blum 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 "soapy_common.h" 22 | #include 23 | 24 | osmosdr::gain_range_t soapy_range_to_gain_range(const SoapySDR::Range &r) 25 | { 26 | //default step size when unspecified 27 | double step = 1.0; 28 | 29 | //support the step size in 0.6 API and above 30 | //but do not allow unspecified steps 31 | //to avoid device by zero in some applications 32 | #ifdef SOAPY_SDR_API_HAS_RANGE_TYPE_STEP 33 | if (r.step() != 0.0) step = r.step(); 34 | #endif 35 | 36 | return osmosdr::gain_range_t(r.minimum(), r.maximum(), step); 37 | } 38 | 39 | std::mutex &get_soapy_maker_mutex(void) 40 | { 41 | static std::mutex m; 42 | return m; 43 | } 44 | -------------------------------------------------------------------------------- /lib/soapy/soapy_common.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Josh Blum 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 | #ifndef INCLUDED_SOAPY_COMMON_H 22 | #define INCLUDED_SOAPY_COMMON_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | /*! 30 | * Convert a soapy range to a gain range. 31 | * Careful to deal with the step size when zero. 32 | */ 33 | osmosdr::gain_range_t soapy_range_to_gain_range(const SoapySDR::Range &r); 34 | 35 | /*! 36 | * Global mutex to protect factory routines. 37 | * (optional under 0.5 release above) 38 | */ 39 | std::mutex &get_soapy_maker_mutex(void); 40 | 41 | #endif /* INCLUDED_SOAPY_COMMON_H */ 42 | -------------------------------------------------------------------------------- /lib/source_impl.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef INCLUDED_OSMOSDR_SOURCE_IMPL_H 21 | #define INCLUDED_OSMOSDR_SOURCE_IMPL_H 22 | 23 | #include 24 | 25 | #ifdef HAVE_IQBALANCE 26 | #include 27 | #include 28 | #endif 29 | 30 | #include 31 | 32 | #include 33 | 34 | class source_impl : public osmosdr::source 35 | { 36 | public: 37 | source_impl( const std::string & args ); 38 | 39 | size_t get_num_channels( void ); 40 | 41 | bool seek( long seek_point, int whence, size_t chan ); 42 | 43 | osmosdr::meta_range_t get_sample_rates( void ); 44 | double set_sample_rate( double rate ); 45 | double get_sample_rate( void ); 46 | 47 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 48 | double set_center_freq( double freq, size_t chan = 0 ); 49 | double get_center_freq( size_t chan = 0 ); 50 | double set_freq_corr( double ppm, size_t chan = 0 ); 51 | double get_freq_corr( size_t chan = 0 ); 52 | 53 | std::vector get_gain_names( size_t chan = 0 ); 54 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 55 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 56 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 57 | bool get_gain_mode( size_t chan = 0 ); 58 | double set_gain( double gain, size_t chan = 0 ); 59 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 60 | double get_gain( size_t chan = 0 ); 61 | double get_gain( const std::string & name, size_t chan = 0 ); 62 | 63 | double set_if_gain( double gain, size_t chan = 0 ); 64 | double set_bb_gain( double gain, size_t chan = 0 ); 65 | 66 | std::vector< std::string > get_antennas( size_t chan = 0 ); 67 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 68 | std::string get_antenna( size_t chan = 0 ); 69 | 70 | void set_dc_offset_mode( int mode, size_t chan = 0 ); 71 | void set_dc_offset( const std::complex &offset, size_t chan = 0 ); 72 | 73 | void set_iq_balance_mode( int mode, size_t chan = 0 ); 74 | void set_iq_balance( const std::complex &balance, size_t chan = 0 ); 75 | 76 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 77 | double get_bandwidth( size_t chan = 0 ); 78 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 79 | 80 | void set_time_source(const std::string &source, const size_t mboard = 0); 81 | std::string get_time_source(const size_t mboard); 82 | std::vector get_time_sources(const size_t mboard); 83 | void set_clock_source(const std::string &source, const size_t mboard = 0); 84 | std::string get_clock_source(const size_t mboard); 85 | std::vector get_clock_sources(const size_t mboard); 86 | double get_clock_rate(size_t mboard = 0); 87 | void set_clock_rate(double rate, size_t mboard = 0); 88 | ::osmosdr::time_spec_t get_time_now(size_t mboard = 0); 89 | ::osmosdr::time_spec_t get_time_last_pps(size_t mboard = 0); 90 | void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard = 0); 91 | void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec); 92 | void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec); 93 | 94 | private: 95 | std::vector< source_iface * > _devs; 96 | 97 | /* cache to prevent multiple device calls with the same value coming from grc */ 98 | double _sample_rate; 99 | std::map< size_t, double > _center_freq; 100 | std::map< size_t, double > _freq_corr; 101 | std::map< size_t, bool > _gain_mode; 102 | std::map< size_t, double > _gain; 103 | std::map< size_t, double > _if_gain; 104 | std::map< size_t, double > _bb_gain; 105 | std::map< size_t, std::string > _antenna; 106 | #ifdef HAVE_IQBALANCE 107 | std::vector< gr::iqbalance::fix_cc * > _iq_fix; 108 | std::vector< gr::iqbalance::optimize_c * > _iq_opt; 109 | std::map< size_t, std::pair > _vals; 110 | #endif 111 | std::map< size_t, double > _bandwidth; 112 | }; 113 | 114 | #endif /* INCLUDED_OSMOSDR_SOURCE_IMPL_H */ 115 | -------------------------------------------------------------------------------- /lib/uhd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2012 Free Software Foundation, Inc. 2 | # 3 | # This file is part of gr-osmosdr 4 | # 5 | # gr-osmosdr 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 | # gr-osmosdr 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 gr-osmosdr; 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${gnuradio-uhd_INCLUDE_DIRS} 27 | ${UHD_INCLUDE_DIRS} 28 | ) 29 | 30 | APPEND_LIB_LIST( 31 | gnuradio::gnuradio-uhd 32 | ${UHD_LIBRARIES} 33 | ) 34 | 35 | list(APPEND gr_osmosdr_srcs 36 | ${CMAKE_CURRENT_SOURCE_DIR}/uhd_sink_c.cc 37 | ${CMAKE_CURRENT_SOURCE_DIR}/uhd_source_c.cc 38 | ) 39 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 40 | -------------------------------------------------------------------------------- /lib/uhd/uhd_sink_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef UHD_SINK_C_H 21 | #define UHD_SINK_C_H 22 | 23 | #include 24 | #include 25 | 26 | #include "sink_iface.h" 27 | 28 | class uhd_sink_c; 29 | 30 | typedef std::shared_ptr< uhd_sink_c > uhd_sink_c_sptr; 31 | 32 | uhd_sink_c_sptr make_uhd_sink_c(const std::string &args = ""); 33 | 34 | class uhd_sink_c : 35 | public gr::hier_block2, 36 | public sink_iface 37 | { 38 | private: 39 | friend uhd_sink_c_sptr make_uhd_sink_c(const std::string &args); 40 | 41 | uhd_sink_c(const std::string &args); 42 | 43 | public: 44 | ~uhd_sink_c(); 45 | 46 | static std::vector< std::string > get_devices(); 47 | 48 | std::string name(); 49 | 50 | size_t get_num_channels( void ); 51 | 52 | osmosdr::meta_range_t get_sample_rates( void ); 53 | double set_sample_rate( double rate ); 54 | double get_sample_rate( void ); 55 | 56 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 57 | double set_center_freq( double freq, size_t chan = 0 ); 58 | double get_center_freq( size_t chan = 0 ); 59 | double set_freq_corr( double ppm, size_t chan = 0 ); 60 | double get_freq_corr( size_t chan = 0 ); 61 | 62 | std::vector get_gain_names( size_t chan = 0 ); 63 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 64 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 65 | double set_gain( double gain, size_t chan = 0 ); 66 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 67 | double get_gain( size_t chan = 0 ); 68 | double get_gain( const std::string & name, size_t chan = 0 ); 69 | 70 | std::vector< std::string > get_antennas( size_t chan = 0 ); 71 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 72 | std::string get_antenna( size_t chan = 0 ); 73 | 74 | void set_dc_offset( const std::complex &offset, size_t chan = 0 ); 75 | 76 | void set_iq_balance( const std::complex &balance, size_t chan = 0 ); 77 | 78 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 79 | double get_bandwidth( size_t chan = 0 ); 80 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 81 | 82 | void set_time_source(const std::string &source, const size_t mboard = 0); 83 | std::string get_time_source(const size_t mboard); 84 | std::vector get_time_sources(const size_t mboard); 85 | void set_clock_source(const std::string &source, const size_t mboard = 0); 86 | std::string get_clock_source(const size_t mboard); 87 | std::vector get_clock_sources(const size_t mboard); 88 | double get_clock_rate(size_t mboard = 0); 89 | void set_clock_rate(double rate, size_t mboard = 0); 90 | ::osmosdr::time_spec_t get_time_now(size_t mboard = 0); 91 | ::osmosdr::time_spec_t get_time_last_pps(size_t mboard = 0); 92 | void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard = 0); 93 | void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec); 94 | void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec); 95 | 96 | private: 97 | double _center_freq; 98 | double _freq_corr; 99 | double _lo_offset; 100 | gr::uhd::usrp_sink::sptr _snk; 101 | }; 102 | 103 | #endif // UHD_SINK_C_H 104 | -------------------------------------------------------------------------------- /lib/uhd/uhd_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2012 Dimitri Stolnikov 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 | #ifndef UHD_SOURCE_C_H 21 | #define UHD_SOURCE_C_H 22 | 23 | #include 24 | #include 25 | 26 | #include "source_iface.h" 27 | 28 | class uhd_source_c; 29 | 30 | typedef std::shared_ptr< uhd_source_c > uhd_source_c_sptr; 31 | 32 | uhd_source_c_sptr make_uhd_source_c(const std::string &args = ""); 33 | 34 | class uhd_source_c : 35 | public gr::hier_block2, 36 | public source_iface 37 | { 38 | private: 39 | friend uhd_source_c_sptr make_uhd_source_c(const std::string &args); 40 | 41 | uhd_source_c(const std::string &args); 42 | 43 | public: 44 | ~uhd_source_c(); 45 | 46 | static std::vector< std::string > get_devices(); 47 | 48 | std::string name(); 49 | 50 | size_t get_num_channels( void ); 51 | 52 | osmosdr::meta_range_t get_sample_rates( void ); 53 | double set_sample_rate( double rate ); 54 | double get_sample_rate( void ); 55 | 56 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 57 | double set_center_freq( double freq, size_t chan = 0 ); 58 | double get_center_freq( size_t chan = 0 ); 59 | double set_freq_corr( double ppm, size_t chan = 0 ); 60 | double get_freq_corr( size_t chan = 0 ); 61 | 62 | std::vector get_gain_names( size_t chan = 0 ); 63 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 64 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 65 | double set_gain( double gain, size_t chan = 0 ); 66 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 67 | double get_gain( size_t chan = 0 ); 68 | double get_gain( const std::string & name, size_t chan = 0 ); 69 | 70 | std::vector< std::string > get_antennas( size_t chan = 0 ); 71 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 72 | std::string get_antenna( size_t chan = 0 ); 73 | 74 | void set_dc_offset_mode( int mode, size_t chan = 0 ); 75 | void set_dc_offset( const std::complex &offset, size_t chan = 0 ); 76 | 77 | void set_iq_balance_mode( int mode, size_t chan = 0 ); 78 | void set_iq_balance( const std::complex &balance, size_t chan = 0 ); 79 | 80 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 81 | double get_bandwidth( size_t chan = 0 ); 82 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0 ); 83 | 84 | void set_time_source(const std::string &source, const size_t mboard = 0); 85 | std::string get_time_source(const size_t mboard); 86 | std::vector get_time_sources(const size_t mboard); 87 | void set_clock_source(const std::string &source, const size_t mboard = 0); 88 | std::string get_clock_source(const size_t mboard); 89 | std::vector get_clock_sources(const size_t mboard); 90 | double get_clock_rate(size_t mboard = 0); 91 | void set_clock_rate(double rate, size_t mboard = 0); 92 | ::osmosdr::time_spec_t get_time_now(size_t mboard = 0); 93 | ::osmosdr::time_spec_t get_time_last_pps(size_t mboard = 0); 94 | void set_time_now(const ::osmosdr::time_spec_t &time_spec, size_t mboard = 0); 95 | void set_time_next_pps(const ::osmosdr::time_spec_t &time_spec); 96 | void set_time_unknown_pps(const ::osmosdr::time_spec_t &time_spec); 97 | 98 | private: 99 | double _center_freq; 100 | double _freq_corr; 101 | double _lo_offset; 102 | gr::uhd::usrp_source::sptr _src; 103 | }; 104 | 105 | #endif // UHD_SOURCE_C_H 106 | -------------------------------------------------------------------------------- /lib/xtrx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 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 | # This file included, use CMake directory variables 22 | ######################################################################## 23 | 24 | target_include_directories(gnuradio-osmosdr PRIVATE 25 | ${CMAKE_CURRENT_SOURCE_DIR} 26 | ${LIBXTRX_INCLUDE_DIRS} 27 | ) 28 | 29 | APPEND_LIB_LIST( 30 | ${LIBXTRX_LIBRARIES} 31 | ) 32 | 33 | list(APPEND gr_osmosdr_srcs 34 | ${CMAKE_CURRENT_SOURCE_DIR}/xtrx_obj.cc 35 | ${CMAKE_CURRENT_SOURCE_DIR}/xtrx_source_c.cc 36 | ${CMAKE_CURRENT_SOURCE_DIR}/xtrx_sink_c.cc 37 | ) 38 | 39 | set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE) 40 | -------------------------------------------------------------------------------- /lib/xtrx/xtrx_obj.cc: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Sergey Kostanbaev 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 | #include "xtrx_obj.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | static std::map s_objects; 28 | 29 | xtrx_obj_sptr xtrx_obj::get(const char* xtrx_dev, 30 | unsigned loglevel, 31 | bool lmsreset) 32 | { 33 | std::map::iterator i; 34 | std::string name(xtrx_dev); 35 | 36 | i = s_objects.find(name); 37 | if (i == s_objects.end()) { 38 | // No such object 39 | s_objects[name].reset(new xtrx_obj(name, loglevel, lmsreset)); 40 | } 41 | 42 | return s_objects[name]; 43 | } 44 | 45 | void xtrx_obj::clear_all() 46 | { 47 | s_objects.clear(); 48 | } 49 | 50 | std::vector xtrx_obj::get_devices() 51 | { 52 | std::vector devices; 53 | // TODO 54 | devices.push_back("/dev/xtrx0"); 55 | return devices; 56 | } 57 | 58 | 59 | xtrx_obj::xtrx_obj(const std::string &path, unsigned loglevel, bool lmsreset) 60 | : _run(false) 61 | , _vio(0) 62 | , _sink_rate(0) 63 | , _sink_master(0) 64 | , _source_rate(0) 65 | , _source_master(0) 66 | , _flags(0) 67 | { 68 | unsigned xtrxflag = (loglevel & XTRX_O_LOGLVL_MASK) | ((lmsreset) ? XTRX_O_RESET : 0); 69 | std::cerr << "xtrx_obj::xtrx_obj = " << xtrxflag << std::endl; 70 | 71 | xtrx_log_setlevel(loglevel, NULL); 72 | 73 | int res = xtrx_open_string(path.c_str(), &_obj); 74 | if (res < 0) { 75 | std::stringstream message; 76 | message << "Couldn't open " ": Error: " << -res; 77 | 78 | throw std::runtime_error( message.str() ); 79 | } 80 | 81 | _devices = res; 82 | } 83 | 84 | double xtrx_obj::set_smaplerate(double rate, double master, bool sink, unsigned flags) 85 | { 86 | boost::mutex::scoped_lock lock(mtx); 87 | 88 | if (sink) { 89 | _sink_rate = rate; 90 | _sink_master = master; 91 | } else { 92 | _source_rate = rate; 93 | _source_master = master; 94 | } 95 | _flags |= flags | XTRX_SAMPLERATE_FORCE_UPDATE; 96 | 97 | if (_sink_master != 0 && _source_master != 0 && _sink_master != _source_master) { 98 | std::stringstream message; 99 | message << "Can't operate on diferrent master settings for XTRX sink and source" 100 | " sink_master " << _sink_master << " source_master" << _source_master; 101 | 102 | throw std::runtime_error( message.str() ); 103 | } 104 | 105 | double rxrate = 0, txrate = 0; 106 | double actmaster = (_source_master > 0) ? _source_master : _sink_master; 107 | int res = xtrx_set_samplerate(_obj, 108 | actmaster, 109 | _source_rate, 110 | _sink_rate, 111 | _flags, 112 | NULL, 113 | &rxrate, 114 | &txrate); 115 | if (res) { 116 | std::cerr << "Unable to set samplerate, error=" << res << std::endl; 117 | if (sink) 118 | return _sink_rate; 119 | return _source_rate; 120 | } 121 | 122 | if (_vio) { 123 | xtrx_val_set(_obj, XTRX_TRX, XTRX_CH_AB, XTRX_LMS7_VIO, _vio); 124 | } 125 | 126 | if (sink) 127 | return txrate; 128 | return rxrate; 129 | } 130 | 131 | xtrx_obj::~xtrx_obj() 132 | { 133 | if (_obj) { 134 | if (_run) { 135 | //boost::mutex::scoped_lock lock(mtx); 136 | xtrx_stop(_obj, XTRX_TRX); 137 | } 138 | xtrx_close(_obj); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /lib/xtrx/xtrx_obj.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2017 Sergey Kostanbaev 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 | #ifndef XTRX_OBJ_H 21 | #define XTRX_OBJ_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class xtrx_obj; 30 | 31 | typedef std::shared_ptr xtrx_obj_sptr; 32 | 33 | class xtrx_obj 34 | { 35 | public: 36 | xtrx_obj(const std::string& path, unsigned loglevel, bool lmsreset); 37 | ~xtrx_obj(); 38 | 39 | static std::vector get_devices(); 40 | 41 | static xtrx_obj_sptr get(const char* xtrx_dev, 42 | unsigned loglevel, 43 | bool lmsreset); 44 | static void clear_all(); 45 | 46 | xtrx_dev* dev() { return _obj; } 47 | unsigned dev_count() { return _devices; } 48 | 49 | double set_smaplerate(double rate, double master, bool sink, unsigned flags); 50 | 51 | void set_vio(unsigned vio) { _vio = vio; } 52 | 53 | boost::mutex mtx; 54 | protected: 55 | xtrx_dev* _obj; 56 | bool _run; 57 | unsigned _vio; 58 | 59 | double _sink_rate; 60 | double _sink_master; 61 | double _source_rate; 62 | double _source_master; 63 | 64 | unsigned _flags; 65 | unsigned _devices; 66 | }; 67 | 68 | #endif // XTRX_OBJ_H 69 | -------------------------------------------------------------------------------- /lib/xtrx/xtrx_sink_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016 Sergey Kostanabev 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 | #ifndef XTRX_SINK_C_H 22 | #define XTRX_SINK_C_H 23 | 24 | #include 25 | #include 26 | 27 | #include "sink_iface.h" 28 | #include "xtrx_obj.h" 29 | 30 | 31 | static const pmt::pmt_t SOB_KEY = pmt::string_to_symbol("tx_sob"); 32 | static const pmt::pmt_t EOB_KEY = pmt::string_to_symbol("tx_eob"); 33 | static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("tx_time"); 34 | static const pmt::pmt_t FREQ_KEY = pmt::string_to_symbol("tx_freq"); 35 | static const pmt::pmt_t COMMAND_KEY = pmt::string_to_symbol("tx_command"); 36 | 37 | class xtrx_sink_c; 38 | 39 | typedef std::shared_ptr< xtrx_sink_c > xtrx_sink_c_sptr; 40 | 41 | xtrx_sink_c_sptr make_xtrx_sink_c( const std::string & args = "" ); 42 | 43 | class xtrx_sink_c : 44 | public gr::sync_block, 45 | public sink_iface 46 | { 47 | private: 48 | friend xtrx_sink_c_sptr make_xtrx_sink_c(const std::string &args); 49 | 50 | xtrx_sink_c(const std::string &args); 51 | 52 | public: 53 | ~xtrx_sink_c(); 54 | 55 | std::string name(); 56 | 57 | static std::vector< std::string > get_devices( bool fake = false ) { return xtrx_obj::get_devices(); } 58 | 59 | size_t get_num_channels( void ); 60 | 61 | osmosdr::meta_range_t get_sample_rates( void ); 62 | double set_sample_rate( double rate ); 63 | double get_sample_rate( void ); 64 | 65 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 66 | double set_center_freq( double freq, size_t chan = 0 ); 67 | double get_center_freq( size_t chan = 0 ); 68 | double set_freq_corr( double ppm, size_t chan = 0 ); 69 | double get_freq_corr( size_t chan = 0 ); 70 | 71 | std::vector get_gain_names( size_t chan = 0 ); 72 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 73 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 74 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 75 | bool get_gain_mode( size_t chan = 0 ); 76 | double set_gain( double gain, size_t chan = 0 ); 77 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 78 | double get_gain( size_t chan = 0 ); 79 | double get_gain( const std::string & name, size_t chan = 0 ); 80 | 81 | std::vector< std::string > get_antennas( size_t chan = 0 ); 82 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 83 | std::string get_antenna( size_t chan = 0 ); 84 | 85 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 86 | double get_bandwidth( size_t chan = 0 ); 87 | 88 | int work (int noutput_items, 89 | gr_vector_const_void_star &input_items, 90 | gr_vector_void_star &output_items); 91 | 92 | bool start(); 93 | bool stop(); 94 | 95 | void tag_process(int ninput_items); 96 | 97 | private: 98 | xtrx_obj_sptr _xtrx; 99 | std::vector _tags; 100 | 101 | unsigned _sample_flags; 102 | double _rate; 103 | double _master; 104 | double _freq; 105 | double _corr; 106 | double _bandwidth; 107 | double _dsp; 108 | bool _auto_gain; 109 | 110 | xtrx_wire_format_t _otw; 111 | bool _mimo_mode; 112 | 113 | int _gain_tx; 114 | 115 | unsigned _channels; 116 | xtrx_antenna_t _ant; 117 | 118 | uint64_t _ts; 119 | 120 | bool _swap_ab; 121 | bool _swap_iq; 122 | 123 | bool _tdd; 124 | bool _allow_dis; 125 | 126 | std::string _dev; 127 | }; 128 | 129 | #endif // xtrx_sink_c_H 130 | -------------------------------------------------------------------------------- /lib/xtrx/xtrx_source_c.h: -------------------------------------------------------------------------------- 1 | /* -*- c++ -*- */ 2 | /* 3 | * Copyright 2016,2017 Sergey Kostanbaev 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 | #ifndef XTRX_SOURCE_C_H 21 | #define XTRX_SOURCE_C_H 22 | 23 | #include 24 | #include 25 | 26 | #include "source_iface.h" 27 | #include "xtrx_obj.h" 28 | 29 | static const pmt::pmt_t TIME_KEY = pmt::string_to_symbol("rx_time"); 30 | static const pmt::pmt_t RATE_KEY = pmt::string_to_symbol("rx_rate"); 31 | static const pmt::pmt_t FREQ_KEY = pmt::string_to_symbol("rx_freq"); 32 | 33 | class xtrx_source_c; 34 | 35 | typedef std::shared_ptr< xtrx_source_c > xtrx_source_c_sptr; 36 | 37 | xtrx_source_c_sptr make_xtrx_source_c( const std::string & args = "" ); 38 | 39 | class xtrx_source_c : 40 | public gr::sync_block, 41 | public source_iface 42 | { 43 | private: 44 | friend xtrx_source_c_sptr make_xtrx_source_c(const std::string &args); 45 | 46 | xtrx_source_c(const std::string &args); 47 | 48 | public: 49 | ~xtrx_source_c(); 50 | 51 | std::string name(); 52 | 53 | static std::vector< std::string > get_devices( bool fake = false ) { return xtrx_obj::get_devices(); } 54 | 55 | size_t get_num_channels( void ); 56 | 57 | osmosdr::meta_range_t get_sample_rates( void ); 58 | double set_sample_rate( double rate ); 59 | double get_sample_rate( void ); 60 | 61 | osmosdr::freq_range_t get_freq_range( size_t chan = 0 ); 62 | double set_center_freq( double freq, size_t chan = 0 ); 63 | double get_center_freq( size_t chan = 0 ); 64 | double set_freq_corr( double ppm, size_t chan = 0 ); 65 | double get_freq_corr( size_t chan = 0 ); 66 | 67 | std::vector get_gain_names( size_t chan = 0 ); 68 | osmosdr::gain_range_t get_gain_range( size_t chan = 0 ); 69 | osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 ); 70 | bool set_gain_mode( bool automatic, size_t chan = 0 ); 71 | bool get_gain_mode( size_t chan = 0 ); 72 | double set_gain( double gain, size_t chan = 0 ); 73 | double set_gain( double gain, const std::string & name, size_t chan = 0 ); 74 | double get_gain( size_t chan = 0 ); 75 | double get_gain( const std::string & name, size_t chan = 0 ); 76 | 77 | double set_if_gain( double gain, size_t chan = 0 ); 78 | 79 | std::vector< std::string > get_antennas( size_t chan = 0 ); 80 | std::string set_antenna( const std::string & antenna, size_t chan = 0 ); 81 | std::string get_antenna( size_t chan = 0 ); 82 | 83 | double set_bandwidth( double bandwidth, size_t chan = 0 ); 84 | double get_bandwidth( size_t chan = 0 ); 85 | osmosdr::freq_range_t get_bandwidth_range( size_t chan = 0); 86 | 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 | private: 95 | xtrx_obj_sptr _xtrx; 96 | pmt::pmt_t _id; 97 | 98 | unsigned _sample_flags; 99 | double _rate; 100 | double _master; 101 | double _freq; 102 | double _corr; 103 | double _bandwidth; 104 | bool _auto_gain; 105 | 106 | xtrx_wire_format_t _otw; 107 | bool _mimo_mode; 108 | 109 | int _gain_lna; 110 | int _gain_tia; 111 | int _gain_pga; 112 | 113 | unsigned _channels; 114 | xtrx_antenna_t _ant; 115 | 116 | bool _swap_ab; 117 | bool _swap_iq; 118 | bool _loopback; 119 | bool _tdd; 120 | bool _fbctrl; 121 | bool _timekey; 122 | 123 | double _dsp; 124 | std::string _dev; 125 | }; 126 | 127 | #endif // XTRX_SOURCE_C_H 128 | -------------------------------------------------------------------------------- /python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2011 Free Software Foundation, Inc. 2 | # 3 | # This file was generated by gr_modtool, a tool from the GNU Radio framework 4 | # This file is a part of gr-osmosdr 5 | # 6 | # SPDX-License-Identifier: GPL-3.0-or-later 7 | # 8 | 9 | ######################################################################## 10 | # Include python install macros 11 | ######################################################################## 12 | include(GrPython) 13 | if(NOT PYTHONINTERP_FOUND) 14 | return() 15 | endif() 16 | 17 | add_subdirectory(bindings) 18 | 19 | ######################################################################## 20 | # Install python sources 21 | ######################################################################## 22 | GR_PYTHON_INSTALL( 23 | FILES 24 | __init__.py 25 | DESTINATION ${GR_PYTHON_DIR}/osmosdr 26 | ) 27 | 28 | ######################################################################## 29 | # Handle the unit tests 30 | ######################################################################## 31 | include(GrTest) 32 | 33 | set(GR_TEST_TARGET_DEPS gnuradio-osmosdr) 34 | -------------------------------------------------------------------------------- /python/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2008,2009 Free Software Foundation, Inc. 3 | # 4 | # SPDX-License-Identifier: GPL-3.0-or-later 5 | # 6 | 7 | # The presence of this file turns this directory into a Python package 8 | 9 | ''' 10 | This is the GNU Radio OSMOSDR module. Place your Python package 11 | description here (python/__init__.py). 12 | ''' 13 | import os 14 | 15 | # import pybind11 generated symbols into the osmosdr namespace 16 | try: 17 | from .osmosdr_python import * 18 | except ImportError: 19 | dirname, filename = os.path.split(os.path.abspath(__file__)) 20 | __path__.append(os.path.join(dirname, "bindings")) 21 | from .osmosdr_python import * 22 | 23 | # import any pure python here 24 | # 25 | -------------------------------------------------------------------------------- /python/bindings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Free Software Foundation, Inc. 2 | # 3 | # This file is part of GNU Radio 4 | # 5 | # SPDX-License-Identifier: GPL-3.0-or-later 6 | # 7 | 8 | GR_PYTHON_CHECK_MODULE_RAW( 9 | "pygccxml" 10 | "import pygccxml" 11 | PYGCCXML_FOUND 12 | ) 13 | 14 | include(GrPybind) 15 | 16 | ######################################################################## 17 | # Python Bindings 18 | ######################################################################## 19 | 20 | list(APPEND osmosdr_python_files 21 | device_python.cc 22 | sink_python.cc 23 | source_python.cc 24 | ranges_python.cc 25 | time_spec_python.cc 26 | python_bindings.cc) 27 | 28 | GR_PYBIND_MAKE_OOT(osmosdr 29 | ../.. 30 | gr::osmosdr 31 | "${osmosdr_python_files}") 32 | 33 | install(TARGETS osmosdr_python DESTINATION ${GR_PYTHON_DIR}/osmosdr COMPONENT pythonapi) 34 | -------------------------------------------------------------------------------- /python/bindings/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osmocom/gr-osmosdr/581402a42e506357ca57187eb71810bcc0caffb5/python/bindings/README.md -------------------------------------------------------------------------------- /python/bindings/bind_oot_file.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | import argparse 3 | import os 4 | from gnuradio.bindtool import BindingGenerator 5 | import pathlib 6 | import sys 7 | 8 | parser = argparse.ArgumentParser(description='Bind a GR Out of Tree Block') 9 | parser.add_argument('--module', type=str, 10 | help='Name of gr module containing file to bind (e.g. fft digital analog)') 11 | 12 | parser.add_argument('--output_dir', default='/tmp', 13 | help='Output directory of generated bindings') 14 | parser.add_argument('--prefix', help='Prefix of Installed GNU Radio') 15 | parser.add_argument('--src', help='Directory of gnuradio source tree', 16 | default=os.path.dirname(os.path.abspath(__file__))+'/../../..') 17 | 18 | parser.add_argument( 19 | '--filename', help="File to be parsed") 20 | 21 | parser.add_argument( 22 | '--include', help='Additional Include Dirs, separated', default=(), nargs='+') 23 | 24 | parser.add_argument( 25 | '--status', help='Location of output file for general status (used during cmake)', default=None 26 | ) 27 | parser.add_argument( 28 | '--flag_automatic', default='0' 29 | ) 30 | parser.add_argument( 31 | '--flag_pygccxml', default='0' 32 | ) 33 | 34 | args = parser.parse_args() 35 | 36 | prefix = args.prefix 37 | output_dir = args.output_dir 38 | includes = args.include 39 | name = args.module 40 | 41 | namespace = [name] 42 | prefix_include_root = name 43 | 44 | 45 | with warnings.catch_warnings(): 46 | warnings.filterwarnings("ignore", category=DeprecationWarning) 47 | 48 | bg = BindingGenerator(prefix, namespace, 49 | prefix_include_root, output_dir, addl_includes=','.join(args.include), catch_exceptions=False, write_json_output=False, status_output=args.status, 50 | flag_automatic=True if args.flag_automatic.lower() in [ 51 | '1', 'true'] else False, 52 | flag_pygccxml=True if args.flag_pygccxml.lower() in ['1', 'true'] else False) 53 | bg.gen_file_binding(args.filename) 54 | -------------------------------------------------------------------------------- /python/bindings/device_python.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace py = pybind11; 5 | 6 | #include 7 | 8 | void bind_device(py::module& m) 9 | { 10 | using device_t = ::osmosdr::device_t; 11 | 12 | py::class_(m, "device_t") 13 | .def(py::init(), py::arg("args") = "") 14 | .def("to_pp_string", &device_t::to_pp_string) 15 | .def("to_string", &device_t::to_string); 16 | 17 | 18 | using devices_t = ::osmosdr::devices_t; 19 | 20 | py::class_(m, "devices_t"); 21 | 22 | 23 | using device = ::osmosdr::device; 24 | 25 | py::class_(m, "device") 26 | .def_static("find", &device::find, py::arg("hint") = device_t()); 27 | } 28 | -------------------------------------------------------------------------------- /python/bindings/docstrings/README.md: -------------------------------------------------------------------------------- 1 | This directory stores templates for docstrings that are scraped from the include header files for each block -------------------------------------------------------------------------------- /python/bindings/docstrings/sink_pydoc_template.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * SPDX-License-Identifier: GPL-3.0-or-later 7 | * 8 | */ 9 | #include "pydoc_macros.h" 10 | #define D(...) DOC(osmosdr, __VA_ARGS__ ) 11 | /* 12 | This file contains placeholders for docstrings for the Python bindings. 13 | Do not edit! These were automatically extracted during the binding process 14 | and will be overwritten during the build process 15 | */ 16 | 17 | 18 | 19 | static const char *__doc_osmosdr_sink = R"doc()doc"; 20 | 21 | 22 | static const char *__doc_osmosdr_sink_sink_0 = R"doc()doc"; 23 | 24 | 25 | static const char *__doc_osmosdr_sink_sink_1 = R"doc()doc"; 26 | 27 | 28 | static const char *__doc_osmosdr_sink_make = R"doc()doc"; 29 | 30 | 31 | static const char *__doc_osmosdr_sink_get_num_channels = R"doc()doc"; 32 | 33 | 34 | static const char *__doc_osmosdr_sink_get_sample_rates = R"doc()doc"; 35 | 36 | 37 | static const char *__doc_osmosdr_sink_set_sample_rate = R"doc()doc"; 38 | 39 | 40 | static const char *__doc_osmosdr_sink_get_sample_rate = R"doc()doc"; 41 | 42 | 43 | static const char *__doc_osmosdr_sink_get_freq_range = R"doc()doc"; 44 | 45 | 46 | static const char *__doc_osmosdr_sink_set_center_freq = R"doc()doc"; 47 | 48 | 49 | static const char *__doc_osmosdr_sink_get_center_freq = R"doc()doc"; 50 | 51 | 52 | static const char *__doc_osmosdr_sink_set_freq_corr = R"doc()doc"; 53 | 54 | 55 | static const char *__doc_osmosdr_sink_get_freq_corr = R"doc()doc"; 56 | 57 | 58 | static const char *__doc_osmosdr_sink_get_gain_names = R"doc()doc"; 59 | 60 | 61 | static const char *__doc_osmosdr_sink_get_gain_range_0 = R"doc()doc"; 62 | 63 | 64 | static const char *__doc_osmosdr_sink_get_gain_range_1 = R"doc()doc"; 65 | 66 | 67 | static const char *__doc_osmosdr_sink_set_gain_mode = R"doc()doc"; 68 | 69 | 70 | static const char *__doc_osmosdr_sink_get_gain_mode = R"doc()doc"; 71 | 72 | 73 | static const char *__doc_osmosdr_sink_set_gain_0 = R"doc()doc"; 74 | 75 | 76 | static const char *__doc_osmosdr_sink_set_gain_1 = R"doc()doc"; 77 | 78 | 79 | static const char *__doc_osmosdr_sink_get_gain_0 = R"doc()doc"; 80 | 81 | 82 | static const char *__doc_osmosdr_sink_get_gain_1 = R"doc()doc"; 83 | 84 | 85 | static const char *__doc_osmosdr_sink_set_if_gain = R"doc()doc"; 86 | 87 | 88 | static const char *__doc_osmosdr_sink_set_bb_gain = R"doc()doc"; 89 | 90 | 91 | static const char *__doc_osmosdr_sink_get_antennas = R"doc()doc"; 92 | 93 | 94 | static const char *__doc_osmosdr_sink_set_antenna = R"doc()doc"; 95 | 96 | 97 | static const char *__doc_osmosdr_sink_get_antenna = R"doc()doc"; 98 | 99 | 100 | static const char *__doc_osmosdr_sink_set_dc_offset = R"doc()doc"; 101 | 102 | 103 | static const char *__doc_osmosdr_sink_set_iq_balance = R"doc()doc"; 104 | 105 | 106 | static const char *__doc_osmosdr_sink_set_bandwidth = R"doc()doc"; 107 | 108 | 109 | static const char *__doc_osmosdr_sink_get_bandwidth = R"doc()doc"; 110 | 111 | 112 | static const char *__doc_osmosdr_sink_get_bandwidth_range = R"doc()doc"; 113 | 114 | 115 | static const char *__doc_osmosdr_sink_set_time_source = R"doc()doc"; 116 | 117 | 118 | static const char *__doc_osmosdr_sink_get_time_source = R"doc()doc"; 119 | 120 | 121 | static const char *__doc_osmosdr_sink_get_time_sources = R"doc()doc"; 122 | 123 | 124 | static const char *__doc_osmosdr_sink_set_clock_source = R"doc()doc"; 125 | 126 | 127 | static const char *__doc_osmosdr_sink_get_clock_source = R"doc()doc"; 128 | 129 | 130 | static const char *__doc_osmosdr_sink_get_clock_sources = R"doc()doc"; 131 | 132 | 133 | static const char *__doc_osmosdr_sink_get_clock_rate = R"doc()doc"; 134 | 135 | 136 | static const char *__doc_osmosdr_sink_set_clock_rate = R"doc()doc"; 137 | 138 | 139 | static const char *__doc_osmosdr_sink_get_time_now = R"doc()doc"; 140 | 141 | 142 | static const char *__doc_osmosdr_sink_get_time_last_pps = R"doc()doc"; 143 | 144 | 145 | static const char *__doc_osmosdr_sink_set_time_now = R"doc()doc"; 146 | 147 | 148 | static const char *__doc_osmosdr_sink_set_time_next_pps = R"doc()doc"; 149 | 150 | 151 | static const char *__doc_osmosdr_sink_set_time_unknown_pps = R"doc()doc"; 152 | 153 | 154 | -------------------------------------------------------------------------------- /python/bindings/docstrings/source_pydoc_template.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * SPDX-License-Identifier: GPL-3.0-or-later 7 | * 8 | */ 9 | #include "pydoc_macros.h" 10 | #define D(...) DOC(osmosdr, __VA_ARGS__ ) 11 | /* 12 | This file contains placeholders for docstrings for the Python bindings. 13 | Do not edit! These were automatically extracted during the binding process 14 | and will be overwritten during the build process 15 | */ 16 | 17 | 18 | 19 | static const char *__doc_osmosdr_source = R"doc()doc"; 20 | 21 | 22 | static const char *__doc_osmosdr_source_source_0 = R"doc()doc"; 23 | 24 | 25 | static const char *__doc_osmosdr_source_source_1 = R"doc()doc"; 26 | 27 | 28 | static const char *__doc_osmosdr_source_make = R"doc()doc"; 29 | 30 | 31 | static const char *__doc_osmosdr_source_get_num_channels = R"doc()doc"; 32 | 33 | 34 | static const char *__doc_osmosdr_source_seek = R"doc()doc"; 35 | 36 | 37 | static const char *__doc_osmosdr_source_get_sample_rates = R"doc()doc"; 38 | 39 | 40 | static const char *__doc_osmosdr_source_set_sample_rate = R"doc()doc"; 41 | 42 | 43 | static const char *__doc_osmosdr_source_get_sample_rate = R"doc()doc"; 44 | 45 | 46 | static const char *__doc_osmosdr_source_get_freq_range = R"doc()doc"; 47 | 48 | 49 | static const char *__doc_osmosdr_source_set_center_freq = R"doc()doc"; 50 | 51 | 52 | static const char *__doc_osmosdr_source_get_center_freq = R"doc()doc"; 53 | 54 | 55 | static const char *__doc_osmosdr_source_set_freq_corr = R"doc()doc"; 56 | 57 | 58 | static const char *__doc_osmosdr_source_get_freq_corr = R"doc()doc"; 59 | 60 | 61 | static const char *__doc_osmosdr_source_get_gain_names = R"doc()doc"; 62 | 63 | 64 | static const char *__doc_osmosdr_source_get_gain_range_0 = R"doc()doc"; 65 | 66 | 67 | static const char *__doc_osmosdr_source_get_gain_range_1 = R"doc()doc"; 68 | 69 | 70 | static const char *__doc_osmosdr_source_set_gain_mode = R"doc()doc"; 71 | 72 | 73 | static const char *__doc_osmosdr_source_get_gain_mode = R"doc()doc"; 74 | 75 | 76 | static const char *__doc_osmosdr_source_set_gain_0 = R"doc()doc"; 77 | 78 | 79 | static const char *__doc_osmosdr_source_set_gain_1 = R"doc()doc"; 80 | 81 | 82 | static const char *__doc_osmosdr_source_get_gain_0 = R"doc()doc"; 83 | 84 | 85 | static const char *__doc_osmosdr_source_get_gain_1 = R"doc()doc"; 86 | 87 | 88 | static const char *__doc_osmosdr_source_set_if_gain = R"doc()doc"; 89 | 90 | 91 | static const char *__doc_osmosdr_source_set_bb_gain = R"doc()doc"; 92 | 93 | 94 | static const char *__doc_osmosdr_source_get_antennas = R"doc()doc"; 95 | 96 | 97 | static const char *__doc_osmosdr_source_set_antenna = R"doc()doc"; 98 | 99 | 100 | static const char *__doc_osmosdr_source_get_antenna = R"doc()doc"; 101 | 102 | 103 | static const char *__doc_osmosdr_source_set_dc_offset_mode = R"doc()doc"; 104 | 105 | 106 | static const char *__doc_osmosdr_source_set_dc_offset = R"doc()doc"; 107 | 108 | 109 | static const char *__doc_osmosdr_source_set_iq_balance_mode = R"doc()doc"; 110 | 111 | 112 | static const char *__doc_osmosdr_source_set_iq_balance = R"doc()doc"; 113 | 114 | 115 | static const char *__doc_osmosdr_source_set_bandwidth = R"doc()doc"; 116 | 117 | 118 | static const char *__doc_osmosdr_source_get_bandwidth = R"doc()doc"; 119 | 120 | 121 | static const char *__doc_osmosdr_source_get_bandwidth_range = R"doc()doc"; 122 | 123 | 124 | static const char *__doc_osmosdr_source_set_time_source = R"doc()doc"; 125 | 126 | 127 | static const char *__doc_osmosdr_source_get_time_source = R"doc()doc"; 128 | 129 | 130 | static const char *__doc_osmosdr_source_get_time_sources = R"doc()doc"; 131 | 132 | 133 | static const char *__doc_osmosdr_source_set_clock_source = R"doc()doc"; 134 | 135 | 136 | static const char *__doc_osmosdr_source_get_clock_source = R"doc()doc"; 137 | 138 | 139 | static const char *__doc_osmosdr_source_get_clock_sources = R"doc()doc"; 140 | 141 | 142 | static const char *__doc_osmosdr_source_get_clock_rate = R"doc()doc"; 143 | 144 | 145 | static const char *__doc_osmosdr_source_set_clock_rate = R"doc()doc"; 146 | 147 | 148 | static const char *__doc_osmosdr_source_get_time_now = R"doc()doc"; 149 | 150 | 151 | static const char *__doc_osmosdr_source_get_time_last_pps = R"doc()doc"; 152 | 153 | 154 | static const char *__doc_osmosdr_source_set_time_now = R"doc()doc"; 155 | 156 | 157 | static const char *__doc_osmosdr_source_set_time_next_pps = R"doc()doc"; 158 | 159 | 160 | static const char *__doc_osmosdr_source_set_time_unknown_pps = R"doc()doc"; 161 | 162 | 163 | -------------------------------------------------------------------------------- /python/bindings/header_utils.py: -------------------------------------------------------------------------------- 1 | # Utilities for reading values in header files 2 | 3 | from argparse import ArgumentParser 4 | import re 5 | 6 | 7 | class PybindHeaderParser: 8 | def __init__(self, pathname): 9 | with open(pathname,'r') as f: 10 | self.file_txt = f.read() 11 | 12 | def get_flag_automatic(self): 13 | # p = re.compile(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)') 14 | # m = p.search(self.file_txt) 15 | m = re.search(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)', self.file_txt) 16 | if (m and m.group(1) == '1'): 17 | return True 18 | else: 19 | return False 20 | 21 | def get_flag_pygccxml(self): 22 | # p = re.compile(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)') 23 | # m = p.search(self.file_txt) 24 | m = re.search(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)', self.file_txt) 25 | if (m and m.group(1) == '1'): 26 | return True 27 | else: 28 | return False 29 | 30 | def get_header_filename(self): 31 | # p = re.compile(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)') 32 | # m = p.search(self.file_txt) 33 | m = re.search(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)', self.file_txt) 34 | if (m): 35 | return m.group(1) 36 | else: 37 | return None 38 | 39 | def get_header_file_hash(self): 40 | # p = re.compile(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)') 41 | # m = p.search(self.file_txt) 42 | m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', self.file_txt) 43 | if (m): 44 | return m.group(1) 45 | else: 46 | return None 47 | 48 | def get_flags(self): 49 | return f'{self.get_flag_automatic()};{self.get_flag_pygccxml()};{self.get_header_filename()};{self.get_header_file_hash()};' 50 | 51 | 52 | 53 | def argParse(): 54 | """Parses commandline args.""" 55 | desc='Reads the parameters from the comment block in the pybind files' 56 | parser = ArgumentParser(description=desc) 57 | 58 | parser.add_argument("function", help="Operation to perform on comment block of pybind file", choices=["flag_auto","flag_pygccxml","header_filename","header_file_hash","all"]) 59 | parser.add_argument("pathname", help="Pathname of pybind c++ file to read, e.g. blockname_python.cc") 60 | 61 | return parser.parse_args() 62 | 63 | if __name__ == "__main__": 64 | # Parse command line options and set up doxyxml. 65 | args = argParse() 66 | 67 | pbhp = PybindHeaderParser(args.pathname) 68 | 69 | if args.function == "flag_auto": 70 | print(pbhp.get_flag_automatic()) 71 | elif args.function == "flag_pygccxml": 72 | print(pbhp.get_flag_pygccxml()) 73 | elif args.function == "header_filename": 74 | print(pbhp.get_header_filename()) 75 | elif args.function == "header_file_hash": 76 | print(pbhp.get_header_file_hash()) 77 | elif args.function == "all": 78 | print(pbhp.get_flags()) -------------------------------------------------------------------------------- /python/bindings/python_bindings.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Free Software Foundation, Inc. 3 | * 4 | * This file is part of GNU Radio 5 | * 6 | * SPDX-License-Identifier: GPL-3.0-or-later 7 | * 8 | */ 9 | 10 | #include 11 | 12 | #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION 13 | #include 14 | 15 | namespace py = pybind11; 16 | 17 | // Headers for binding functions 18 | /**************************************/ 19 | // The following comment block is used for 20 | // gr_modtool to insert function prototypes 21 | // Please do not delete 22 | /**************************************/ 23 | // BINDING_FUNCTION_PROTOTYPES( 24 | void bind_sink(py::module& m); 25 | void bind_source(py::module& m); 26 | // ) END BINDING_FUNCTION_PROTOTYPES 27 | 28 | void bind_device(py::module& m); 29 | void bind_ranges(py::module& m); 30 | void bind_time_spec(py::module& m); 31 | 32 | 33 | // We need this hack because import_array() returns NULL 34 | // for newer Python versions. 35 | // This function is also necessary because it ensures access to the C API 36 | // and removes a warning. 37 | void* init_numpy() 38 | { 39 | import_array(); 40 | return NULL; 41 | } 42 | 43 | PYBIND11_MODULE(osmosdr_python, m) 44 | { 45 | // Initialize the numpy C API 46 | // (otherwise we will see segmentation faults) 47 | init_numpy(); 48 | 49 | // Allow access to base block methods 50 | py::module::import("gnuradio.gr"); 51 | 52 | /**************************************/ 53 | // The following comment block is used for 54 | // gr_modtool to insert binding function calls 55 | // Please do not delete 56 | /**************************************/ 57 | // BINDING_FUNCTION_CALLS( 58 | bind_sink(m); 59 | bind_source(m); 60 | // ) END BINDING_FUNCTION_CALLS 61 | 62 | bind_device(m); 63 | bind_ranges(m); 64 | bind_time_spec(m); 65 | } 66 | -------------------------------------------------------------------------------- /python/bindings/ranges_python.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace py = pybind11; 4 | 5 | #include 6 | 7 | void bind_ranges(py::module& m) 8 | { 9 | m.attr("ALL_MBOARDS") = ::osmosdr::ALL_MBOARDS; 10 | m.attr("ALL_CHANS") = ::osmosdr::ALL_CHANS; 11 | 12 | 13 | using range_t = ::osmosdr::range_t; 14 | 15 | py::class_(m, "range_t") 16 | .def(py::init(), py::arg("value") = 0) 17 | .def(py::init(), py::arg("start"), py::arg("stop"), py::arg("step") = 0) 18 | .def("start", &range_t::start) 19 | .def("stop", &range_t::stop) 20 | .def("step", &range_t::step) 21 | .def("to_pp_string", &range_t::to_pp_string); 22 | 23 | 24 | using meta_range_t = ::osmosdr::meta_range_t; 25 | 26 | py::class_(m, "meta_range_t") 27 | .def(py::init()) 28 | .def(py::init(), py::arg("start"), py::arg("stop"), py::arg("step") = 0) 29 | .def("start", &meta_range_t::start) 30 | .def("stop", &meta_range_t::stop) 31 | .def("step", &meta_range_t::step) 32 | .def("clip", &meta_range_t::clip, py::arg("value"), py::arg("clip_step") = false) 33 | .def("values", &meta_range_t::values) 34 | .def("to_pp_string", &meta_range_t::to_pp_string); 35 | } 36 | -------------------------------------------------------------------------------- /python/bindings/time_spec_python.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | namespace py = pybind11; 5 | 6 | #include 7 | 8 | void bind_time_spec(py::module& m) 9 | { 10 | using time_spec_t = ::osmosdr::time_spec_t; 11 | 12 | py::class_(m, "time_spec_t") 13 | .def_static("get_system_time", &time_spec_t::get_system_time) 14 | .def(py::init(), py::arg("secs") = 0) 15 | .def(py::init(), py::arg("full_secs"), py::arg("frac_secs") = 0) 16 | .def(py::init(), py::arg("full_secs"), py::arg("tick_count"), py::arg("tick_rate")) 17 | .def_static("from_ticks", &time_spec_t::from_ticks, py::arg("ticks"), py::arg("tick_rate")) 18 | .def("get_tick_count", &time_spec_t::get_tick_count, py::arg("tick_rate")) 19 | .def("to_ticks", &time_spec_t::to_ticks, py::arg("tick_rate")) 20 | .def("get_real_secs", &time_spec_t::get_real_secs) 21 | .def("get_full_secs", &time_spec_t::get_full_secs) 22 | .def("get_frac_secs", &time_spec_t::get_frac_secs) 23 | .def(py::self + py::self) 24 | .def(py::self += py::self) 25 | .def(py::self - py::self) 26 | .def(py::self -= py::self) 27 | .def(py::self == py::self) 28 | .def(py::self != py::self) 29 | .def(py::self < py::self) 30 | .def(py::self > py::self) 31 | .def(py::self <= py::self) 32 | .def(py::self >= py::self); 33 | } 34 | --------------------------------------------------------------------------------