Compare commits

..

20 Commits

Author SHA1 Message Date
Harald Welte 39ef03d961 README.md: Fix copy/paste from pysim 2024-03-23 12:26:11 +01:00
Harald Welte bf220b0f7b README.md: Add link to discourse forum 2024-03-23 12:17:32 +01:00
Harald Welte ebc2e99408 README.md: Improve/fix mark-down formatting 2024-03-23 12:17:22 +01:00
Dimitri Stolnikov 73d8982ac0 Merge pull request 'Fix compilation of retpitaya and rtl_tcp with MinGW' (#5) from argilo/gr-osmosdr:fix-win-compile into master
Reviewed-on: sdr/gr-osmosdr#5
2023-12-03 09:08:40 +00:00
Clayton Smith 14d4116175 Fix compiler warning 2023-12-02 19:33:45 -05:00
Clayton Smith 6ba384f3a4 Use CMake to link ws2_32 on Windows 2023-12-02 19:33:36 -05:00
Clayton Smith 273f68483f Remove unused files 2023-12-02 19:31:09 -05:00
Ruslan Migirov 48422c87a9 Fix pointer-to-integer casting precision loss in gr-osmosdr
Changed the casting of pointers to `long int` to `reinterpret_cast<std::intptr_t>`
in `source_impl.cc` and `sink_impl.cc`. This resolves the issue of precision
loss when compiling on 64-bit systems, where the size of pointers is 64 bits
and `long int` is typically 32 bits. Using `std::intptr_t` ensures safe
and portable casting across different platforms.
Additionally this fixes build in MSYS2 MinGW64 environment.
2023-11-23 21:35:14 +01:00
Harald Welte 2fedabec38 convert README to markdow; expand/update it slightly 2023-11-07 21:21:24 +01:00
Harald Welte cebcf5773f The old git:// protocol is long deprecated, use https:// instead 2023-11-07 17:14:03 +01:00
Harald Welte 1c09d1467d Add debian packaging information
This allows (among others) to build rtl-sdr nightly packages
for a variety of distributions as part of the network:osmocom:nightly
builds.
2023-11-07 17:12:57 +01:00
Carl Laufer 9c09c90d92 rtlsdr: detect RTL-SDR Blog V4, set lower tuning limit to 0Mhz
Signed-off-by: Eric Wild <ewild@sysmocom.de>
2023-10-29 17:19:44 +01:00
Eric Wild b581c621fe fix gain mode caching
As pointed out in https://osmocom.org/issues/5562 and previously
discussed in https://github.com/gqrx-sdr/gqrx/issues/979 the current
cache fails to set 0, because the first map lookup of the key that does
not exist (and is created by accessing it using operator[]) returns 0.
2023-10-29 16:50:05 +01:00
Eric Wild 8b33260d66 hackf: remove deprecated register keyword, make c++17 happy
This fixes https://osmocom.org/issues/6004
2023-10-29 16:24:23 +01:00
Eric Wild 674863d9cb Merge pull request 'Avoid namespace conflicts' (#4) from argilo/gr-osmosdr:freesrp-namespaces into master
Reviewed-on: sdr/gr-osmosdr#4
2023-10-29 15:15:59 +00:00
Clayton Smith 0d15519fd5 Avoid namespace conflicts
This fixes building with C++17, where std::sample conflicts with
FreeSRP::sample.
2023-10-01 18:58:12 -04:00
Mike McCarrick 82d6b6db78 Add support for RFSpace CloudSDR to gr-osmosdr
Signed-off-by: Eric Wild <ewild@sysmocom.de>
2022-12-28 20:00:26 +01:00
Eric Wild d75ccf8248 Re-add mirisdr support
This was originally removed in fe03d83703

There are apparently a bunch of different compatible libmirisdr
libraries which are actually being used that have nothing in common with
the old, unmaintained hack we built this support for.
2022-12-28 20:00:26 +01:00
Eric Wild de6de7bc90 Merge pull request 'bladeRF: allow setting reference frequency' (#2) from jan.hrach/gr-osmosdr:master into master
Reviewed-on: sdr/gr-osmosdr#2
2022-11-01 11:30:35 +00:00
Jan Hrach 3e531451f9 bladeRF: allow setting reference frequency 2022-07-07 21:20:00 +02:00
42 changed files with 2360 additions and 671 deletions

View File

@ -164,6 +164,7 @@ message (STATUS " Found Volk: ${Volk_FOUND}")
####################
find_package(LibRTLSDR)
find_package(LibMiriSDR)
if(ENABLE_NONFREE)
find_package(LibSDRplay)
endif(ENABLE_NONFREE)

View File

@ -15,7 +15,7 @@ author:
copyright_owner:
- Dimitri Stolnikov <horiz0n@gmx.net>
license: GPLv3
repo: git://git.osmocom.org/gr-osmosdr
repo: https://gitea.osmocom.org/sdr/gr-osmosdr
website: http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
---
GNU Radio block for interfacing with various radio hardware

50
README
View File

@ -1,50 +0,0 @@
While primarily being developed for the OsmoSDR hardware, this block
as well supports:
* FUNcube Dongle / Pro+ through gr-funcube
* RTL2832U based DVB-T dongles through librtlsdr
* RTL-TCP spectrum server (see librtlsdr project)
* SDRplay RSP through SDRplay API library
* gnuradio .cfile input through libgnuradio-blocks
* RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option)
* AirSpy Wideband Receiver through libairspy
* CCCamp 2015 rad1o Badge through libhackrf
* Great Scott Gadgets HackRF through libhackrf
* Nuand LLC bladeRF through libbladeRF library
* Ettus USRP Devices through Ettus UHD library
* Fairwaves UmTRX through Fairwaves' module for UHD
* Fairwaves XTRX through libxtrx
* Red Pitaya SDR transceiver (http://bazaar.redpitaya.com)
* FreeSRP through libfreesrp
By using the OsmoSDR block you can take advantage of a common software api in
your application(s) independent of the underlying radio hardware.
For installation and usage guidelines please read the documentation available
at http://sdr.osmocom.org/trac/wiki/GrOsmoSDR
For the impatient :) a short excerpt:
The Gnu Radio block requires a recent gnuradio (>= v3.7) to be installed.
Before building the block you have to make sure that all the dependencies
(see list of supported devices above) you are intend to work with are
properly installed. The build system of gr-osmosdr will recognize them and
enable specific source/sink components thereafter.
Please note: prior pulling a new version from git and compiling it,
please do a "make uninstall" first to properly remove the previous version.
Building with cmake:
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr/
mkdir build
cd build/
cmake ../
make
sudo make install
sudo ldconfig
NOTE: The osmocom blocks will appear under 'Sources' and 'Sinks' categories
in GRC menu.

92
README.md Normal file
View File

@ -0,0 +1,92 @@
gr-osmosdr - generic gnuradio SDR I/O block
===========================================
While originally being developed for the
[OsmoSDR](https://osmocom.org/projects/osmosdr/wiki) hardware, this
block has become a generic SDR I/O block for a variety of SDR
hardware, including:
* FUNcube Dongle / Pro+ through [gr-funcube](https://github.com/dl1ksv/gr-funcube)
* RTL2832U based DVB-T dongles through [librtlsdr](https://osmocom.org/projects/rtl-sdr/wiki)
* RTL-TCP spectrum server (see librtlsdr project)
* MSi2500 based DVB-T dongles through [libmirisdr](https://gitea.osmocom.org/sdr/libmirisdr)
* SDRplay RSP through SDRplay API library
* gnuradio .cfile input through libgnuradio-blocks
* RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option), Cloud-IQ, and CloudSDR
* AirSpy Wideband Receiver through [libairspy](https://github.com/airspy/airspyone_host)
* CCCamp 2015 rad1o Badge through [libhackrf](https://github.com/greatscottgadgets/hackrf)
* Great Scott Gadgets HackRF through [libhackrf](https://github.com/greatscottgadgets/hackrf)
* Nuand LLC bladeRF through [libbladeRF library](https://www.nuand.com/libbladeRF-doc/)
* Ettus USRP Devices through [Ettus UHD library](https://github.com/EttusResearch/uhd)
* Fairwaves UmTRX through [Fairwaves' module for UHD](https://github.com/fairwaves/UHD-Fairwaves)
* Fairwaves XTRX through [libxtrx](https://github.com/myriadrf/libxtrx)
* Red Pitaya SDR transceiver <http://bazaar.redpitaya.com>
* FreeSRP through [libfreesrp](https://github.com/myriadrf/libfreesrp)
By using the gr-osmosdr block you can take advantage of a common software API in
your application(s) independent of the underlying radio hardware.
Homepage + Documentation
------------------------
For installation and usage guidelines please read the documentation available
at <https://osmocom.org/projects/gr-osmosdr/wiki>
For the impatient :) a short excerpt:
The Gnu Radio block requires a recent gnuradio (>= v3.7) to be installed.
Before building the block you have to make sure that all the dependencies
(see list of supported devices above) you are intend to work with are
properly installed. The build system of gr-osmosdr will recognize them and
enable specific source/sink components thereafter.
Please note: prior pulling a new version from git and compiling it,
please do a `make uninstall` first to properly remove the previous version.
Building with cmake:
```
git clone https://gitea.osmocom.org/sdr/gr-osmosdr
cd gr-osmosdr/
mkdir build
cd build/
cmake ../
make
sudo make install
sudo ldconfig
```
NOTE: The osmocom blocks will appear under *Sources* and *Sinks* categories
in GRC menu.
Forum
-----
We welcome any gr-osmosdr related discussions in the
[SDR](https://discourse.osmocom.org/c/sdr/)
section of the osmocom discourse (web based Forum).
Mailing List
------------
Discussions related to libosmocore are happening on the
osmocom-sdr@lists.osmocom.org mailing list, please see
<https://lists.osmocom.org/mailman/listinfo/osmocom-sdr> for subscription
options and the list archive.
Please observe the [Osmocom Mailing List
Rules](https://osmocom.org/projects/cellular-infrastructure/wiki/Mailing_List_Rules)
when posting.
Issue tracker
-------------
We are using the Osmocom redmine at <https://osmocom.org/projects/gr-osmosdr/issues>
Contributing
------------
We maintain our source code in a self-hosted instance of gitea at
<https://gitea.osmocom.org/sdr/gr-osmosdr>. You can send pull requests there, or send
patches the old-fashioned way (git send-email) to the above-mentioned mailing list.

View File

@ -0,0 +1,27 @@
if(NOT LIBMIRISDR_FOUND)
pkg_check_modules (LIBMIRISDR_PKG libmirisdr)
find_path(LIBMIRISDR_INCLUDE_DIRS NAMES mirisdr.h
PATHS
${LIBMIRISDR_PKG_INCLUDE_DIRS}
/usr/include
/usr/local/include
)
find_library(LIBMIRISDR_LIBRARIES NAMES mirisdr
PATHS
${LIBMIRISDR_PKG_LIBRARY_DIRS}
/usr/lib
/usr/local/lib
)
if(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES)
set(LIBMIRISDR_FOUND TRUE CACHE INTERNAL "libmirisdr found")
message(STATUS "Found libmirisdr: ${LIBMIRISDR_INCLUDE_DIRS}, ${LIBMIRISDR_LIBRARIES}")
else(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES)
set(LIBMIRISDR_FOUND FALSE CACHE INTERNAL "libmirisdr found")
message(STATUS "libmirisdr not found.")
endif(LIBMIRISDR_INCLUDE_DIRS AND LIBMIRISDR_LIBRARIES)
mark_as_advanced(LIBMIRISDR_LIBRARIES LIBMIRISDR_INCLUDE_DIRS)
endif(NOT LIBMIRISDR_FOUND)

188
debian/changelog vendored Normal file
View File

@ -0,0 +1,188 @@
gr-osmosdr (0.1.5git) unstable; urgency=medium
* Add initial support for Airspy HF+
* Support for FreeSRP via libfreesrp
-- Harald Welte <laforge@gnumonks.org> Sun, 03 Jun 2018 10:38:52 +0200
gr-osmosdr (0.1.4-14) unstable; urgency=medium
* Add initial support for Airspy HF+
* Support for FreeSRP via libfreesrp
-- A. Maitland Bottoms <bottoms@debian.org> Thu, 23 Nov 2017 10:38:52 -0500
gr-osmosdr (0.1.4-13) unstable; urgency=medium
* update to v0.1.4-98-gc653754
* rtl-sdr bias-T support
* build with gnuradio-3.7.11
-- A. Maitland Bottoms <bottoms@debian.org> Thu, 07 Sep 2017 19:50:05 -0400
gr-osmosdr (0.1.4-12) unstable; urgency=medium
* rebuild with airspy-host 1.0.9
-- A. Maitland Bottoms <bottoms@debian.org> Fri, 14 Oct 2016 20:58:28 -0400
gr-osmosdr (0.1.4-11) unstable; urgency=medium
* Add SoapySDR support
-- A. Maitland Bottoms <bottoms@debian.org> Sun, 28 Aug 2016 14:52:53 -0400
gr-osmosdr (0.1.4-10) unstable; urgency=medium
* build with gnuradio-3.7.10
-- A. Maitland Bottoms <bottoms@debian.org> Sun, 10 Jul 2016 12:41:34 -0400
gr-osmosdr (0.1.4-9) unstable; urgency=medium
* update to v0.1.4-72-g164a09f
* rebuild on kfreebsd (Closes: #822132)
-- A. Maitland Bottoms <bottoms@debian.org> Fri, 29 Apr 2016 05:10:35 -0400
gr-osmosdr (0.1.4-8) unstable; urgency=medium
* update to v0.1.4-67-gac15e78, build with gnuradio 3.7.9
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 13 Jan 2016 00:16:06 -0500
gr-osmosdr (0.1.4-7) unstable; urgency=medium
* Lintian cleanups pre-depends and dep5-copyright
-- A. Maitland Bottoms <bottoms@debian.org> Sat, 28 Nov 2015 22:57:30 -0500
gr-osmosdr (0.1.4-6) unstable; urgency=medium
* Don't depend upon hackrf on non-linux
-- A. Maitland Bottoms <bottoms@debian.org> Mon, 05 Oct 2015 00:25:01 -0400
gr-osmosdr (0.1.4-5) unstable; urgency=medium
* Rebuild with uhd 3.9.1-3
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 30 Sep 2015 21:06:49 -0400
gr-osmosdr (0.1.4-4) unstable; urgency=medium
* Tighten libuhd003 versioned dependency via dh_makeshlibs
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 30 Sep 2015 01:04:40 -0400
gr-osmosdr (0.1.4-3) unstable; urgency=low
* rebuild with uhd-3.9.1
* post gcc-5 libstdc++6 transition build (Closes: #791062)
-- A. Maitland Bottoms <bottoms@debian.org> Mon, 14 Sep 2015 20:51:16 -0400
gr-osmosdr (0.1.4-2) unstable; urgency=medium
* add watch file, rebuild with uhd-3.9.0
-- A. Maitland Bottoms <bottoms@debian.org> Thu, 10 Sep 2015 10:55:58 -0400
gr-osmosdr (0.1.4-1) unstable; urgency=medium
* New upstream, update to v0.1.4-48-g86ad584
build with gnuradio 3.7.8
-- A. Maitland Bottoms <bottoms@debian.org> Sun, 16 Aug 2015 21:55:38 -0400
gr-osmosdr (0.1.3-2) unstable; urgency=low
* Add versioned depends for bladerf (Closes: #759927)
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 10 Sep 2014 23:57:56 -0400
gr-osmosdr (0.1.3-1) unstable; urgency=low
* New upstream release
* build with gnuradio 3.7.5
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 03 Sep 2014 22:21:12 -0400
gr-osmosdr (0.1.2-1) unstable; urgency=low
* New upstream release, update to v0.1.2-2-g8604d76
* Include airspy support
* pkg-gr-osmosdr git for Debian packaging (Closes: #759268)
-- A. Maitland Bottoms <bottoms@debian.org> Thu, 28 Aug 2014 14:37:08 -0400
gr-osmosdr (0.1.1.4.ac95af2-1) unstable; urgency=low
* Update to v0.1.1-4-gac95af2
reverting 66109099 rtl: implement methods allowing runtime to control
sampling process
* Build with gnuradio 3.7.3 (Closes: #743392)
* Osmocom MiriSDR support
-- A. Maitland Bottoms <bottoms@debian.org> Sat, 19 Apr 2014 19:22:49 -0400
gr-osmosdr (0.1.0.55.80c4af-2~bpo70~1) wheezy-backports; urgency=low
* Rebuild for wheezy-backports.
-- A. Maitland Bottoms <bottoms@debian.org> Tue, 11 Feb 2014 16:57:11 -0500
gr-osmosdr (0.1.0.55.80c4af-2) unstable; urgency=low
* ship grc blocks
-- A. Maitland Bottoms <bottoms@debian.org> Fri, 03 Jan 2014 00:32:28 -0500
gr-osmosdr (0.1.0.55.80c4af-1) unstable; urgency=low
* New upstream commit, build with gnuradio 3.7.2.1
-- A. Maitland Bottoms <bottoms@debian.org> Tue, 31 Dec 2013 00:09:54 -0500
gr-osmosdr (0.1.0.11.04b4c8-3) unstable; urgency=low
* Fix up dependencies for current unstable build
-- A. Maitland Bottoms <bottoms@debian.org> Thu, 12 Dec 2013 12:05:35 -0500
gr-osmosdr (0.1.0.11.04b4c8-2) unstable; urgency=low
* drop bladerf dependency
-- A. Maitland Bottoms <bottoms@debian.org> Sat, 23 Nov 2013 11:25:21 -0500
gr-osmosdr (0.1.0.11.04b4c8-1) unstable; urgency=low
* New upstream snapshot (Closes: #726469)
* Match GNU Radio live distribution version
-- A. Maitland Bottoms <bottoms@debian.org> Tue, 08 Oct 2013 17:30:31 -0400
gr-osmosdr (0.1git59ceddb-1) unstable; urgency=low
* New upstream release, build with gnuradio 3.6.4.1-0wheezy1
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 01 May 2013 17:19:35 -0400
gr-osmosdr (0.1gitd11b7a-1) unstable; urgency=low
* New upstream git, build with gnuradio 3.6.3
-- A. Maitland Bottoms <bottoms@debian.org> Wed, 13 Feb 2013 15:56:33 -0500
gr-osmosdr (0.1git0f25dae-1) unstable; urgency=low
* New upstream git, build with gnuradio 3.6.2
-- A. Maitland Bottoms <bottoms@debian.org> Sun, 16 Sep 2012 20:47:39 -0400
gr-osmosdr (0.0git7f796fe-1) unstable; urgency=low
* New upstream git, build with gnuradio 3.6.0
-- A. Maitland Bottoms <bottoms@debian.org> Mon, 14 May 2012 20:28:18 -0400

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
9

79
debian/control vendored Normal file
View File

@ -0,0 +1,79 @@
Source: gr-osmosdr
Section: libdevel
Priority: optional
Maintainer: Harald Welte <laforge@gnumonks.org>
Build-Depends: cmake,
debhelper (>= 9.0.0~),
dh-python,
doxygen,
gnuradio-dev (>=3.7.11),
gr-fcdproplus (>=3.7.25.4b6464b-3) [!hurd-i386],
gr-iqbal (>=0.37.2-8),
libairspy-dev (>= 1.0.9~) [!hurd-i386],
libairspyhf-dev [!hurd-i386],
libbladerf-dev (>=0.2016.01~rc1) [!hurd-i386],
libboost-dev,
libboost-system-dev,
libboost-thread-dev,
libfreesrp-dev [!hurd-i386],
libhackrf-dev [linux-any],
liblog4cpp5-dev,
libmirisdr-dev [!hurd-i386],
libosmosdr-dev [!hurd-i386],
librtlsdr-dev [!hurd-i386],
libsoapysdr-dev,
libuhd-dev (>=3.10),
pkg-config,
python-dev,
python-soapysdr,
swig
X-Python-Version: >= 2.7, << 2.8
Standards-Version: 4.1.0
Homepage: https://osmocom.org/projects/gr-osmosdr/wiki
Vcs-Git: https://gitea.osmocom.org/sdr/gr-osmosdr
Vcs-Browser: https://gitea.osmocom.org/sdr/gr-osmosdr
Package: gr-osmosdr
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${python:Depends}, ${shlibs:Depends}
Recommends: gnuradio, gr-fosphor
Description: Gnuradio blocks from the OsmoSDR project
The Osmocom project is a family of projects regarding Open source
mobile communications.
.
While primarily being developed for the OsmoSDR hardware, this block
as well supports:
- FUNcube Dongle through libgnuradio-fcd
- FUNcube Dongle Pro+ through gr-fcdproplus
- sysmocom OsmoSDR Devices through libosmosdr
- RTL2832U based DVB-T dongles through librtlsdr
- RTL-TCP spectrum server (see librtlsdr project)
- MSi2500 based DVB-T dongles through libmirisdr
- gnuradio .cfile input through libgnuradio-blocks
- RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option)
- Great Scott Gadgets HackRF through libhackrf
- Nuand LLC bladeRF through libbladeRF library
- Ettus USRP Devices through Ettus UHD library
- Fairwaves UmTRX through Fairwaves' fork of UHD
- AIRSPY Receiver
- AIRSPY HF+ Receiver
- SoapySDR support
- Red Pitaya SDR transceiver (http://bazaar.redpitaya.com)
- FreeSRP through libfreesrp
.
By using the OsmoSDR block you can take advantage of a common
software API in your application(s) independent of the underlying
radio hardware.
Package: libgnuradio-osmosdr0.1.4
Section: libs
Architecture: any
Pre-Depends: ${misc:Pre-Depends}
Depends: ${misc:Depends}, ${shlibs:Depends}
Multi-Arch: same
Description: Gnuradio blocks from the OsmoSDR project - library
The Osmocom project is a family of projects regarding Open source
mobile communications.
.
This package contains the shared library.

195
debian/copyright vendored Normal file
View File

@ -0,0 +1,195 @@
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gr-osmosdr
Upstream-Contact: http://sdr.osmocom.org/trac/wiki/rtl-sdr
Source:
git clone https://gitea.osmocom.org/sdr/gr-osmosdr
The upstream package source tarball was generated from the tag:
git archive --format=tar --prefix=gr-osmosdr-0.1.4/ v0.1.4 | xz > ../gr-osmosdr_0.1.4.orig.tar.xz
Comment:
Debian packages by A. Maitland Bottoms <bottoms@debian.org>,
.
Upstream Author:
Dimitri Stolnikov <horiz0n@gmx.net>
Copyright: 2012,2013 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: COPYING
Copyright: 2007 Free Software Foundation, Inc. <http://fsf.org/>
License: FSF-COPYING
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Files: CMakeLists.txt apps/* docs/* python/* include/osmosdr/api.h
cmake/Modules/* include/osmosdr/CMakeLists.txt
lib/CMakeLists.txt lib/gnuradio-osmosdr.rc.in
lib/bladerf/CMakeLists.txt swig/* grc/CMakeLists.txt
Copyright: 2005,2007-2013 Free Software Foundation, Inc.
Comment: GNU Radio gr_modtool derived
License: GPL-3+
Files: debian/*
Copyright: 2013 A. Maitland Bottoms <bottoms@debian.org>
License: GPL-3+
Files: grc/gen_osmosdr_blocks.py
Copyright: 2012 Free Software Foundation, Inc.
License: GPL-2+
Files: include/osmosdr/pimpl.h include/osmosdr/ranges.h lib/ranges.cc
include/osmosdr/time_spec.h lib/time_spec.cc
Copyright: 2010-2013 Ettus Research LLC
License: GPL-3+
FIles: lib/bladerf/bladerf_common.cc lib/bladerf/bladerf_common.h
lib/bladerf/bladerf_sink_c.cc lib/bladerf/bladerf_sink_c.h
lib/bladerf/bladerf_source_c.cc lib/bladerf/bladerf_source_c.h
Copyright: 2013 Nuand LLC
2013 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: lib/soapy/*
Copyright: 2015 Josh Blum <josh@joshknows.com>
2013 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: lib/freesrp/*
Copyright: 2017 by Lukas Lao Beyer
License: GPL-3+
Files: AUTHORS MANIFEST.md README.md gnuradio-osmosdr.pc.in
cmake/cmake_uninstall.cmake.in include/osmosdr/device.h
include/osmosdr/sink.h include/osmosdr/source.h
lib/arg_helpers.h lib/config.h.in lib/device.cc
lib/sink_iface.h lib/sink_impl.cc lib/sink_impl.h
lib/source_iface.h lib/source_impl.cc lib/source_impl.h
lib/airspy/* lib/fcd/* lib/file/* lib/hackrf/*
lib/miri/* lib/osmosdr/* lib/rfspace/* lib/rtl*
lib/sdrplay/* lib/uhd/*
Copyright: 2012-2013 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: lib/rtl_tcp/rtl_tcp_source_f.h
Copyright: 2012 Hoernchen <la@tfc-server.de>
License: GPL-3+
Files: lib/miri/miri_source_c.cc
Copyright: 2012 Steve Markgraf <steve@steve-m.de>
2012 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: lib/redpitaya/*
Copyright: 2015 Pavel Demin
2012,2015 Dimitri Stolnikov <horiz0n@gmx.net>
License: GPL-3+
Files: lib/freesrp/readerwriterqueue/*
Copyright: 2013-2015, Cameron Desrochers
Comment: libfreesrp includes ReaderWriterQueue
License: Simplified-BSD
All rights reserved.
.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
.
- Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Files: lib/freesrp/readerwriterqueue/atomicops.h
Copyright: 2015 Jeff Preshing
License: atomicops
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
.
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Files: cmake/Modules/CMakeParseArgumentsCopy.cmake
Copyright: 2010 Alexander Neundorf <neundorf@kde.org>
Comment: copy of CMakeParseArguments.cmake from cmake 2.8.x
License: Kitware-BSD
All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
.
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
.
* Neither the names of Kitware, Inc., the Insight Software Consortium,
nor the names of their contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
License: GPL-2+
GNU Radio Companion is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
.
GNU Radio Companion is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
.
On Debian systems, the complete text of the GNU General Public
License (GPL) version 3 can be found in the file
'/usr/share/common-licenses/GPL-2'.
License: GPL-3+
GNU Radio is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
.
GNU Radio is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
.
On Debian systems, the complete text of the GNU General Public
License (GPL) version 3 can be found in the file
'/usr/share/common-licenses/GPL-3'.

6
debian/gr-osmosdr.install vendored Normal file
View File

@ -0,0 +1,6 @@
usr/bin/*
usr/include/*
usr/lib/*/lib*.so
usr/lib/*/pkgconfig/*
usr/lib/python*
usr/share/*

4
debian/gr-osmosdr.manpages vendored Normal file
View File

@ -0,0 +1,4 @@
debian/osmocom_fft.1
debian/osmocom_siggen.1
debian/osmocom_siggen_nogui.1
debian/osmocom_spectrum_sense.1

View File

@ -0,0 +1 @@
usr/lib/*/lib*.so.*

224
debian/osmocom_fft.1 vendored Normal file
View File

@ -0,0 +1,224 @@
.TH osmocom_fft "1" "October 2013" "OSMOCOM" "User Commands"
.SH NAME
osmocom_fft \- Spectrum Browser
.SH SYNOPSIS
.B osmocom_fft
[\fIoptions\fR]
.SH DESCRIPTION
Spectrum Browser
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-a\fR ARGS, \fB\-\-args\fR=\fIARGS\fR
Device args, [default=]
.TP
\fB\-A\fR ANTENNA, \fB\-\-antenna\fR=\fIANTENNA\fR
Select RX antenna where appropriate
.TP
\fB\-s\fR SAMP_RATE, \fB\-\-samp\-rate\fR=\fISAMP_RATE\fR
Set sample rate (bandwidth), minimum by default
.TP
\fB\-f\fR FREQ, \fB\-\-center\-freq\fR=\fIFREQ\fR
Set frequency to FREQ
.TP
\fB\-c\fR FREQ_CORR, \fB\-\-freq\-corr\fR=\fIFREQ_CORR\fR
Set frequency correction (ppm)
.TP
\fB\-g\fR GAIN, \fB\-\-gain\fR=\fIGAIN\fR
Set gain in dB (default is midpoint)
.TP
\fB\-W\fR, \fB\-\-waterfall\fR
Enable waterfall display
.TP
\fB\-S\fR, \fB\-\-oscilloscope\fR
Enable oscilloscope display
.TP
\fB\-\-avg\-alpha\fR=\fIAVG_ALPHA\fR
Set fftsink averaging factor, default=[0.1]
.TP
\fB\-\-averaging\fR
Enable fftsink averaging, default=[False]
.TP
\fB\-\-ref\-scale\fR=\fIREF_SCALE\fR
Set dBFS=0dB input value, default=[1.0]
.TP
\fB\-\-fft\-size\fR=\fIFFT_SIZE\fR
Set number of FFT bins [default=1024]
.TP
\fB\-\-fft\-rate\fR=\fIFFT_RATE\fR
Set FFT update rate, [default=30]
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose console output [default=False]
.SH "SEE ALSO"
The full documentation for
.B linux;
is maintained as a Texinfo manual. If the
.B info
and
.B linux;
programs are properly installed at your site, the command
.IP
.B info linux;
.PP
should give you access to the complete manual.
.SH Device specification
You can specify the source or sink device using a comma separated string of argument=value pairs. The always-up-to-date block documentation with examples is available right here.
.SH FCD Source
.TP
Argument
Notes
.TP
fcd=<device-index>
0-based device identifier, optional
.TP
device=hw:2
overrides the audio device
.TP
type=2
selects the dongle type, 1 for Classic, 2 for Pro+
.LP
The "device" argument overrides the audio device used by the underlying driver to access the dongle's IQ sample stream.
.LP
The "type" argument selects the dongle type, 1 for Classic, 2 for Pro+.
.SH OsmoSDR Source
.TP
Argument
Notes
.TP
osmosdr=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.SH RTL-SDR Source
.TP
Argument
Notes
.TP
rtl=<device-index>
0-based device identifier OR serial number
.TP
rtl_xtal=<frequency>
Frequency (Hz) used for the RTL chip, accepts eng notation
.TP
tuner_xtal=<frequency>
Frequency (Hz) used for the tuner chip, accepts eng notation
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip. 0: Disable, 1: use I channel, 2: use Q channel
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.LP
NOTE: use rtl_eeprom -s to program your own serial number to the device
.LP
NOTE: if you don't specify rtl_xtal/tuner_xtal, the underlying driver will use 28.0MHz
.SH RTL-SDR TCP Source
.TP
Argument
Notes
.TP
rtl_tcp=<hostname>:<port>
hostname defaults to "localhost", port to "1234"
.TP
psize=<payload-size>
Default is 16384 bytes
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip 0=Off, 1=I-ADC input enabled, 2=Q-ADC input enabled
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.SH Miri Source
.TP
Argument
Notes
.TP
miri=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.SH UHD Source / Sink
Argument
Notes
.TP
uhd
Use this argument without a value
.TP
nchan=<channel-count>
For multichannel USRP configurations use the subdev parameter to specify stream mapping
.TP
subdev=<subdev-spec>
Examples: "A:0", "B:0", "A:0 B:0" when nchan=2. Refer original ettus documentation on this
.TP
lo_offset=<frequency>
Offset frequency in Hz, must be within daughterboard bandwidth. Accepts eng notation
.LP
Additional argument/value pairs will be passed to the underlying driver, for more information see specifying the subdevice and common device identifiers in the Ettus documentation.
.SH bladeRF Source / Sink
.TP
Argument
Notes
.TP
bladerf[=0]
0-based device identifier (optional)
.TP
fw='/path/to/the/firmware.img'
program MCU firmware from given file. usually not needed. power cycle required.
.TP
fpga='/path/to/the/bitstream.rbf'
load FPGA bitstream from given file. required only at first run at the moment.
.SH HackRF Source / Sink
.TP
Argument
Notes
.TP
hackrf
Use this argument without a value
.TP
buffers=<number-of-buffers>
Default is 32
.LP
Only the first device found may be used at the moment because of libhackrf limitation.
.LP
Transmit support has been verified by using the crc-mmbTools DAB sdr transmitter.
.SH IQ File Source
.TP
Argument
Notes
.TP
file=<path-to-file-name>
.TP
freq=<frequency>
Center frequency in Hz, accepts eng notation
.TP
rate=<sampling-rate>
Mandatory, in samples/s, accepts eng notation
.TP
repeat=true|false
Default is true
.TP
throttle=true|false
Throttle flow of samples, default is true
.SH EXAMPLES
.LP
osmocom_fft -a rtl=0 -v -f 100e6 -s 2.4e6 -g 15
.LP
osmocom_fft -a hackrf -v
.LP
osmocom_fft -a uhd -v
.SH "SEE ALSO"
osmocom_siggen(1) osmocom_siggen_nogui(1) osmocom_spectrum_sense(1)

222
debian/osmocom_siggen.1 vendored Normal file
View File

@ -0,0 +1,222 @@
.TH osmocom_siggen "1" "October 2013" "OSMOCOM" "User Commands"
.SH NAME
osmocom_siggen \- Signal Generator Application with GUI controls
.SH SYNOPSIS
.B osmocom_siggen:
[\fIoptions\fR]
.SH DESCRIPTION
Signal Generator Application with GUI controls
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-a\fR ARGS, \fB\-\-args\fR=\fIARGS\fR
Device args, [default=]
.TP
\fB\-A\fR ANTENNA, \fB\-\-antenna\fR=\fIANTENNA\fR
Select Rx Antenna where appropriate
.TP
\fB\-s\fR SAMP_RATE, \fB\-\-samp\-rate\fR=\fISAMP_RATE\fR
Set sample rate (bandwidth), minimum by default
.TP
\fB\-g\fR GAIN, \fB\-\-gain\fR=\fIGAIN\fR
Set gain in dB (default is midpoint)
.TP
\fB\-f\fR FREQ, \fB\-\-tx\-freq\fR=\fIFREQ\fR
Set carrier frequency to FREQ [default=mid\-point]
.TP
\fB\-c\fR FREQ_CORR, \fB\-\-freq\-corr\fR=\fIFREQ_CORR\fR
Set carrier frequency correction [default=0]
.TP
\fB\-x\fR WAVEFORM_FREQ, \fB\-\-waveform\-freq\fR=\fIWAVEFORM_FREQ\fR
Set baseband waveform frequency to FREQ [default=0]
.TP
\fB\-y\fR WAVEFORM2_FREQ, \fB\-\-waveform2\-freq\fR=\fIWAVEFORM2_FREQ\fR
Set 2nd waveform frequency to FREQ [default=none]
.TP
\fB\-\-sine\fR
Generate a carrier modulated by a complex sine wave
.TP
\fB\-\-const\fR
Generate a constant carrier
.TP
\fB\-\-offset\fR=\fIOFFSET\fR
Set waveform phase offset to OFFSET [default=0]
.TP
\fB\-\-gaussian\fR
Generate Gaussian random output
.TP
\fB\-\-uniform\fR
Generate Uniform random output
.TP
\fB\-\-2tone\fR
Generate Two Tone signal for IMD testing
.TP
\fB\-\-sweep\fR
Generate a swept sine wave
.TP
\fB\-\-gsm\fR
Generate GMSK modulated GSM Burst Sequence
.TP
\fB\-\-amplitude\fR=\fIAMPL\fR
Set output amplitude to AMPL (0.1\-1.0) [default=0.3]
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose console output [default=False]
.SH Device specification
You can specify the source or sink device using a comma separated string of argument=value pairs. The always-up-to-date block documentation with examples is available right here.
.SH FCD Source
.TP
Argument
Notes
.TP
fcd=<device-index>
0-based device identifier, optional
.TP
device=hw:2
overrides the audio device
.TP
type=2
selects the dongle type, 1 for Classic, 2 for Pro+
.LP
The "device" argument overrides the audio device used by the underlying driver to access the dongle's IQ sample stream.
.LP
The "type" argument selects the dongle type, 1 for Classic, 2 for Pro+.
.SH OsmoSDR Source
.TP
Argument
Notes
.TP
osmosdr=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.SH RTL-SDR Source
.TP
Argument
Notes
.TP
rtl=<device-index>
0-based device identifier OR serial number
.TP
rtl_xtal=<frequency>
Frequency (Hz) used for the RTL chip, accepts eng notation
.TP
tuner_xtal=<frequency>
Frequency (Hz) used for the tuner chip, accepts eng notation
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip. 0: Disable, 1: use I channel, 2: use Q channel
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.LP
NOTE: use rtl_eeprom -s to program your own serial number to the device
.LP
NOTE: if you don't specify rtl_xtal/tuner_xtal, the underlying driver will use 28.0MHz
.SH RTL-SDR TCP Source
.TP
Argument
Notes
.TP
rtl_tcp=<hostname>:<port>
hostname defaults to "localhost", port to "1234"
.TP
psize=<payload-size>
Default is 16384 bytes
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip 0=Off, 1=I-ADC input enabled, 2=Q-ADC input enabled
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.SH Miri Source
.TP
Argument
Notes
.TP
miri=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.SH UHD Source / Sink
Argument
Notes
.TP
uhd
Use this argument without a value
.TP
nchan=<channel-count>
For multichannel USRP configurations use the subdev parameter to specify stream mapping
.TP
subdev=<subdev-spec>
Examples: "A:0", "B:0", "A:0 B:0" when nchan=2. Refer original ettus documentation on this
.TP
lo_offset=<frequency>
Offset frequency in Hz, must be within daughterboard bandwidth. Accepts eng notation
.LP
Additional argument/value pairs will be passed to the underlying driver, for more information see specifying the subdevice and common device identifiers in the Ettus documentation.
.SH bladeRF Source / Sink
.TP
Argument
Notes
.TP
bladerf[=0]
0-based device identifier (optional)
.TP
fw='/path/to/the/firmware.img'
program MCU firmware from given file. usually not needed. power cycle required.
.TP
fpga='/path/to/the/bitstream.rbf'
load FPGA bitstream from given file. required only at first run at the moment.
.SH HackRF Source / Sink
.TP
Argument
Notes
.TP
hackrf
Use this argument without a value
.TP
buffers=<number-of-buffers>
Default is 32
.LP
Only the first device found may be used at the moment because of libhackrf limitation.
.LP
Transmit support has been verified by using the crc-mmbTools DAB sdr transmitter.
.SH IQ File Source
.TP
Argument
Notes
.TP
file=<path-to-file-name>
.TP
freq=<frequency>
Center frequency in Hz, accepts eng notation
.TP
rate=<sampling-rate>
Mandatory, in samples/s, accepts eng notation
.TP
repeat=true|false
Default is true
.TP
throttle=true|false
Throttle flow of samples, default is true
.SH EXAMPLES
.LP
osmocom_siggen -a hackrf -f 100e6 --sine
.LP
osmocom_siggen -a hackrf -f 100e6 --sweep -x 2M -y 1 -c34
.SH "SEE ALSO"
osmocom_fft(1) osmocom_siggen(1) osmocom_spectrum_sense(1)

224
debian/osmocom_siggen_nogui.1 vendored Normal file
View File

@ -0,0 +1,224 @@
.TH osmocom_siggen_nogui "1" "October 2013" "OSMOCOM" "User Commands"
.SH NAME
osmocom_siggen_nogui \- Signal generator application
.SH SYNOPSIS
.B osmocom_siggen_nogui:
[\fIoptions\fR]
.SH DESCRIPTION
Signal generator application
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-a\fR ARGS, \fB\-\-args\fR=\fIARGS\fR
Device args, [default=]
.TP
\fB\-A\fR ANTENNA, \fB\-\-antenna\fR=\fIANTENNA\fR
Select Rx Antenna where appropriate
.TP
\fB\-s\fR SAMP_RATE, \fB\-\-samp\-rate\fR=\fISAMP_RATE\fR
Set sample rate (bandwidth), minimum by default
.TP
\fB\-g\fR GAIN, \fB\-\-gain\fR=\fIGAIN\fR
Set gain in dB (default is midpoint)
.TP
\fB\-f\fR FREQ, \fB\-\-tx\-freq\fR=\fIFREQ\fR
Set carrier frequency to FREQ [default=mid\-point]
.TP
\fB\-c\fR FREQ_CORR, \fB\-\-freq\-corr\fR=\fIFREQ_CORR\fR
Set carrier frequency correction [default=0]
.TP
\fB\-x\fR WAVEFORM_FREQ, \fB\-\-waveform\-freq\fR=\fIWAVEFORM_FREQ\fR
Set baseband waveform frequency to FREQ [default=0]
.TP
\fB\-y\fR WAVEFORM2_FREQ, \fB\-\-waveform2\-freq\fR=\fIWAVEFORM2_FREQ\fR
Set 2nd waveform frequency to FREQ [default=none]
.TP
\fB\-\-sine\fR
Generate a carrier modulated by a complex sine wave
.TP
\fB\-\-const\fR
Generate a constant carrier
.TP
\fB\-\-offset\fR=\fIOFFSET\fR
Set waveform phase offset to OFFSET [default=0]
.TP
\fB\-\-gaussian\fR
Generate Gaussian random output
.TP
\fB\-\-uniform\fR
Generate Uniform random output
.TP
\fB\-\-2tone\fR
Generate Two Tone signal for IMD testing
.TP
\fB\-\-sweep\fR
Generate a swept sine wave
.TP
\fB\-\-gsm\fR
Generate GMSK modulated GSM Burst Sequence
.TP
\fB\-\-amplitude\fR=\fIAMPL\fR
Set output amplitude to AMPL (0.1\-1.0) [default=0.3]
.TP
\fB\-v\fR, \fB\-\-verbose\fR
Use verbose console output [default=False]
.PP
Note: failed to enable realtime scheduling, continuing
.SH Device specification
You can specify the source or sink device using a comma separated string of argument=value pairs. The always-up-to-date block documentation with examples is available right here.
.SH FCD Source
.TP
Argument
Notes
.TP
fcd=<device-index>
0-based device identifier, optional
.TP
device=hw:2
overrides the audio device
.TP
type=2
selects the dongle type, 1 for Classic, 2 for Pro+
.LP
The "device" argument overrides the audio device used by the underlying driver to access the dongle's IQ sample stream.
.LP
The "type" argument selects the dongle type, 1 for Classic, 2 for Pro+.
.SH OsmoSDR Source
.TP
Argument
Notes
.TP
osmosdr=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.SH RTL-SDR Source
.TP
Argument
Notes
.TP
rtl=<device-index>
0-based device identifier OR serial number
.TP
rtl_xtal=<frequency>
Frequency (Hz) used for the RTL chip, accepts eng notation
.TP
tuner_xtal=<frequency>
Frequency (Hz) used for the tuner chip, accepts eng notation
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip. 0: Disable, 1: use I channel, 2: use Q channel
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.LP
NOTE: use rtl_eeprom -s to program your own serial number to the device
.LP
NOTE: if you don't specify rtl_xtal/tuner_xtal, the underlying driver will use 28.0MHz
.SH RTL-SDR TCP Source
.TP
Argument
Notes
.TP
rtl_tcp=<hostname>:<port>
hostname defaults to "localhost", port to "1234"
.TP
psize=<payload-size>
Default is 16384 bytes
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip 0=Off, 1=I-ADC input enabled, 2=Q-ADC input enabled
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.SH Miri Source
.TP
Argument
Notes
.TP
miri=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.SH UHD Source / Sink
Argument
Notes
.TP
uhd
Use this argument without a value
.TP
nchan=<channel-count>
For multichannel USRP configurations use the subdev parameter to specify stream mapping
.TP
subdev=<subdev-spec>
Examples: "A:0", "B:0", "A:0 B:0" when nchan=2. Refer original ettus documentation on this
.TP
lo_offset=<frequency>
Offset frequency in Hz, must be within daughterboard bandwidth. Accepts eng notation
.LP
Additional argument/value pairs will be passed to the underlying driver, for more information see specifying the subdevice and common device identifiers in the Ettus documentation.
.SH bladeRF Source / Sink
.TP
Argument
Notes
.TP
bladerf[=0]
0-based device identifier (optional)
.TP
fw='/path/to/the/firmware.img'
program MCU firmware from given file. usually not needed. power cycle required.
.TP
fpga='/path/to/the/bitstream.rbf'
load FPGA bitstream from given file. required only at first run at the moment.
.SH HackRF Source / Sink
.TP
Argument
Notes
.TP
hackrf
Use this argument without a value
.TP
buffers=<number-of-buffers>
Default is 32
.LP
Only the first device found may be used at the moment because of libhackrf limitation.
.LP
Transmit support has been verified by using the crc-mmbTools DAB sdr transmitter.
.SH IQ File Source
.TP
Argument
Notes
.TP
file=<path-to-file-name>
.TP
freq=<frequency>
Center frequency in Hz, accepts eng notation
.TP
rate=<sampling-rate>
Mandatory, in samples/s, accepts eng notation
.TP
repeat=true|false
Default is true
.TP
throttle=true|false
Throttle flow of samples, default is true
.SH EXAMPLES
.LP
osmocom_siggen_nogui -a hackrf -f 100e6 --sweep -x 2e6 -y 10 -v
.LP
osmocom_siggen_nogui -a uhd,subdev=A:0 -f 100e6 --sweep -x 2e6 -y 10 -s 4e6 -v
.SH "SEE ALSO"
osmocom_fft(1) osmocom_siggen(1) osmocom_spectrum_sense(1)

196
debian/osmocom_spectrum_sense.1 vendored Normal file
View File

@ -0,0 +1,196 @@
.TH osmocom_spectrum_sense "1" "October 2013" "OSMOCOMM" "User Commands"
.SH NAME
osmocom_spectrum_sense \- GNU Radio application from OsmoSDR
.SH SYNOPSIS
.B osmocom_spectrum_sense
[\fIoptions\fR] \fImin_freq max_freq\fR
.SH DESCRIPTION
GNU Radio application from OsmoSDR
.SH OPTIONS
.TP
\fB\-h\fR, \fB\-\-help\fR
show this help message and exit
.TP
\fB\-a\fR ARGS, \fB\-\-args\fR=\fIARGS\fR
Device args [default=]
.TP
\fB\-A\fR ANTENNA, \fB\-\-antenna\fR=\fIANTENNA\fR
Select antenna where appropriate
.TP
\fB\-s\fR SAMP_RATE, \fB\-\-samp\-rate\fR=\fISAMP_RATE\fR
Set sample rate (bandwidth), minimum by default
.TP
\fB\-g\fR GAIN, \fB\-\-gain\fR=\fIGAIN\fR
Set gain in dB (default is midpoint)
.TP
\fB\-\-tune\-delay\fR=\fISECS\fR
Time to delay (in seconds) after changing frequency
[default=0.25]
.TP
\fB\-\-dwell\-delay\fR=\fISECS\fR
Time to dwell (in seconds) at a given frequency
[default=0.25]
.TP
\fB\-b\fR Hz, \fB\-\-channel\-bandwidth\fR=\fIHz\fR
Channel bandwidth of fft bins in Hz [default=6250.0]
.TP
\fB\-q\fR dB, \fB\-\-squelch\-threshold\fR=\fIdB\fR
Squelch threshold in dB [default=none]
.TP
\fB\-F\fR FFT_SIZE, \fB\-\-fft\-size\fR=\fIFFT_SIZE\fR
Specify number of FFT bins
[default=samp_rate/channel_bw]
.TP
\fB\-\-real\-time\fR
Attempt to enable real\-time scheduling
.SH Device specification
You can specify the source or sink device using a comma separated string of argument=value pairs. The always-up-to-date block documentation with examples is available right here.
.SH FCD Source
.TP
Argument
Notes
.TP
fcd=<device-index>
0-based device identifier, optional
.TP
device=hw:2
overrides the audio device
.TP
type=2
selects the dongle type, 1 for Classic, 2 for Pro+
.LP
The "device" argument overrides the audio device used by the underlying driver to access the dongle's IQ sample stream.
.LP
The "type" argument selects the dongle type, 1 for Classic, 2 for Pro+.
.SH OsmoSDR Source
.TP
Argument
Notes
.TP
osmosdr=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.SH RTL-SDR Source
.TP
Argument
Notes
.TP
rtl=<device-index>
0-based device identifier OR serial number
.TP
rtl_xtal=<frequency>
Frequency (Hz) used for the RTL chip, accepts eng notation
.TP
tuner_xtal=<frequency>
Frequency (Hz) used for the tuner chip, accepts eng notation
.TP
buffers=<number-of-buffers>
Default is 32
.TP
buflen=<length-of-buffer>
Default is 256kB, must be multiple of 512
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip. 0: Disable, 1: use I channel, 2: use Q channel
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.LP
NOTE: use rtl_eeprom -s to program your own serial number to the device
.LP
NOTE: if you don't specify rtl_xtal/tuner_xtal, the underlying driver will use 28.0MHz
.SH RTL-SDR TCP Source
.TP
Argument
Notes
.TP
rtl_tcp=<hostname>:<port>
hostname defaults to "localhost", port to "1234"
.TP
psize=<payload-size>
Default is 16384 bytes
.TP
direct_samp=0|1|2
Enable direct sampling mode on the RTL chip 0=Off, 1=I-ADC input enabled, 2=Q-ADC input enabled
.TP
offset_tune=0|1
Enable offset tune mode for E4000 tuners
.SH Miri Source
.TP
Argument
Notes
.TP
miri=<device-index>
0-based device identifier
.TP
buffers=<number-of-buffers>
Default is 32
.SH UHD Source / Sink
Argument
Notes
.TP
uhd
Use this argument without a value
.TP
nchan=<channel-count>
For multichannel USRP configurations use the subdev parameter to specify stream mapping
.TP
subdev=<subdev-spec>
Examples: "A:0", "B:0", "A:0 B:0" when nchan=2. Refer original ettus documentation on this
.TP
lo_offset=<frequency>
Offset frequency in Hz, must be within daughterboard bandwidth. Accepts eng notation
.LP
Additional argument/value pairs will be passed to the underlying driver, for more information see specifying the subdevice and common device identifiers in the Ettus documentation.
.SH bladeRF Source / Sink
.TP
Argument
Notes
.TP
bladerf[=0]
0-based device identifier (optional)
.TP
fw='/path/to/the/firmware.img'
program MCU firmware from given file. usually not needed. power cycle required.
.TP
fpga='/path/to/the/bitstream.rbf'
load FPGA bitstream from given file. required only at first run at the moment.
.SH HackRF Source / Sink
.TP
Argument
Notes
.TP
hackrf
Use this argument without a value
.TP
buffers=<number-of-buffers>
Default is 32
.LP
Only the first device found may be used at the moment because of libhackrf limitation.
.LP
Transmit support has been verified by using the crc-mmbTools DAB sdr transmitter.
.SH IQ File Source
.TP
Argument
Notes
.TP
file=<path-to-file-name>
.TP
freq=<frequency>
Center frequency in Hz, accepts eng notation
.TP
rate=<sampling-rate>
Mandatory, in samples/s, accepts eng notation
.TP
repeat=true|false
Default is true
.TP
throttle=true|false
Throttle flow of samples, default is true
.SH "SEE ALSO"
osmocom_fft(1) osmocom_siggen(1) osmocom_siggen_nogui(1)

29
debian/rules vendored Executable file
View File

@ -0,0 +1,29 @@
#!/usr/bin/make -f
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_HOST_MULTIARCH
DEB_DEBIAN_DIR=$(dir $(firstword $(MAKEFILE_LIST)))
VER=$(shell dpkg-parsechangelog -l$(DEB_DEBIAN_DIR)/changelog \
| sed -rne 's,^Version: ([^-]+).*,\1,p')
GITREV=$(shell echo $(VER) | sed -rne 's,[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\.([0-f]+),\1,p')
%:
dh $@ --with python2
override_dh_auto_configure:
dh_auto_configure -- -DLIB_SUFFIX="/$(DEB_HOST_MULTIARCH)" -DPythonLibs_FIND_VERSION:STRING="2.7" -DPYTHON_EXECUTABLE:STRING="/usr/bin/python"
override_dh_auto_install:
dh_auto_install
rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyc
rm -f debian/gr-osmosdr/usr/lib/python2.7/dist-packages/osmosdr/*pyo
override_dh_makeshlibs:
dh_makeshlibs -V 'libgnuradio-osmosdr0.1.4 (>= 0.1.4-13)'
version-to-get:
echo $(VER) is $(GITREV)
get-orig-source: version-to-get
git clone https://gitea.osmocom.org/sdr/gr-osmosdr
cd gr-osmosdr && git archive --format=tar --prefix=gr-osmosdr-$(VER)/ $(GITREV) | xz > ../gr-osmosdr_$(VER).orig.tar.xz
rm -rf gr-osmosdr

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (native)

3
debian/watch vendored Normal file
View File

@ -0,0 +1,3 @@
version=3
opts="downloadurlmangle=s/refs\/tags/snapshot/,uversionmangle=s|(.*)git|1|" \
http://cgit.osmocom.org/gr-osmosdr/refs/tags /gr-osmosdr/snapshot/gr-osmosdr-(\d.*)\.tar\.xz

View File

@ -159,6 +159,7 @@ documentation: |-
% if sourk == 'source':
* RTL2832U based DVB-T dongles through librtlsdr
* RTL-TCP spectrum server (see librtlsdr project)
* MSi2500 based DVB-T dongles through libmirisdr
* SDRplay RSP devices through SDRplay library
* gnuradio .cfile input through libgnuradio-blocks
* RFSPACE SDR-IQ, SDR-IP, NetSDR (incl. X2 option)
@ -191,6 +192,7 @@ documentation: |-
Lines ending with ... mean it's possible to bind devices together by specifying multiple device arguments separated with a space.
% if sourk == 'source':
miri=0[,buffers=32] ...
rtl=serial_number ...
rtl=0[,rtl_xtal=28.8e6][,tuner_xtal=28.8e6] ...
rtl=1[,buffers=32][,buflen=N*512] ...

View File

@ -175,6 +175,14 @@ if(ENABLE_UHD)
add_subdirectory(uhd)
endif(ENABLE_UHD)
########################################################################
# Setup MiriSDR component
########################################################################
GR_REGISTER_COMPONENT("Osmocom MiriSDR" ENABLE_MIRI LIBMIRISDR_FOUND)
if(ENABLE_MIRI)
add_subdirectory(miri)
endif(ENABLE_MIRI)
########################################################################
# Setup SDRplay component
########################################################################

View File

@ -112,6 +112,15 @@ bladerf_source_c::bladerf_source_c(const std::string &args) :
/* RX Mux */
set_rx_mux_mode(dict.count("rxmux") ? dict["rxmux"] : "baseband");
/* Ref in frequency */
if (dict.count("refin_freq")) {
status = bladerf_set_pll_refclk(_dev.get(), boost::lexical_cast< uint64_t >(dict["refin_freq"]));
if (status != 0) {
BLADERF_WARNING("Problem while setting refin_freq: " <<
bladerf_strerror(status));
}
}
/* AGC mode */
if (dict.count("agc_mode")) {
set_agc_mode(dict["agc_mode"]);

View File

@ -9,6 +9,7 @@
#cmakedefine ENABLE_RTL
#cmakedefine ENABLE_RTL_TCP
#cmakedefine ENABLE_UHD
#cmakedefine ENABLE_MIRI
#cmakedefine ENABLE_SDRPLAY
#cmakedefine ENABLE_HACKRF
#cmakedefine ENABLE_BLADERF

View File

@ -49,6 +49,10 @@
#include <uhd_source_c.h>
#endif
#ifdef ENABLE_MIRI
#include <miri_source_c.h>
#endif
#ifdef ENABLE_SDRPLAY
#include <sdrplay_source_c.h>
#endif
@ -153,6 +157,10 @@ devices_t device::find(const device_t &hint)
for (std::string dev : uhd_source_c::get_devices())
devices.push_back( device_t(dev) );
#endif
#ifdef ENABLE_MIRI
for (std::string dev : miri_source_c::get_devices())
devices.push_back( device_t(dev) );
#endif
#ifdef ENABLE_SDRPLAY
for (std::string dev : sdrplay_source_c::get_devices())
devices.push_back( device_t(dev) );

View File

@ -6,13 +6,11 @@
#include <arg_helpers.h>
using namespace FreeSRP;
using namespace std;
using namespace boost::assign;
std::shared_ptr<::FreeSRP::FreeSRP> freesrp_common::_srp;
freesrp_common::freesrp_common(const string &args)
freesrp_common::freesrp_common(const std::string &args)
{
dict_t dict = params_to_dict(args);
@ -20,7 +18,7 @@ freesrp_common::freesrp_common(const string &args)
{
try
{
string serial = "";
std::string serial = "";
if(dict.count("freesrp"))
{
@ -29,22 +27,22 @@ freesrp_common::freesrp_common(const string &args)
if(dict.count("fx3"))
{
if(Util::find_fx3())
if(FreeSRP::Util::find_fx3())
{
// Upload firmware to FX3
string firmware_path = string(getenv("HOME")) + "/.freesrp/fx3.img";
std::string firmware_path = std::string(getenv("HOME")) + "/.freesrp/fx3.img";
if(dict["fx3"].length() > 0)
{
firmware_path = dict["fx3"];
}
Util::find_fx3(true, firmware_path);
cout << "FX3 programmed with '" << firmware_path << "'" << endl;
FreeSRP::Util::find_fx3(true, firmware_path);
std::cout << "FX3 programmed with '" << firmware_path << "'" << std::endl;
// Give FX3 time to re-enumerate
this_thread::sleep_for(chrono::milliseconds(600));
std::this_thread::sleep_for(std::chrono::milliseconds(600));
}
else
{
cout << "No FX3 in bootloader mode found" << endl;
std::cout << "No FX3 in bootloader mode found" << std::endl;
}
}
@ -52,45 +50,45 @@ freesrp_common::freesrp_common(const string &args)
if(dict.count("fpga") || !_srp->fpga_loaded())
{
string bitstream_path = string(getenv("HOME")) + "/.freesrp/fpga.bin";
std::string bitstream_path = std::string(getenv("HOME")) + "/.freesrp/fpga.bin";
if(dict["fpga"].length() > 0)
{
bitstream_path = dict["fpga"];
}
fpga_status stat = _srp->load_fpga(bitstream_path);
FreeSRP::fpga_status stat = _srp->load_fpga(bitstream_path);
switch(stat)
{
case FPGA_CONFIG_ERROR:
throw runtime_error("Could not load FPGA configuration!");
case FPGA_CONFIG_SKIPPED:
cout << "FPGA already configured. Restart the FreeSRP to load a new bitstream." << endl;
case FreeSRP::FPGA_CONFIG_ERROR:
throw std::runtime_error("Could not load FPGA configuration!");
case FreeSRP::FPGA_CONFIG_SKIPPED:
std::cout << "FPGA already configured. Restart the FreeSRP to load a new bitstream." << std::endl;
break;
case FPGA_CONFIG_DONE:
cout << "FPGA configured with '" << bitstream_path << "'" << endl;
case FreeSRP::FPGA_CONFIG_DONE:
std::cout << "FPGA configured with '" << bitstream_path << "'" << std::endl;
break;
}
}
cout << "Connected to FreeSRP" << endl;
std::cout << "Connected to FreeSRP" << std::endl;
if(dict.count("loopback"))
{
response res = _srp->send_cmd({SET_LOOPBACK_EN, 1});
if(res.error == CMD_OK)
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_LOOPBACK_EN, 1});
if(res.error == FreeSRP::CMD_OK)
{
cout << "AD9364 in loopback mode" << endl;
std::cout << "AD9364 in loopback mode" << std::endl;
}
else
{
throw runtime_error("Could not put AD9364 into loopback mode!");
throw std::runtime_error("Could not put AD9364 into loopback mode!");
}
}
else
{
response res = _srp->send_cmd({SET_LOOPBACK_EN, 0});
if(res.error != CMD_OK)
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_LOOPBACK_EN, 0});
if(res.error != FreeSRP::CMD_OK)
{
throw runtime_error("Error disabling AD9364 loopback mode!");
throw std::runtime_error("Error disabling AD9364 loopback mode!");
}
}
@ -103,28 +101,28 @@ freesrp_common::freesrp_common(const string &args)
_ignore_overflow = false;
}
}
catch(const runtime_error& e)
catch(const std::runtime_error& e)
{
cerr << "FreeSRP Error: " << e.what() << endl;
throw runtime_error(e.what());
std::cerr << "FreeSRP Error: " << e.what() << std::endl;
throw std::runtime_error(e.what());
}
}
}
vector<string> freesrp_common::get_devices()
std::vector<std::string> freesrp_common::get_devices()
{
vector<string> devices;
std::vector<std::string> devices;
vector<string> serial_numbers = ::FreeSRP::FreeSRP::list_connected();
std::vector<std::string> serial_numbers = ::FreeSRP::FreeSRP::list_connected();
int index = 0;
for(string &serial : serial_numbers)
for(std::string &serial : serial_numbers)
{
index++;
string str;
str = "freesrp=" + serial + ",label='FreeSRP " + to_string(index) + "'";
std::string str;
str = "freesrp=" + serial + ",label='FreeSRP " + std::to_string(index) + "'";
devices.push_back(str);
}

View File

@ -1,9 +1,6 @@
#include "freesrp_sink_c.h"
using namespace FreeSRP;
using namespace std;
freesrp_sink_c_sptr make_freesrp_sink_c (const string &args)
freesrp_sink_c_sptr make_freesrp_sink_c (const std::string &args)
{
return gnuradio::get_initial_sptr(new freesrp_sink_c (args));
}
@ -22,21 +19,21 @@ static const int MAX_IN = 1; // maximum number of input streams
static const int MIN_OUT = 0; // minimum number of output streams
static const int MAX_OUT = 0; // maximum number of output streams
freesrp_sink_c::freesrp_sink_c (const string & args) : gr::sync_block("freesrp_sink_c",
freesrp_sink_c::freesrp_sink_c (const std::string & args) : gr::sync_block("freesrp_sink_c",
gr::io_signature::make (MIN_IN, MAX_IN, sizeof (gr_complex)),
gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
freesrp_common(args)
{
if(_srp == nullptr)
{
throw runtime_error("FreeSRP not initialized!");
throw std::runtime_error("FreeSRP not initialized!");
}
}
bool freesrp_sink_c::start()
{
response res = _srp->send_cmd({SET_DATAPATH_EN, 1});
if(res.error != CMD_OK)
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 1});
if(res.error != FreeSRP::CMD_OK)
{
return false;
}
@ -46,16 +43,16 @@ bool freesrp_sink_c::start()
bool freesrp_sink_c::stop()
{
_srp->send_cmd({SET_DATAPATH_EN, 0});
_srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 0});
_srp->stop_tx();
return true;
}
void freesrp_sink_c::freesrp_tx_callback(vector<sample>& samples)
void freesrp_sink_c::freesrp_tx_callback(std::vector<FreeSRP::sample>& samples)
{
unique_lock<std::mutex> lk(_buf_mut);
std::unique_lock<std::mutex> lk(_buf_mut);
for(sample &s : samples)
for(FreeSRP::sample &s : samples)
{
if(!_buf_queue.try_dequeue(s))
{
@ -75,7 +72,7 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
{
const gr_complex *in = (const gr_complex *) input_items[0];
unique_lock<std::mutex> lk(_buf_mut);
std::unique_lock<std::mutex> lk(_buf_mut);
// Wait until enough space is available
while(_buf_available_space < (unsigned int) noutput_items)
@ -85,13 +82,13 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
for(int i = 0; i < noutput_items; ++i)
{
sample s;
FreeSRP::sample s;
s.i = (int16_t) (real(in[i]) * 2047.0f);
s.q = (int16_t) (imag(in[i]) * 2047.0f);
if(!_buf_queue.try_enqueue(s))
{
throw runtime_error("Failed to add sample to buffer. This should never happen. Available space reported to be " + to_string(_buf_available_space) + " samples, noutput_items=" + to_string(noutput_items) + ", i=" + to_string(i));
throw std::runtime_error("Failed to add sample to buffer. This should never happen. Available space reported to be " + std::to_string(_buf_available_space) + " samples, noutput_items=" + std::to_string(noutput_items) + ", i=" + std::to_string(i));
}
else
{
@ -104,11 +101,11 @@ int freesrp_sink_c::work(int noutput_items, gr_vector_const_void_star& input_ite
double freesrp_sink_c::set_sample_rate( double rate )
{
command cmd = _srp->make_command(SET_TX_SAMP_FREQ, rate);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_SAMP_FREQ, rate);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set TX sample rate, error: " << r.error << endl;
std::cerr << "Could not set TX sample rate, error: " << r.error << std::endl;
return 0;
}
else
@ -119,10 +116,10 @@ double freesrp_sink_c::set_sample_rate( double rate )
double freesrp_sink_c::get_sample_rate( void )
{
response r = _srp->send_cmd({GET_TX_SAMP_FREQ, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_SAMP_FREQ, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get TX sample rate, error: " << r.error << endl;
std::cerr << "Could not get TX sample rate, error: " << r.error << std::endl;
return 0;
}
else
@ -133,11 +130,11 @@ double freesrp_sink_c::get_sample_rate( void )
double freesrp_sink_c::set_center_freq( double freq, size_t chan )
{
command cmd = _srp->make_command(SET_TX_LO_FREQ, freq);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_LO_FREQ, freq);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set TX LO frequency, error: " << r.error << endl;
std::cerr << "Could not set TX LO frequency, error: " << r.error << std::endl;
return 0;
}
else
@ -148,10 +145,10 @@ double freesrp_sink_c::set_center_freq( double freq, size_t chan )
double freesrp_sink_c::get_center_freq( size_t chan )
{
response r = _srp->send_cmd({GET_TX_LO_FREQ, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_LO_FREQ, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get TX LO frequency, error: " << r.error << endl;
std::cerr << "Could not get TX LO frequency, error: " << r.error << std::endl;
return 0;
}
else
@ -160,9 +157,9 @@ double freesrp_sink_c::get_center_freq( size_t chan )
}
}
vector<string> freesrp_sink_c::get_gain_names( size_t chan )
std::vector<std::string> freesrp_sink_c::get_gain_names( size_t chan )
{
vector<string> names;
std::vector<std::string> names;
names.push_back("TX_RF");
@ -178,7 +175,7 @@ osmosdr::gain_range_t freesrp_sink_c::get_gain_range(size_t chan)
return gain_ranges;
}
osmosdr::gain_range_t freesrp_sink_c::get_gain_range(const string& name, size_t chan)
osmosdr::gain_range_t freesrp_sink_c::get_gain_range(const std::string& name, size_t chan)
{
return get_gain_range(chan);
}
@ -189,11 +186,11 @@ double freesrp_sink_c::set_gain(double gain, size_t chan)
double atten = 89.75 - gain;
command cmd = _srp->make_command(SET_TX_ATTENUATION, atten * 1000);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_ATTENUATION, atten * 1000);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set TX attenuation, error: " << r.error << endl;
std::cerr << "Could not set TX attenuation, error: " << r.error << std::endl;
return 0;
}
else
@ -202,17 +199,17 @@ double freesrp_sink_c::set_gain(double gain, size_t chan)
}
}
double freesrp_sink_c::set_gain(double gain, const string& name, size_t chan)
double freesrp_sink_c::set_gain(double gain, const std::string& name, size_t chan)
{
return set_gain(gain, chan);
}
double freesrp_sink_c::get_gain(size_t chan)
{
response r = _srp->send_cmd({GET_TX_ATTENUATION, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_ATTENUATION, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get TX RF attenuation, error: " << r.error << endl;
std::cerr << "Could not get TX RF attenuation, error: " << r.error << std::endl;
return 0;
}
else
@ -221,7 +218,7 @@ double freesrp_sink_c::get_gain(size_t chan)
}
}
double freesrp_sink_c::get_gain(const string& name, size_t chan)
double freesrp_sink_c::get_gain(const std::string& name, size_t chan)
{
return get_gain(chan);
}
@ -231,32 +228,32 @@ double freesrp_sink_c::set_bb_gain(double gain, size_t chan)
return set_gain(gain, chan);
}
vector<string> freesrp_sink_c::get_antennas(size_t chan)
std::vector<std::string> freesrp_sink_c::get_antennas(size_t chan)
{
vector<string> antennas;
std::vector<std::string> antennas;
antennas.push_back(get_antenna(chan));
return antennas;
}
string freesrp_sink_c::set_antenna(const string& antenna, size_t chan)
std::string freesrp_sink_c::set_antenna(const std::string& antenna, size_t chan)
{
return get_antenna(chan);
}
string freesrp_sink_c::get_antenna(size_t chan)
std::string freesrp_sink_c::get_antenna(size_t chan)
{
return "TX";
}
double freesrp_sink_c::set_bandwidth(double bandwidth, size_t chan)
{
command cmd = _srp->make_command(SET_TX_RF_BANDWIDTH, bandwidth);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_TX_RF_BANDWIDTH, bandwidth);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set TX RF bandwidth, error: " << r.error << endl;
std::cerr << "Could not set TX RF bandwidth, error: " << r.error << std::endl;
return 0;
}
else
@ -267,10 +264,10 @@ double freesrp_sink_c::set_bandwidth(double bandwidth, size_t chan)
double freesrp_sink_c::get_bandwidth(size_t chan)
{
response r = _srp->send_cmd({GET_TX_RF_BANDWIDTH, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_TX_RF_BANDWIDTH, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get TX RF bandwidth, error: " << r.error << endl;
std::cerr << "Could not get TX RF bandwidth, error: " << r.error << std::endl;
return 0;
}
else

View File

@ -1,9 +1,6 @@
#include "freesrp_source_c.h"
using namespace FreeSRP;
using namespace std;
freesrp_source_c_sptr make_freesrp_source_c (const string &args)
freesrp_source_c_sptr make_freesrp_source_c (const std::string &args)
{
return gnuradio::get_initial_sptr(new freesrp_source_c (args));
}
@ -22,21 +19,21 @@ static const int MAX_IN = 0; // maximum number of input streams
static const int MIN_OUT = 1; // minimum number of output streams
static const int MAX_OUT = 1; // maximum number of output streams
freesrp_source_c::freesrp_source_c (const string & args) : gr::sync_block ("freesrp_source_c",
freesrp_source_c::freesrp_source_c (const std::string & args) : gr::sync_block ("freesrp_source_c",
gr::io_signature::make (MIN_IN, MAX_IN, sizeof (gr_complex)),
gr::io_signature::make (MIN_OUT, MAX_OUT, sizeof (gr_complex))),
freesrp_common(args)
{
if(_srp == nullptr)
{
throw runtime_error("FreeSRP not initialized!");
throw std::runtime_error("FreeSRP not initialized!");
}
}
bool freesrp_source_c::start()
{
response res = _srp->send_cmd({SET_DATAPATH_EN, 1});
if(res.error != CMD_OK)
FreeSRP::response res = _srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 1});
if(res.error != FreeSRP::CMD_OK)
{
return false;
}
@ -49,7 +46,7 @@ bool freesrp_source_c::start()
bool freesrp_source_c::stop()
{
_srp->send_cmd({SET_DATAPATH_EN, 0});
_srp->send_cmd({FreeSRP::SET_DATAPATH_EN, 0});
_srp->stop_rx();
_running = false;
@ -57,17 +54,17 @@ bool freesrp_source_c::stop()
return true;
}
void freesrp_source_c::freesrp_rx_callback(const vector<sample> &samples)
void freesrp_source_c::freesrp_rx_callback(const std::vector<FreeSRP::sample> &samples)
{
unique_lock<std::mutex> lk(_buf_mut);
std::unique_lock<std::mutex> lk(_buf_mut);
for(const sample &s : samples)
for(const FreeSRP::sample &s : samples)
{
if(!_buf_queue.try_enqueue(s))
{
if(!_ignore_overflow)
{
throw runtime_error("RX buffer overflow");
throw std::runtime_error("RX buffer overflow");
}
}
else
@ -83,7 +80,7 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
{
gr_complex *out = static_cast<gr_complex *>(output_items[0]);
unique_lock<std::mutex> lk(_buf_mut);
std::unique_lock<std::mutex> lk(_buf_mut);
if(!_running)
{
@ -98,11 +95,11 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
for(int i = 0; i < noutput_items; ++i)
{
sample s;
FreeSRP::sample s;
if(!_buf_queue.try_dequeue(s))
{
// This should not be happening
throw runtime_error("Failed to get sample from buffer. This should never happen. Number of available samples reported to be " + to_string(_buf_num_samples) + ", noutput_items=" + to_string(noutput_items) + ", i=" + to_string(i));
throw std::runtime_error("Failed to get sample from buffer. This should never happen. Number of available samples reported to be " + std::to_string(_buf_num_samples) + ", noutput_items=" + std::to_string(noutput_items) + ", i=" + std::to_string(i));
}
else
{
@ -117,11 +114,11 @@ int freesrp_source_c::work(int noutput_items, gr_vector_const_void_star& input_i
double freesrp_source_c::set_sample_rate( double rate )
{
command cmd = _srp->make_command(SET_RX_SAMP_FREQ, rate);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_SAMP_FREQ, rate);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set RX sample rate, error: " << r.error << endl;
std::cerr << "Could not set RX sample rate, error: " << r.error << std::endl;
return 0;
}
else
@ -132,10 +129,10 @@ double freesrp_source_c::set_sample_rate( double rate )
double freesrp_source_c::get_sample_rate( void )
{
response r = _srp->send_cmd({GET_RX_SAMP_FREQ, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_SAMP_FREQ, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get RX sample rate, error: " << r.error << endl;
std::cerr << "Could not get RX sample rate, error: " << r.error << std::endl;
return 0;
}
else
@ -146,11 +143,11 @@ double freesrp_source_c::get_sample_rate( void )
double freesrp_source_c::set_center_freq( double freq, size_t chan )
{
command cmd = _srp->make_command(SET_RX_LO_FREQ, freq);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_LO_FREQ, freq);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set RX LO frequency, error: " << r.error << endl;
std::cerr << "Could not set RX LO frequency, error: " << r.error << std::endl;
return 0;
}
else
@ -161,10 +158,10 @@ double freesrp_source_c::set_center_freq( double freq, size_t chan )
double freesrp_source_c::get_center_freq( size_t chan )
{
response r = _srp->send_cmd({GET_RX_LO_FREQ, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_LO_FREQ, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get RX LO frequency, error: " << r.error << endl;
std::cerr << "Could not get RX LO frequency, error: " << r.error << std::endl;
return 0;
}
else
@ -173,9 +170,9 @@ double freesrp_source_c::get_center_freq( size_t chan )
}
}
vector<string> freesrp_source_c::get_gain_names( size_t chan )
std::vector<std::string> freesrp_source_c::get_gain_names( size_t chan )
{
vector<string> names;
std::vector<std::string> names;
names.push_back("RF");
@ -193,41 +190,41 @@ osmosdr::gain_range_t freesrp_source_c::get_gain_range(size_t chan)
bool freesrp_source_c::set_gain_mode( bool automatic, size_t chan )
{
uint8_t gc_mode = RF_GAIN_SLOWATTACK_AGC;
uint8_t gc_mode = FreeSRP::RF_GAIN_SLOWATTACK_AGC;
if(!automatic)
{
gc_mode = RF_GAIN_MGC;
gc_mode = FreeSRP::RF_GAIN_MGC;
}
command cmd = _srp->make_command(SET_RX_GC_MODE, gc_mode);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_GC_MODE, gc_mode);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set RX RF gain control mode, error: " << r.error << endl;
std::cerr << "Could not set RX RF gain control mode, error: " << r.error << std::endl;
return false;
}
else
{
return r.param != RF_GAIN_MGC;
return r.param != FreeSRP::RF_GAIN_MGC;
}
}
bool freesrp_source_c::get_gain_mode( size_t chan )
{
response r = _srp->send_cmd({GET_RX_GC_MODE, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_GC_MODE, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get RX RF gain control mode, error: " << r.error << endl;
std::cerr << "Could not get RX RF gain control mode, error: " << r.error << std::endl;
return false;
}
else
{
return r.param != RF_GAIN_MGC;
return r.param != FreeSRP::RF_GAIN_MGC;
}
}
osmosdr::gain_range_t freesrp_source_c::get_gain_range(const string& name, size_t chan)
osmosdr::gain_range_t freesrp_source_c::get_gain_range(const std::string& name, size_t chan)
{
return get_gain_range(chan);
}
@ -236,11 +233,11 @@ double freesrp_source_c::set_gain(double gain, size_t chan)
{
gain = get_gain_range().clip(gain);
command cmd = _srp->make_command(SET_RX_RF_GAIN, gain);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_RF_GAIN, gain);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set RX RF gain, error: " << r.error << endl;
std::cerr << "Could not set RX RF gain, error: " << r.error << std::endl;
return 0;
}
else
@ -249,7 +246,7 @@ double freesrp_source_c::set_gain(double gain, size_t chan)
}
}
double freesrp_source_c::set_gain(double gain, const string& name, size_t chan)
double freesrp_source_c::set_gain(double gain, const std::string& name, size_t chan)
{
if(name == "RF")
{
@ -263,10 +260,10 @@ double freesrp_source_c::set_gain(double gain, const string& name, size_t chan)
double freesrp_source_c::get_gain(size_t chan)
{
response r = _srp->send_cmd({GET_RX_RF_GAIN, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_RF_GAIN, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get RX RF gain, error: " << r.error << endl;
std::cerr << "Could not get RX RF gain, error: " << r.error << std::endl;
return 0;
}
else
@ -275,7 +272,7 @@ double freesrp_source_c::get_gain(size_t chan)
}
}
double freesrp_source_c::get_gain(const string& name, size_t chan)
double freesrp_source_c::get_gain(const std::string& name, size_t chan)
{
if(name == "RF")
{
@ -292,32 +289,32 @@ double freesrp_source_c::set_bb_gain(double gain, size_t chan)
return set_gain(gain, chan);
}
vector<string> freesrp_source_c::get_antennas(size_t chan)
std::vector<std::string> freesrp_source_c::get_antennas(size_t chan)
{
vector<string> antennas;
std::vector<std::string> antennas;
antennas.push_back(get_antenna(chan));
return antennas;
}
string freesrp_source_c::set_antenna(const string& antenna, size_t chan)
std::string freesrp_source_c::set_antenna(const std::string& antenna, size_t chan)
{
return get_antenna(chan);
}
string freesrp_source_c::get_antenna(size_t chan)
std::string freesrp_source_c::get_antenna(size_t chan)
{
return "RX";
}
double freesrp_source_c::set_bandwidth(double bandwidth, size_t chan)
{
command cmd = _srp->make_command(SET_RX_RF_BANDWIDTH, bandwidth);
response r = _srp->send_cmd(cmd);
if(r.error != CMD_OK)
FreeSRP::command cmd = _srp->make_command(FreeSRP::SET_RX_RF_BANDWIDTH, bandwidth);
FreeSRP::response r = _srp->send_cmd(cmd);
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not set RX RF bandwidth, error: " << r.error << endl;
std::cerr << "Could not set RX RF bandwidth, error: " << r.error << std::endl;
return 0;
}
else
@ -328,10 +325,10 @@ double freesrp_source_c::set_bandwidth(double bandwidth, size_t chan)
double freesrp_source_c::get_bandwidth(size_t chan)
{
response r = _srp->send_cmd({GET_RX_RF_BANDWIDTH, 0});
if(r.error != CMD_OK)
FreeSRP::response r = _srp->send_cmd({FreeSRP::GET_RX_RF_BANDWIDTH, 0});
if(r.error != FreeSRP::CMD_OK)
{
cerr << "Could not get RX RF bandwidth, error: " << r.error << endl;
std::cerr << "Could not get RX RF bandwidth, error: " << r.error << std::endl;
return 0;
}
else

View File

@ -299,7 +299,7 @@ void convert_avx(const float* inbuf, int8_t* outbuf,const unsigned int count)
#elif USE_SSE2
void convert_sse2(const float* inbuf, int8_t* outbuf,const unsigned int count)
{
const register __m128 mulme = _mm_set_ps( 127.0f, 127.0f, 127.0f, 127.0f );
const __m128 mulme = _mm_set_ps( 127.0f, 127.0f, 127.0f, 127.0f );
__m128 itmp1,itmp2,itmp3,itmp4;
__m128i otmp1,otmp2,otmp3,otmp4;

36
lib/miri/CMakeLists.txt Normal file
View File

@ -0,0 +1,36 @@
# Copyright 2012 Free Software Foundation, Inc.
#
# This file is part of gr-osmosdr
#
# gr-osmosdr is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# gr-osmosdr is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with gr-osmosdr; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
########################################################################
# This file included, use CMake directory variables
########################################################################
target_include_directories(gnuradio-osmosdr PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${LIBMIRISDR_INCLUDE_DIRS}
)
APPEND_LIB_LIST(
${LIBMIRISDR_LIBRARIES}
)
list(APPEND gr_osmosdr_srcs
${CMAKE_CURRENT_SOURCE_DIR}/miri_source_c.cc
)
set(gr_osmosdr_srcs ${gr_osmosdr_srcs} PARENT_SCOPE)

451
lib/miri/miri_source_c.cc Normal file
View File

@ -0,0 +1,451 @@
/* -*- c++ -*- */
/*
* Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
* Copyright 2012 Steve Markgraf <steve@steve-m.de>
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
/*
* config.h is generated by configure. It contains the results
* of probing for features, options etc. It should be the first
* file included in your .cc file.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "miri_source_c.h"
#include <gnuradio/io_signature.h>
#include <boost/assign.hpp>
#include <boost/format.hpp>
#include <stdexcept>
#include <iostream>
#include <stdio.h>
#include <mirisdr.h>
#include "arg_helpers.h"
using namespace boost::assign;
#define BUF_SIZE 2304 * 8 * 2
#define BUF_NUM 15
#define BUF_SKIP 1 // buffers to skip due to garbage
#define BYTES_PER_SAMPLE 4 // mirisdr device delivers 16 bit signed IQ data
// containing 12 bits of information
/*
* Create a new instance of miri_source_c and return
* a boost shared_ptr. This is effectively the public constructor.
*/
miri_source_c_sptr
make_miri_source_c (const std::string &args)
{
return gnuradio::get_initial_sptr(new miri_source_c (args));
}
/*
* Specify constraints on number of input and output streams.
* This info is used to construct the input and output signatures
* (2nd & 3rd args to gr::block's constructor). The input and
* output signatures are used by the runtime system to
* check that a valid number and type of inputs and outputs
* are connected to this block. In this case, we accept
* only 0 input and 1 output.
*/
static const int MIN_IN = 0; // mininum number of input streams
static const int MAX_IN = 0; // maximum number of input streams
static const int MIN_OUT = 1; // minimum number of output streams
static const int MAX_OUT = 1; // maximum number of output streams
/*
* The private constructor
*/
miri_source_c::miri_source_c (const std::string &args)
: gr::sync_block ("miri_source_c",
gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)),
gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))),
_running(true),
_auto_gain(false),
_skipped(0)
{
int ret;
unsigned int dev_index = 0;
dict_t dict = params_to_dict(args);
if (dict.count("miri"))
dev_index = boost::lexical_cast< unsigned int >( dict["miri"] );
_buf_num = _buf_head = _buf_used = _buf_offset = 0;
_samp_avail = BUF_SIZE / BYTES_PER_SAMPLE;
if (dict.count("buffers"))
_buf_num = boost::lexical_cast< unsigned int >( dict["buffers"] );
if (0 == _buf_num)
_buf_num = BUF_NUM;
if ( BUF_NUM != _buf_num ) {
std::cerr << "Using " << _buf_num << " buffers of size " << BUF_SIZE << "."
<< std::endl;
}
if ( dev_index >= mirisdr_get_device_count() )
throw std::runtime_error("Wrong mirisdr device index given.");
std::cerr << "Using device #" << dev_index << ": "
<< mirisdr_get_device_name(dev_index)
<< std::endl;
_dev = NULL;
ret = mirisdr_open( &_dev, dev_index );
if (ret < 0)
throw std::runtime_error("Failed to open mirisdr device.");
#if 0
ret = mirisdr_set_sample_rate( _dev, 500000 );
if (ret < 0)
throw std::runtime_error("Failed to set default samplerate.");
ret = mirisdr_set_tuner_gain_mode(_dev, int(!_auto_gain));
if (ret < 0)
throw std::runtime_error("Failed to enable manual gain mode.");
#endif
ret = mirisdr_reset_buffer( _dev );
if (ret < 0)
throw std::runtime_error("Failed to reset usb buffers.");
_buf = (unsigned short **) malloc(_buf_num * sizeof(unsigned short *));
_buf_lens = (unsigned int *) malloc(_buf_num * sizeof(unsigned int));
if (_buf && _buf_lens) {
for(unsigned int i = 0; i < _buf_num; ++i)
_buf[i] = (unsigned short *) malloc(BUF_SIZE);
}
_thread = gr::thread::thread(_mirisdr_wait, this);
}
/*
* Our virtual destructor.
*/
miri_source_c::~miri_source_c ()
{
if (_dev) {
_running = false;
mirisdr_cancel_async( _dev );
_thread.join();
mirisdr_close( _dev );
_dev = NULL;
}
if (_buf) {
for(unsigned int i = 0; i < _buf_num; ++i) {
free(_buf[i]);
}
free(_buf);
_buf = NULL;
free(_buf_lens);
_buf_lens = NULL;
}
}
void miri_source_c::_mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx)
{
miri_source_c *obj = (miri_source_c *)ctx;
obj->mirisdr_callback(buf, len);
}
void miri_source_c::mirisdr_callback(unsigned char *buf, uint32_t len)
{
if (_skipped < BUF_SKIP) {
_skipped++;
return;
}
{
std::lock_guard<std::mutex> lock( _buf_mutex );
if (len > BUF_SIZE)
throw std::runtime_error("Buffer too small.");
int buf_tail = (_buf_head + _buf_used) % _buf_num;
memcpy(_buf[buf_tail], buf, len);
_buf_lens[buf_tail] = len;
if (_buf_used == _buf_num) {
std::cerr << "O" << std::flush;
_buf_head = (_buf_head + 1) % _buf_num;
} else {
_buf_used++;
}
}
_buf_cond.notify_one();
}
void miri_source_c::_mirisdr_wait(miri_source_c *obj)
{
obj->mirisdr_wait();
}
void miri_source_c::mirisdr_wait()
{
int ret = mirisdr_read_async( _dev, _mirisdr_callback, (void *)this, _buf_num, BUF_SIZE );
_running = false;
if ( ret != 0 )
std::cerr << "mirisdr_read_async returned with " << ret << std::endl;
_buf_cond.notify_one();
}
int miri_source_c::work( int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items )
{
gr_complex *out = (gr_complex *)output_items[0];
{
std::unique_lock<std::mutex> lock( _buf_mutex );
while (_buf_used < 3 && _running) // collect at least 3 buffers
_buf_cond.wait( lock );
}
if (!_running)
return WORK_DONE;
short *buf = (short *)_buf[_buf_head] + _buf_offset;
if (noutput_items <= _samp_avail) {
for (int i = 0; i < noutput_items; i++)
*out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f),
float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) );
_buf_offset += noutput_items * 2;
_samp_avail -= noutput_items;
} else {
for (int i = 0; i < _samp_avail; i++)
*out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f),
float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) );
{
std::lock_guard<std::mutex> lock( _buf_mutex );
_buf_head = (_buf_head + 1) % _buf_num;
_buf_used--;
}
buf = (short *)_buf[_buf_head];
int remaining = noutput_items - _samp_avail;
for (int i = 0; i < remaining; i++)
*out++ = gr_complex( float(*(buf + i * 2 + 0)) * (1.0f/4096.0f),
float(*(buf + i * 2 + 1)) * (1.0f/4096.0f) );
_buf_offset = remaining * 2;
_samp_avail = (_buf_lens[_buf_head] / BYTES_PER_SAMPLE) - remaining;
}
return noutput_items;
}
std::vector<std::string> miri_source_c::get_devices()
{
std::vector<std::string> devices;
for (unsigned int i = 0; i < mirisdr_get_device_count(); i++) {
std::string args = "miri=" + boost::lexical_cast< std::string >( i );
args += ",label='" + std::string(mirisdr_get_device_name( i )) + "'";
devices.push_back( args );
}
return devices;
}
size_t miri_source_c::get_num_channels()
{
return 1;
}
osmosdr::meta_range_t miri_source_c::get_sample_rates()
{
osmosdr::meta_range_t range;
range += osmosdr::range_t( 8000000 ); // known to work
return range;
}
double miri_source_c::set_sample_rate(double rate)
{
if (_dev) {
mirisdr_set_sample_rate( _dev, (uint32_t)rate );
}
return get_sample_rate();
}
double miri_source_c::get_sample_rate()
{
if (_dev)
return (double)mirisdr_get_sample_rate( _dev );
return 0;
}
osmosdr::freq_range_t miri_source_c::get_freq_range( size_t chan )
{
osmosdr::freq_range_t range;
range += osmosdr::range_t( 150e3, 30e6 ); /* LW/MW/SW (150 kHz - 30 MHz) */
range += osmosdr::range_t( 64e6, 108e6 ); /* VHF Band II (64 - 108 MHz) */
range += osmosdr::range_t( 162e6, 240e6 ); /* Band III (162 - 240 MHz) */
range += osmosdr::range_t( 470e6, 960e6 ); /* Band IV/V (470 - 960 MHz) */
range += osmosdr::range_t( 1450e6, 1675e6 ); /* L-Band (1450 - 1675 MHz) */
return range;
}
double miri_source_c::set_center_freq( double freq, size_t chan )
{
if (_dev)
mirisdr_set_center_freq( _dev, (uint32_t)freq );
return get_center_freq( chan );
}
double miri_source_c::get_center_freq( size_t chan )
{
if (_dev)
return (double)mirisdr_get_center_freq( _dev );
return 0;
}
double miri_source_c::set_freq_corr( double ppm, size_t chan )
{
return get_freq_corr( chan );
}
double miri_source_c::get_freq_corr( size_t chan )
{
return 0;
}
std::vector<std::string> miri_source_c::get_gain_names( size_t chan )
{
std::vector< std::string > gains;
gains += "LNA";
return gains;
}
osmosdr::gain_range_t miri_source_c::get_gain_range( size_t chan )
{
osmosdr::gain_range_t range;
if (_dev) {
int count = mirisdr_get_tuner_gains(_dev, NULL);
if (count > 0) {
int* gains = new int[ count ];
count = mirisdr_get_tuner_gains(_dev, gains);
for (int i = 0; i < count; i++)
range += osmosdr::range_t( gains[i] / 10.0 );
delete[] gains;
}
}
return range;
}
osmosdr::gain_range_t miri_source_c::get_gain_range( const std::string & name, size_t chan )
{
return get_gain_range( chan );
}
bool miri_source_c::set_gain_mode( bool automatic, size_t chan )
{
if (_dev) {
if (!mirisdr_set_tuner_gain_mode(_dev, int(!automatic))) {
_auto_gain = automatic;
}
}
return get_gain_mode(chan);
}
bool miri_source_c::get_gain_mode( size_t chan )
{
return _auto_gain;
}
double miri_source_c::set_gain( double gain, size_t chan )
{
osmosdr::gain_range_t rf_gains = miri_source_c::get_gain_range( chan );
if (_dev) {
mirisdr_set_tuner_gain( _dev, int(rf_gains.clip(gain) * 10.0) );
}
return get_gain( chan );
}
double miri_source_c::set_gain( double gain, const std::string & name, size_t chan)
{
return set_gain( gain, chan );
}
double miri_source_c::get_gain( size_t chan )
{
if ( _dev )
return ((double)mirisdr_get_tuner_gain( _dev )) / 10.0;
return 0;
}
double miri_source_c::get_gain( const std::string & name, size_t chan )
{
return get_gain( chan );
}
std::vector< std::string > miri_source_c::get_antennas( size_t chan )
{
std::vector< std::string > antennas;
antennas += get_antenna( chan );
return antennas;
}
std::string miri_source_c::set_antenna( const std::string & antenna, size_t chan )
{
return get_antenna( chan );
}
std::string miri_source_c::get_antenna( size_t chan )
{
return "RX";
}

124
lib/miri/miri_source_c.h Normal file
View File

@ -0,0 +1,124 @@
/* -*- c++ -*- */
/*
* Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef INCLUDED_MIRI_SOURCE_C_H
#define INCLUDED_MIRI_SOURCE_C_H
#include <gnuradio/sync_block.h>
#include <gnuradio/thread/thread.h>
#include <mutex>
#include <condition_variable>
#include "source_iface.h"
class miri_source_c;
typedef struct mirisdr_dev mirisdr_dev_t;
typedef std::shared_ptr<miri_source_c> miri_source_c_sptr;
/*!
* \brief Return a shared_ptr to a new instance of miri_source_c.
*
* To avoid accidental use of raw pointers, miri_source_c's
* constructor is private. make_miri_source_c is the public
* interface for creating new instances.
*/
miri_source_c_sptr make_miri_source_c (const std::string & args = "");
/*!
* \brief Provides a stream of complex samples.
* \ingroup block
*/
class miri_source_c :
public gr::sync_block,
public source_iface
{
private:
// The friend declaration allows make_miri_source_c to
// access the private constructor.
friend miri_source_c_sptr make_miri_source_c (const std::string & args);
/*!
* \brief Provides a stream of complex samples.
*/
miri_source_c (const std::string & args); // private constructor
public:
~miri_source_c (); // public destructor
int work( int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items );
static std::vector< std::string > get_devices();
size_t get_num_channels( void );
osmosdr::meta_range_t get_sample_rates( void );
double set_sample_rate( double rate );
double get_sample_rate( void );
osmosdr::freq_range_t get_freq_range( size_t chan = 0 );
double set_center_freq( double freq, size_t chan = 0 );
double get_center_freq( size_t chan = 0 );
double set_freq_corr( double ppm, size_t chan = 0 );
double get_freq_corr( size_t chan = 0 );
std::vector<std::string> get_gain_names( size_t chan = 0 );
osmosdr::gain_range_t get_gain_range( size_t chan = 0 );
osmosdr::gain_range_t get_gain_range( const std::string & name, size_t chan = 0 );
bool set_gain_mode( bool automatic, size_t chan = 0 );
bool get_gain_mode( size_t chan = 0 );
double set_gain( double gain, size_t chan = 0 );
double set_gain( double gain, const std::string & name, size_t chan = 0 );
double get_gain( size_t chan = 0 );
double get_gain( const std::string & name, size_t chan = 0 );
std::vector< std::string > get_antennas( size_t chan = 0 );
std::string set_antenna( const std::string & antenna, size_t chan = 0 );
std::string get_antenna( size_t chan = 0 );
private:
static void _mirisdr_callback(unsigned char *buf, uint32_t len, void *ctx);
void mirisdr_callback(unsigned char *buf, uint32_t len);
static void _mirisdr_wait(miri_source_c *obj);
void mirisdr_wait();
mirisdr_dev_t *_dev;
gr::thread::thread _thread;
unsigned short **_buf;
unsigned int *_buf_lens;
unsigned int _buf_num;
unsigned int _buf_head;
unsigned int _buf_used;
std::mutex _buf_mutex;
std::condition_variable _buf_cond;
bool _running;
unsigned int _buf_offset;
int _samp_avail;
bool _auto_gain;
unsigned int _skipped;
};
#endif /* INCLUDED_MIRI_SOURCE_C_H */

View File

@ -29,6 +29,12 @@ APPEND_LIB_LIST(
${Gnuradio-blocks_LIBRARIES}
)
if(WIN32)
APPEND_LIB_LIST(
ws2_32
)
endif()
list(APPEND gr_osmosdr_srcs
${CMAKE_CURRENT_SOURCE_DIR}/redpitaya_source_c.cc
${CMAKE_CURRENT_SOURCE_DIR}/redpitaya_sink_c.cc

View File

@ -26,7 +26,6 @@
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#include <windows.h>
#define INVSOC INVALID_SOCKET
#else

View File

@ -122,6 +122,9 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
if ( dict.count("cloudiq") )
dict["rfspace"] = dict["cloudiq"];
if ( dict.count("cloudsdr") )
dict["rfspace"] = dict["cloudsdr"];
if ( dict.count("rfspace") )
{
std::string value = dict["rfspace"];
@ -146,6 +149,9 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
if ( first.count("cloudiq") )
value = first["cloudiq"];
if ( first.count("cloudsdr") )
value = first["cloudsdr"];
dict["rfspace"] = value;
dict["label"] = first["label"];
}
@ -291,7 +297,7 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
memset(&host_sa, 0, sizeof(host_sa));
host_sa.sin_family = AF_INET;
host_sa.sin_addr.s_addr = htonl(INADDR_ANY);
host_sa.sin_port = htons(DEFAULT_PORT);
host_sa.sin_port = htons(port); /* host port must match sdr port */
if ( bind(_udp, (struct sockaddr *)&host_sa, sizeof(host_sa)) < 0 )
{
@ -336,6 +342,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
_radio = RFSPACE_NETSDR;
else if ( 0x434C4951 == product_id ) /* CloudIQ Product ID */
_radio = RFSPACE_CLOUDIQ;
else if ( 0x434C5344 == product_id ) /* CloudSDR Product ID */
_radio = RFSPACE_CLOUDSDR;
else
std::cerr << "UNKNOWN ";
}
@ -374,7 +382,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
if ( RFSPACE_NETSDR == _radio ||
RFSPACE_SDR_IP == _radio ||
RFSPACE_CLOUDIQ == _radio)
RFSPACE_CLOUDIQ == _radio ||
RFSPACE_CLOUDSDR == _radio)
{
unsigned char hardver[] = { 0x05, 0x20, 0x04, 0x00, 0x02 };
if ( transaction( hardver, sizeof(hardver), response ) )
@ -382,7 +391,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
}
if ( RFSPACE_NETSDR == _radio ||
RFSPACE_CLOUDIQ == _radio)
RFSPACE_CLOUDIQ == _radio ||
RFSPACE_CLOUDSDR == _radio)
{
unsigned char fpgaver[] = { 0x05, 0x20, 0x04, 0x00, 0x03 };
if ( transaction( fpgaver, sizeof(fpgaver), response ) )
@ -431,7 +441,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
set_bandwidth( 0 ); /* switch to automatic filter selection by default */
}
else if ( RFSPACE_CLOUDIQ == _radio)
else if ( RFSPACE_CLOUDIQ == _radio ||
RFSPACE_CLOUDSDR == _radio)
{
set_sample_rate( 240000 );
set_bandwidth( 0 );
@ -440,7 +451,8 @@ rfspace_source_c::rfspace_source_c (const std::string &args)
/* start TCP keepalive thread */
if ( RFSPACE_NETSDR == _radio ||
RFSPACE_SDR_IP == _radio ||
RFSPACE_CLOUDIQ == _radio )
RFSPACE_CLOUDIQ == _radio ||
RFSPACE_CLOUDSDR == _radio )
{
_run_tcp_keepalive_task = true;
_thread = gr::thread::thread( boost::bind(&rfspace_source_c::tcp_keepalive_task, this) );
@ -1265,6 +1277,21 @@ osmosdr::meta_range_t rfspace_source_c::get_sample_rates()
range += osmosdr::range_t( 1228800 );
range += osmosdr::range_t( 1807058 );
}
else if ( RFSPACE_CLOUDSDR == _radio )
{
/* CloudSDR supports 122.88 MHz / 4*N for N = 15 ... 2560, but lets limit
* ourselves to the ones available in SpectraVue
*/
range += osmosdr::range_t( 48000 ); // 40 kHz
range += osmosdr::range_t( 61440 ); // 50 kHz
range += osmosdr::range_t( 122880 ); // 100 kHz
range += osmosdr::range_t( 245760 ); // 200 kHz
range += osmosdr::range_t( 370120 ); // 300 kHz
range += osmosdr::range_t( 495483 ); // 400 kHz
range += osmosdr::range_t( 614400 ); // 500 kHz
range += osmosdr::range_t( 1228800 ); // 1 MHz
range += osmosdr::range_t( 2048000 ); // 2 MHz (16 bit)
}
return range;
}
@ -1562,7 +1589,8 @@ std::string rfspace_source_c::get_antenna( size_t chan )
double rfspace_source_c::set_bandwidth( double bandwidth, size_t chan )
{
if ( RFSPACE_SDR_IQ == _radio ||
RFSPACE_CLOUDIQ == _radio) /* not supported by SDR-IQ or Cloud-IQ */
RFSPACE_CLOUDIQ == _radio ||
RFSPACE_CLOUDSDR == _radio) /* not supported by SDR-IQ, Cloud-IQ, or CloudSDR */
return 0.0f;
/* SDR-IP 4.2.5 RF Filter Selection */

View File

@ -130,7 +130,8 @@ private: /* members */
RFSPACE_SDR_IQ,
RFSPACE_SDR_IP,
RFSPACE_NETSDR,
RFSPACE_CLOUDIQ
RFSPACE_CLOUDIQ,
RFSPACE_CLOUDSDR
};
radio_type _radio;

View File

@ -455,6 +455,8 @@ double rtl_source_c::get_sample_rate()
osmosdr::freq_range_t rtl_source_c::get_freq_range( size_t chan )
{
osmosdr::freq_range_t range;
char manufact[256];
char product[256];
if (_dev) {
if (_no_tuner) {
@ -464,6 +466,8 @@ osmosdr::freq_range_t rtl_source_c::get_freq_range( size_t chan )
return range;
}
rtlsdr_get_usb_strings( _dev, manufact, product, NULL );
enum rtlsdr_tuner tuner = rtlsdr_get_tuner_type(_dev);
if ( tuner == RTLSDR_TUNER_E4000 ) {
@ -478,6 +482,8 @@ osmosdr::freq_range_t rtl_source_c::get_freq_range( size_t chan )
range += osmosdr::range_t( 438e6, 924e6 );
} else if ( tuner == RTLSDR_TUNER_R820T ) {
range += osmosdr::range_t( 24e6, 1766e6 );
} else if ( tuner == RTLSDR_TUNER_R828D && strcmp(manufact, "RTLSDRBlog") == 0 && strcmp(product, "Blog V4") == 0 ) {
range += osmosdr::range_t( 0e6, 1766e6 );
} else if ( tuner == RTLSDR_TUNER_R828D ) {
range += osmosdr::range_t( 24e6, 1766e6 );
}

View File

@ -29,6 +29,12 @@ APPEND_LIB_LIST(
${Gnuradio-blocks_LIBRARIES}
)
if(WIN32)
APPEND_LIB_LIST(
ws2_32
)
endif()
list(APPEND gr_osmosdr_srcs
${CMAKE_CURRENT_SOURCE_DIR}/rtl_tcp_source_c.cc
)

View File

@ -32,7 +32,6 @@
#if defined(_WIN32)
// if not posix, assume winsock
#pragma comment(lib, "ws2_32.lib")
#define USING_WINSOCK
#include <winsock2.h>
#include <ws2tcpip.h>
@ -89,7 +88,9 @@ static int is_error( int perr )
{
// Compare error to posix error code; return nonzero if match.
#if defined(USING_WINSOCK)
#ifndef ENOPROTOOPT
#define ENOPROTOOPT 109
#endif
// All codes to be checked for must be defined below
int werr = WSAGetLastError();
switch( werr ) {

View File

@ -1,327 +0,0 @@
/* -*- c++ -*- */
/*
* Copyright 2012 Hoernchen <la@tfc-server.de>
* Copyright 2012 Dimitri Stolnikov <horiz0n@gmx.net>
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
//#define HAVE_WINDOWS_H
#include <rtl_tcp_source_f.h>
#include <gnuradio/io_signature.h>
#include <stdexcept>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifndef _WIN32
#include <netinet/in.h>
#else
#include <WinSock2.h>
#endif
/* copied from rtl sdr code */
typedef struct { /* structure size must be multiple of 2 bytes */
char magic[4];
uint32_t tuner_type;
uint32_t tuner_gain_count;
} dongle_info_t;
#define USE_SELECT 1 // non-blocking receive on all platforms
#define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin
#define SRC_VERBOSE 0
#define SNK_VERBOSE 0
static int is_error( int perr )
{
// Compare error to posix error code; return nonzero if match.
#if defined(USING_WINSOCK)
#define ENOPROTOOPT 109
// All codes to be checked for must be defined below
int werr = WSAGetLastError();
switch( werr ) {
case WSAETIMEDOUT:
return( perr == EAGAIN );
case WSAENOPROTOOPT:
return( perr == ENOPROTOOPT );
default:
fprintf(stderr,"rtl_tcp_source_f: unknown error %d WS err %d \n", perr, werr );
throw std::runtime_error("internal error");
}
return 0;
#else
return( perr == errno );
#endif
}
static void report_error( const char *msg1, const char *msg2 )
{
// Deal with errors, both posix and winsock
#if defined(USING_WINSOCK)
int werr = WSAGetLastError();
fprintf(stderr, "%s: winsock error %d\n", msg1, werr );
#else
perror(msg1);
#endif
if( msg2 != NULL )
throw std::runtime_error(msg2);
return;
}
rtl_tcp_source_f::rtl_tcp_source_f(size_t itemsize,
const char *host,
unsigned short port,
int payload_size,
bool eof,
bool wait)
: gr::sync_block ("rtl_tcp_source_f",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, sizeof(float))),
d_itemsize(itemsize),
d_payload_size(payload_size),
d_eof(eof),
d_wait(wait),
d_socket(-1),
d_temp_offset(0)
{
int ret = 0;
#if defined(USING_WINSOCK) // for Windows (with MinGW)
// initialize winsock DLL
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if( iResult != NO_ERROR ) {
report_error( "rtl_tcp_source_f WSAStartup", "can't open socket" );
}
#endif
// Set up the address stucture for the source address and port numbers
// Get the source IP address from the host name
struct addrinfo *ip_src; // store the source IP address to use
struct addrinfo hints;
memset( (void*)&hints, 0, sizeof(hints) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_PASSIVE;
char port_str[12];
sprintf( port_str, "%d", port );
// FIXME leaks if report_error throws below
ret = getaddrinfo( host, port_str, &hints, &ip_src );
if( ret != 0 )
report_error("rtl_tcp_source_f/getaddrinfo",
"can't initialize source socket" );
// FIXME leaks if report_error throws below
d_temp_buff = new unsigned char[d_payload_size]; // allow it to hold up to payload_size bytes
d_LUT= new float[0xff+1];
for(int i=0; i <=(0xff);++i){
d_LUT[i] = (((float)(i&0xff))-127.4f)*(1.0f/128.0f);
}
// create socket
d_socket = socket(ip_src->ai_family, ip_src->ai_socktype,
ip_src->ai_protocol);
if(d_socket == -1) {
report_error("socket open","can't open socket");
}
// Turn on reuse address
int opt_val = 1;
if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) {
report_error("SO_REUSEADDR","can't set socket option SO_REUSEADDR");
}
// Don't wait when shutting down
linger lngr;
lngr.l_onoff = 1;
lngr.l_linger = 0;
if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) {
if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows
report_error("SO_LINGER","can't set socket option SO_LINGER");
}
}
#if USE_RCV_TIMEO
// Set a timeout on the receive function to not block indefinitely
// This value can (and probably should) be changed
// Ignored on Cygwin
#if defined(USING_WINSOCK)
DWORD timeout = 1000; // milliseconds
#else
timeval timeout;
timeout.tv_sec = 1;
timeout.tv_usec = 0;
#endif
if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) {
report_error("SO_RCVTIMEO","can't set socket option SO_RCVTIMEO");
}
#endif // USE_RCV_TIMEO
while(connect(d_socket, ip_src->ai_addr, ip_src->ai_addrlen) != 0);
freeaddrinfo(ip_src);
int flag = 1;
setsockopt(d_socket, IPPROTO_TCP, TCP_NODELAY, (char *)&flag,sizeof(flag));
dongle_info_t dongle_info;
ret = recv(d_socket, (char*)&dongle_info, sizeof(dongle_info), 0);
if (sizeof(dongle_info) != ret)
fprintf(stderr,"failed to read dongle info\n");
d_tuner_type = RTLSDR_TUNER_UNKNOWN;
d_tuner_gain_count = 0;
d_tuner_if_gain_count = 0;
if (memcmp(dongle_info.magic, "RTL0", 4) == 0)
{
d_tuner_type = ntohl(dongle_info.tuner_type);
d_tuner_gain_count = ntohl(dongle_info.tuner_gain_count);
if ( RTLSDR_TUNER_E4000 == d_tuner_type )
d_tuner_if_gain_count = 53;
}
}
rtl_tcp_source_f_sptr make_rtl_tcp_source_f (size_t itemsize,
const char *ipaddr,
unsigned short port,
int payload_size,
bool eof,
bool wait)
{
return gnuradio::get_initial_sptr(new rtl_tcp_source_f (
itemsize,
ipaddr,
port,
payload_size,
eof,
wait));
}
rtl_tcp_source_f::~rtl_tcp_source_f ()
{
delete [] d_temp_buff;
if (d_socket != -1){
shutdown(d_socket, SHUT_RDWR);
#if defined(USING_WINSOCK)
closesocket(d_socket);
#else
::close(d_socket);
#endif
d_socket = -1;
}
#if defined(USING_WINSOCK) // for Windows (with MinGW)
// free winsock resources
WSACleanup();
#endif
}
int rtl_tcp_source_f::work (int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
float *out = (float *) output_items[0];
ssize_t r = 0;
int bytesleft = noutput_items;
int index = 0;
int receivedbytes = 0;
while(bytesleft > 0) {
receivedbytes = recv(d_socket, (char*)&d_temp_buff[index], bytesleft, 0);
if(receivedbytes == -1 && !is_error(EAGAIN)){
fprintf(stderr, "socket error\n");
return -1;
}
bytesleft -= receivedbytes;
index += receivedbytes;
}
r = noutput_items;
for(int i=0; i<r; ++i)
out[i]=d_LUT[*(d_temp_buff+d_temp_offset+i)];
return r;
}
#ifdef _WIN32
#define __attribute__(x)
#pragma pack(push, 1)
#endif
struct command{
unsigned char cmd;
unsigned int param;
}__attribute__((packed));
#ifdef _WIN32
#pragma pack(pop)
#endif
void rtl_tcp_source_f::set_freq(int freq)
{
struct command cmd = { 0x01, htonl(freq) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_sample_rate(int sample_rate)
{
struct command cmd = { 0x02, htonl(sample_rate) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_gain_mode(int manual)
{
struct command cmd = { 0x03, htonl(manual) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_gain(int gain)
{
struct command cmd = { 0x04, htonl(gain) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_freq_corr(int ppm)
{
struct command cmd = { 0x05, htonl(ppm) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_if_gain(int stage, int gain)
{
uint32_t params = stage << 16 | (gain & 0xffff);
struct command cmd = { 0x06, htonl(params) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_agc_mode(int on)
{
struct command cmd = { 0x08, htonl(on) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_direct_sampling(int on)
{
struct command cmd = { 0x09, htonl(on) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}
void rtl_tcp_source_f::set_offset_tuning(int on)
{
struct command cmd = { 0x0a, htonl(on) };
send(d_socket, (const char*)&cmd, sizeof(cmd), 0);
}

View File

@ -1,125 +0,0 @@
/* -*- c++ -*- */
/*
* Copyright 2012 Hoernchen <la@tfc-server.de>
*
* GNU Radio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU Radio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Radio; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
#ifndef RTL_TCP_SOURCE_F_H
#define RTL_TCP_SOURCE_F_H
#include <gnuradio/sync_block.h>
#include <gnuradio/thread/thread.h>
#if defined(_WIN32)
// if not posix, assume winsock
#pragma comment(lib, "ws2_32.lib")
#define USING_WINSOCK
#include <winsock2.h>
#include <ws2tcpip.h>
#define SHUT_RDWR 2
typedef char* optval_t;
#else
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
typedef void* optval_t;
#endif
#ifdef _MSC_VER
#include <cstddef>
typedef ptrdiff_t ssize_t;
#endif //_MSC_VER
/* copied from rtl sdr */
enum rtlsdr_tuner {
RTLSDR_TUNER_UNKNOWN = 0,
RTLSDR_TUNER_E4000,
RTLSDR_TUNER_FC0012,
RTLSDR_TUNER_FC0013,
RTLSDR_TUNER_FC2580,
RTLSDR_TUNER_R820T,
RTLSDR_TUNER_R828D
};
class rtl_tcp_source_f;
typedef std::shared_ptr<rtl_tcp_source_f> rtl_tcp_source_f_sptr;
rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
size_t itemsize,
const char *host,
unsigned short port,
int payload_size,
bool eof = false,
bool wait = false);
class rtl_tcp_source_f : public gr::sync_block
{
private:
size_t d_itemsize;
int d_payload_size; // maximum transmission unit (packet length)
bool d_eof; // zero-length packet is EOF
bool d_wait; // wait if data if not immediately available
int d_socket; // handle to socket
unsigned char *d_temp_buff; // hold buffer between calls
size_t d_temp_offset; // point to temp buffer location offset
float *d_LUT;
unsigned int d_tuner_type;
unsigned int d_tuner_gain_count;
unsigned int d_tuner_if_gain_count;
private:
rtl_tcp_source_f(size_t itemsize, const char *host,
unsigned short port, int payload_size, bool eof, bool wait);
// The friend declaration allows make_source_c to
// access the private constructor.
friend rtl_tcp_source_f_sptr make_rtl_tcp_source_f (
size_t itemsize,
const char *host,
unsigned short port,
int payload_size,
bool eof,
bool wait);
public:
~rtl_tcp_source_f();
enum rtlsdr_tuner get_tuner_type() { return (enum rtlsdr_tuner) d_tuner_type; }
unsigned int get_tuner_gain_count() { return d_tuner_gain_count; }
unsigned int get_tuner_if_gain_count() { return d_tuner_if_gain_count; }
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
void set_freq(int freq);
void set_sample_rate(int sample_rate);
void set_gain_mode(int manual);
void set_gain(int gain);
void set_freq_corr(int ppm);
void set_if_gain(int stage, int gain);
void set_agc_mode(int on);
void set_direct_sampling(int on);
void set_offset_tuning(int on);
};
#endif /* RTL_TCP_SOURCE_F_H */

View File

@ -232,13 +232,13 @@ sink_impl::sink_impl( const std::string &args )
}
#endif
if ( iface != NULL && long(block.get()) != 0 ) {
if (iface != NULL && reinterpret_cast<std::intptr_t>(block.get()) != 0) {
_devs.push_back( iface );
for (size_t i = 0; i < iface->get_num_channels(); i++) {
connect(self(), channel++, block, i);
}
} else if ( (iface != NULL) || (long(block.get()) != 0) )
} else if ((iface != NULL) || (reinterpret_cast<std::intptr_t>(block.get()) != 0))
throw std::runtime_error("Either iface or block are NULL.");
}
@ -410,7 +410,7 @@ bool sink_impl::set_gain_mode( bool automatic, size_t chan )
for (sink_iface *dev : _devs)
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ ) {
if ( _gain_mode[ chan ] != automatic ) {
if ( (_gain_mode.count(chan) == 0) || (_gain_mode[ chan ] != automatic) ) {
_gain_mode[ chan ] = automatic;
bool mode = dev->set_gain_mode( automatic, dev_chan );
if (!automatic) // reapply gain value when switched to manual mode

View File

@ -52,6 +52,10 @@
#include <uhd_source_c.h>
#endif
#ifdef ENABLE_MIRI
#include <miri_source_c.h>
#endif
#ifdef ENABLE_SDRPLAY
#include <sdrplay_source_c.h>
#endif
@ -136,6 +140,9 @@ source_impl::source_impl( const std::string &args )
#ifdef ENABLE_UHD
dev_types.push_back("uhd");
#endif
#ifdef ENABLE_MIRI
dev_types.push_back("miri");
#endif
#ifdef ENABLE_SDRPLAY
dev_types.push_back("sdrplay");
#endif
@ -179,6 +186,7 @@ source_impl::source_impl( const std::string &args )
dev_types.push_back("sdr-ip");
dev_types.push_back("netsdr");
dev_types.push_back("cloudiq");
dev_types.push_back("cloudsdr");
#endif
for (std::string arg : arg_list) {
@ -205,6 +213,10 @@ source_impl::source_impl( const std::string &args )
for (std::string dev : uhd_source_c::get_devices())
dev_list.push_back( dev );
#endif
#ifdef ENABLE_MIRI
for (std::string dev : miri_source_c::get_devices())
dev_list.push_back( dev );
#endif
#ifdef ENABLE_SDRPLAY
for (std::string dev : sdrplay_source_c::get_devices())
dev_list.push_back( dev );
@ -302,6 +314,13 @@ source_impl::source_impl( const std::string &args )
}
#endif
#ifdef ENABLE_MIRI
if ( dict.count("miri") ) {
miri_source_c_sptr src = make_miri_source_c( arg );
block = src; iface = src.get();
}
#endif
#ifdef ENABLE_SDRPLAY
if ( dict.count("sdrplay") ) {
sdrplay_source_c_sptr src = make_sdrplay_source_c( arg );
@ -328,7 +347,8 @@ source_impl::source_impl( const std::string &args )
dict.count("sdr-iq") ||
dict.count("sdr-ip") ||
dict.count("netsdr") ||
dict.count("cloudiq") ) {
dict.count("cloudiq") ||
dict.count("cloudsdr") ) {
rfspace_source_c_sptr src = make_rfspace_source_c( arg );
block = src; iface = src.get();
}
@ -376,7 +396,7 @@ source_impl::source_impl( const std::string &args )
}
#endif
if ( iface != NULL && long(block.get()) != 0 ) {
if (iface != NULL && reinterpret_cast<std::intptr_t>(block.get()) != 0 ) {
_devs.push_back( iface );
for (size_t i = 0; i < iface->get_num_channels(); i++) {
@ -396,7 +416,7 @@ source_impl::source_impl( const std::string &args )
connect(block, i, self(), channel++);
#endif
}
} else if ( (iface != NULL) || (long(block.get()) != 0) )
} else if ((iface != NULL) || (reinterpret_cast<std::intptr_t>(block.get()) != 0))
throw std::runtime_error("Either iface or block are NULL.");
}
@ -597,7 +617,7 @@ bool source_impl::set_gain_mode( bool automatic, size_t chan )
for (source_iface *dev : _devs)
for (size_t dev_chan = 0; dev_chan < dev->get_num_channels(); dev_chan++)
if ( chan == channel++ ) {
if ( _gain_mode[ chan ] != automatic ) {
if ( (_gain_mode.count(chan) == 0) || (_gain_mode[ chan ] != automatic) ) {
_gain_mode[ chan ] = automatic;
bool mode = dev->set_gain_mode( automatic, dev_chan );
if (!automatic) // reapply gain value when switched to manual mode