Commit Graph

338 Commits (master)

Author SHA1 Message Date
rtlsdrblog 2f28c0f498 add direct sampling to rtl_sdr 2023-11-02 12:28:54 +01:00
rtlsdrblog 6de0987c3d add -D direct sampling flag to rtl_tcp 2023-11-02 12:28:51 +01:00
rtlsdrblog 138cd052f5 add blog v4 upconverter gpio switch
In future blog v4 production batches (out in several months time), it
will be possible to turn off the upconverter when tuned outside of the
HF bands. The code controls the GPIOs to turn off the upconverter
when it is not in use.
2023-11-02 12:28:34 +01:00
rtlsdrblog 178267c399 fix rtl_tcp error on windows when hints not initialized to 0 2023-11-02 12:09:46 +01:00
rtlsdrblog 6ca9082aec fix rtl_tcp on macos 2023-11-02 12:08:22 +01:00
rtlsdrblog 1261fbb285 add rtl-sdr blog v4 support 2023-08-23 00:34:08 +02:00
Tobias Girstmair 142325a93c Fix signal handler from getting stuck in an endless loop
The signal handler for SIGINT/TERM/QUIT and, importantly, SIGPIPE tries
to write an informational message to stderr. When however stderr is
redirected to a closed pipe, this will cause (another) SIGPIPE, and in
turn the signal handler will get called again, and again and again.

Since we intend to exit rtl_fm anyways, we can just ignore this signal.
2022-12-17 21:18:49 +01:00
Clayton Smith 5e73f90f1d lib: Stop applying workaround for libusb < 1.0.9
Librtlsdr has a workaround for libusb versions that lack
libusb_handle_events_timeout_completed, which was added in version 1.0.9
(released 2012-04-02). The workaround is always applied unless the
code that sets this macro was removed in
849f8efca4. As a result, the workaround is
now always applied. This results in an extra 1-second delay whenever a
GNU Radio flowgraph containing an RTL-SDR block is stopped, which makes
operations like switching between demodulators in Gqrx annoyingly slow.

To solve this problem, I've simply removed the workaround, as it should
no longer be needed.

I wonder if perhaps the workaround recently applied in
2659e2df31 might stem from the same bug.
2022-01-19 17:59:16 +01:00
jvde.github 2659e2df31 lib: force wait state after cancel of usb transfer
..and before handling usb events

This avoids an occasional crash when closing the device on Windows.
Also see
2022-01-08 20:57:02 +01:00
Martin Hauke d770add42e Fix minGW build
MinGW-w64 ships all Windows SDK headers as lowercase, which prevents
cross-compiling this code from Linux.
2021-09-11 19:09:17 +02:00
Doug Hammond a4eab76c8c rtl_fm: add a new option to select 2nd direct sampling mode 2021-08-18 23:14:10 +02:00
Oliver Smith 3163b8817f rtl_tcp: put new DEFAULT_* constants in defines
Fix failures with some GCC versions:
  /usr/src/packages/BUILD/src/rtl_tcp.c:90:24: error: initializer element is not constant
   static int llbuf_num = DEFAULT_MAX_NUM_BUFFERS;

Fixes: 641c22 ("rtl_tcp: Extracted some constants out of printf strings")
Change-Id: Ia9e18d4c22d957f561dcdaf2657bb6d201374375
2021-08-18 10:32:10 +02:00
David Neiss 641c221fab rtl_tcp: Extracted some constants out of printf strings
The help output contained constants that should print values
based on code constants and not be hardcoded into the print strings.
2021-08-17 23:39:17 +02:00
Eric Wild 0847e93e08 fix windows build
We really should not have pkgconfig as a build requirement on windows.
2020-11-01 01:13:33 +01:00
Steve Markgraf c1faae295c Add rtl_biast as install target
Thanks to for pointing this out.
2020-06-06 21:30:44 +02:00
Derrick Pallas d794155ba6 tuner_r82xx: fix short-write in r82xx_read
In r82xx_read, there is a 1-byte I2C write followed by the I2C read.  If
this I2C write fails, r82xx_read correctly bails out but may return 0.
Callers that check whether (rc < 0) will assume that the buffer was written
when it has not been, e.g. in r82xx_set_tv_standard where

	priv->fil_cal_code = data[4] & 0x0f;

consumes a garbage value for data[4].

This change resolves that issue by copying the error path from r82xx_write.
2020-03-18 23:51:46 +01:00
Steve Markgraf 849f8efca4 Modernize CMake
New minimum version is CMake 3.7.2.

This patch has been rebased to incorporate changes that happened
since the creation of the original patch.

Original Author: A. Maitland Bottoms  <>, 07 Sep 2018
2020-02-26 23:55:32 +01:00
Steve Markgraf f427883320 rtl_tcp: Initialize listensocket
Older versions of GCC will complain that it can be used
uninitialized - which is not the case, but it breaks our Jenkins
build as we build with -Werror.
2020-02-26 23:52:02 +01:00
A. Maitland Bottoms 8985b45e1f rtl_tcp: Add IPv6 support
I've prepared this patch in response to Debian bug #870804

It passes the text from the -a and -p options through
getaddrinfo() and uses the first result that has a valid
socket with a successful bind.

While not a complete bind to all possible valid names, it
does appear to address the use case of the bug submitter
without completely changing the program flow.
2020-02-26 22:55:23 +01:00
A. Maitland Bottoms f2a9a81c4b rtl_fm/rtl_power: Improve scanning range parsing 2020-02-26 22:16:29 +01:00
Benjamin Larsson 1dff8e0b4c lib: enable better UHF reception (>862MHz) for FC0013 2020-02-18 20:52:20 +01:00
leonsal b5af355b1d Fixed issues compiling on Windows with MSVC, CMake and NMake (#61)
When trying to build a simple program which uses librtlsdr
as a subproject on Windows, CMake reported several problems
which were solved by:
- Added complete name of libusb in FindLibUSB module.
- Replaced CMAKE_SOURCE_DIR to PROJECT_SOURCE_DIR in src/CMakeLists.txt.
- Replaced header file <afxres.h> in src/ (only present when windows MFC is
  installed) by <windows.h> which defines the same constants.
2019-12-03 20:47:17 +01:00
Adrian Chadd 43b257854c rtl_biast: Add rtl_biast
This is an import of the rtl_biast command line tool from the
rtlsdrblog github repository.  It's easier to include it here than
try to package up the separate application because they both
wish to install dynamic libraries.
2019-11-12 20:46:02 +01:00
Adrian Chadd 5d0735f5df lib: Add GPIO version of the bias tee configuration API
rtl_biast allows for non-default GPIO pins to be used.
Add an API call which allows for that.
2019-11-12 20:32:35 +01:00
Brian Waters 9d05150a64 Fix building librtlsdr on OpenBSD
Gets rid of librt, which doesn't exist on OpenBSD. The version of
librtlsdr in the OpenBSD ports tree is extremely old (~2013), so this
should help some users.

Tested against tag 0.6.0, but it should apply just fine to HEAD.
2019-11-11 14:28:46 +01:00
Steve Markgraf 3c263b7451 rtl_eeprom: fix warnings
Account for \0 string terminator when calling strncpy().

Fixes the following GCC 9 warning:
warning: ‘__builtin_strncpy’ specified
bound 256 equals destination size
2019-11-01 02:18:54 +01:00
Steve Markgraf 81833a1cf6 lib: disable usbfs zero-copy support by default
Although we added a detection mechanism for the presence of the Kernel
bug earlier, reading from the incorrectly mapped memory might cause a
bus error on some ARM systems.

With the overall performance benefit being rather minimal for the
data rates of rtl-sdr, disable zero-copy by default.
2019-07-16 23:49:48 +02:00
Steve Markgraf be1d1206bf lib: fix memory leak in rtlsdr_open()
Thanks to Vincent Perrier for reporting the bug.
2019-07-16 23:31:31 +02:00
Steve Markgraf f68bb2fa77 lib: Add workaround for Linux usbfs mmap() bug
The Linux Kernel has a bug on ARM/ARM64 systems where the USB CMA
memory is incorrectly mapped to userspace, breaking zerocopy.

When the Kernel allocates the memory, it clears it with memset().
If the mapping worked correctly, we should have zeroed out buffers,
if it doesn't, we get random Kernel memory. We now check for this,
and fall back to buffers in userspace if that's the case.

Signed-off-by: Steve Markgraf <>
2018-10-07 01:25:07 +02:00
David Woodhouse 9047eef701 Fix inline functions to use 'static inline'
With just 'inline', if the compiler decides not to inline them, it isn't
required to emit them at all. For some targets with -Os that is causing
build failures, see

Perhaps we might consider using '__attribute__((always_inline))' for
GCC builds, but 'static inline' is a good start.

Signed-off-by: Steve Markgraf <>
2018-07-03 23:59:01 +02:00
Steve Markgraf 5c3073f417 tuner_r82xx: turn off loop-through, remove dead code
As pointed out by Carl Laufer on the mailing list,
turning the loop-through output off reduces the
current consumption by 10-20mA which in turn reduces
the heat a bit. So far there seem to be no devices
that have anything connected to the loop-through output.

Signed-off-by: Steve Markgraf <>
2018-05-25 00:16:38 +02:00
Pete Zaitcev ce9595ef53 rtl_adsb: fix hanging upon a signal in Fedora 27
This code stayed unchanged for many years, but for some reason
rtl_adsb started hanging upon exit:

^CSignal caught, exiting!
 <------ hangs here forever

Examining it with gdb reveals that the demod thread waits
peacefully on the condition variable, which we're trying to
destroy. Either the signals killed all threads before, or
condition variables were possible to destroy while other
threads still waited on them.

The easiest fix appears to be just cancel the demod thread
and wait for it to exit before proceeding for the door.

Signed-off-by: Steve Markgraf <>
2018-05-23 23:20:26 +02:00
Steve Markgraf a854ae8b48 lib: use USB zero-copy transfers if possible
Decreases CPU load especially for embedded machines.
Requires Linux >= 4.6 and libusb >= 1.0.21. If this
is not the case or the allocation fails, we will
fall back to buffers allocated in userspace.

Signed-off-by: Steve Markgraf <>
2018-05-01 14:23:37 +02:00
Steve Markgraf c403ef0bc1 rtl_test: fix build on Mac OS
Thanks to mot for reporting.
closes #3130

Signed-off-by: Steve Markgraf <>
2018-04-26 23:51:15 +02:00
Harald Welte 5a9864c56d fix "-Wshift-negative-value" compiler warning on ggc-7.3.0 2018-04-18 23:59:17 +02:00
Harald Welte e92b11bfb7 cosmetic: Fix "implicit fall-through" gcc 7.3.0 warnings 2018-04-18 23:59:17 +02:00
Steve Markgraf 4520f001d8 lib: fix FC0012 reset GPIO
Since a typo in rtlsdr_set_gpio_output() was fixed,
FC0012 tuners were not detected anymore, as the reset pin
is actually 4, not 5.

Thanks to David Basden et al for reporting the bug.

Signed-off-by: Steve Markgraf <>
2018-02-20 22:24:46 +01:00
Kacper Michajłow a03198c5b7 rtl_test: Support PPM error measurement on Windows.
Signed-off-by: Steve Markgraf <>
2018-02-20 22:24:40 +01:00
hayati ayguen 18bf26989c Add option '-T' for activating bias-T in rtl_(adsb|fm|power|tcp)
* added debug output when activating
Signed-off-by: hayati ayguen <>
* fixed options argument
Signed-off-by: Fabian P. Schmidt <>
Signed-off-by: Steve Markgraf <>
2017-06-13 01:20:32 +02:00
Dimitri Stolnikov fa3a113b77 rtl_tcp: add command for bias tee control 2017-06-12 00:04:05 +02:00
Lucas Teske 2be1612e60 lib: Use GPIO P0 to toggle an (optional) bias-t
At least one distributor of rtl-sdr dongles ( added
a bias-t to their dongles which could be toggled via GPIO P0 of the
RTL2832U chip.


Signed-off-by: Steve Markgraf <>
2017-06-09 15:06:23 +02:00
Lucas Teske ba64a7459a lib: fix direction bit in GPIO code

* Removed unnecessary comment of old code.
Signed-off-by: Fabian P. Schmidt <>
Signed-off-by: Steve Markgraf <>
2017-06-09 15:06:09 +02:00
Steve Markgraf e3e6ee23b7 lib: add new HanfTek dongle
Signed-off-by: Steve Markgraf <>
2016-11-27 12:19:44 +01:00
Hoernchen e3c03f738f lib: check for libusb init failure 2015-06-09 01:53:23 +02:00
Hoernchen 5c376fc79c tools: allow built-in functions for newer versions of MSVC 2015-06-09 01:37:46 +02:00
Steve Markgraf 8b4d755ba1 Merge pull request #20 from lcl7/correct-e4k_reg_write
Correct return code of e4k_reg_write().
2015-05-16 00:48:37 +02:00
Jiří Pinkava 92df068dc5 New functions rtlsdr_set_tuner_bandwidth()
Signed-off-by: Steve Markgraf <>
2015-05-16 00:38:01 +02:00
Jiří Pinkava d892279085 Allow setting bandwidth for R820T
This improves SDR performence for nearby channel interference.
As a sideeffect also improves dynamic range becase ADC is not overloaded
by onwanted singlas.

Signed-off-by: Steve Markgraf <>
2015-05-16 00:37:17 +02:00
lcl c5dc459fc5 Correct return code of e4k_reg_write().
In contradiction with the documentation, e4k_reg_write() was
returning the value 2 upon success (the number of bytes written),
not zero as documented.
Patched to return zero upon success.

As a consequence, this corrects also the return value of
e4k_reg_set_mask() and e4k_dc_offset_calibrate().
2015-05-08 11:10:30 +02:00
Dimitri Stolnikov d447a2e983 cmake: include resource file for MSVC builds 2014-08-26 21:26:26 +02:00