Giter VIP home page Giter VIP logo

soapyrtlsdr's Introduction

Soapy SDR module for RTL-SDR

Dependencies

Documentation

Licensing information

The MIT License (MIT)

Copyright (c) 2015 Charles J. Cliffe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

soapyrtlsdr's People

Contributors

andreasbombe avatar brianmwaters avatar cjcliffe avatar guruofquality avatar jeija avatar jketterl avatar mr-precise avatar mryndzionek avatar rtlsdrblog avatar sjkelly avatar vsonnier avatar willcode avatar xloem avatar zuckschwerdt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

soapyrtlsdr's Issues

USB claim interface error -3 crashes CubicSDR

Installed CubicSDR via the brew instructions but CubicSDR crashes on clicking Start when the RTL-SDR USB device is selected in the initial starting window. Here is part of the output in Terminal:

 available = No
  driver = rtlsdr
  label = ezcap USB 2.0 DVB-T/DAB/FM dongle :: 00000001
  manufacturer = Realtek
  product = RTL2838UHIDIR
  rtl = 0
  serial = 00000001
  tuner = 
Make device 4
usb_claim_interface error -3
  origin=https://github.com/pothosware/SoapyRTLSDR
  rtl=0


Reporting enumeration complete.
SDR enumerator done.
usb_claim_interface error -3
ERROR: thread '9SDRThread' has not terminated in time ! (> 2000 ms)
SDR enumerator starting.
SoapySDR init..
	API Version: v0.5.2
	ABI Version: v0.5-2
	Install root: /usr/local
	Loading modules... 
	Available factories...audio, bladerf, hackrf, lime, miri, null, osmosdr, redpitaya, remote, rfspace, rtlsdr, uhd

ending with:

Reporting enumeration complete.
SDR enumerator done.
usb_claim_interface error -3
SDR thread starting.
device init()
[INFO] Using format CF32.
Stream MTU: 8192
dyld: lazy symbol binding failed: Symbol not found: _rtlsdr_set_agc_mode
  Referenced from: /usr/local/lib/SoapySDR/modules0.5-2/librtlsdrSupport.so
  Expected in: flat namespace

dyld: Symbol not found: _rtlsdr_set_agc_mode
  Referenced from: /usr/local/lib/SoapySDR/modules0.5-2/librtlsdrSupport.so
  Expected in: flat namespace

/usr/local/bin/cubicsdr: line 5: 44767 Trace/BPT trap: 5       ./CubicSDR
bash$ 

CubicSDR boot->crash.txt

setupStream() mangles tunerGain

setupStream resets tunerGain by calling rtlsdr_get_tuner_gain, but that return value is in tenths of a dB and there is no conversion done, so future calls to getGain() return a value that is wrong by a factor of 10.

tunerGain = rtlsdr_get_tuner_gain(dev);

Splitting up device args - tune and stream args

We have some device arguments which I think are more or less inherited from the Osmo code, but there may be more fitting ways to deal with them in the API.

Stream args

These are device args that could be passed to setupStream()

  • "buflen" and "buffers" are stream args and affect the stream buffer allocations
  • "iq_swap" sounds to me like is also a stream modifier
  • "direct_samp" also a stream modifier?

Tune args

These are device args that could be passed to setFrequency()

  • "offset_tune" could be used to modify rtlsdr_set_offset_tuning only when specified in the tune arguments for setFrequency()
  • "corr" - it looks like this device arg was intended to be redundant with the "CORR" frequency component which calls rtlsdr_set_freq_correction

Possible bugs?

  • current the device arg "corr" and "direct_samp" look like they are parsed, but not actually used

Pros/cons/thoughts...

  • Putting things into the device args is a convenient way to specify extra settings via many of the command line applications because nothing has to be changed about the code. So quite a lot has been crammed into args.
  • Second, RTL is a single channel device, so device-wide args work in this situation -- so long as we dont have multiple channels with heterogeneous settings.
  • We could continue to use device args as the defaults to the tuner or stream args when they are not specified by the user on a per-channel basis, this would keep the old "API" in-tact.

Allow non-integer frequency error correction

๐Ÿ’ก Feature request
Allow non-integer frequency corrections via SoapyRTLSDR::setFrequencyCorrection(const int direction, const size_t channel, const double value) and properly handle them. As librtlsdr supports integer ppm corrections only, this would either require modifying the library or applying the frequency correction in SoapyRTLSDR itself.

๐ŸŽฏ Goal
We are using soapysdr via gr-soapy in the SatNOGS satellite ground stations. A user-provided parameter SATNOGS_PPM_ERROR is passed from the gnuradio flowgraph via gr-soapy to the Soapy Frequency Correction API, to correct for freq errors (e.g. -1 ppm for -1.220 ppm or -3 ppm for -2.675 ppm). A 0.5ppm error at 440Mhz is 0.22 kHz. In some cases even an offset of 0.5 kHz made it difficult to decode some signals (issue tracked at satnogs-client-ansible#90).

Allowing non-integer corrections like -1.220 ppm will reduce the residual error to 0.001 ppm / 0.4 Hz@440MHz, which is small enough.

๐Ÿ“– Related issues

As the support of Frequency Error Correction via the Soapy Frontend Correction API is limited to only a few devices (RTL-SDR & SDRPlay afaik), maybe this can be handled in SoapySDR itself. See pothosware/SoapySDR#291

CC. @janvgils

Device init sometimes does not work (RTL SDR V3)

Hi all,

Thanks for the nice product.

In the last version there is an issue with access to RTLSDR - sometimes it initializing correctly and sometimes is not.

radio

Sometimes it works, and sometimes is not, the probability is about 50% :) Symptoms: the device serial number is empty, the gains are not correct (both are zeros).
It also affects CubicSDR - it does not work correctly.

Device RTL SDR V3, system Windows 10, the drivers were installed with PothosSDR-2019.03.24-vc14-x64.exe (in old version PothosSDR-2018.09.09-vc14-x64.exe all was ok).

Code to reproduce:

import SoapySDR

print("SDR devices:")
for d in SoapySDR.Device.enumerate(''):
        print(d)
print()

print("SDR device gains:")
device = SoapySDR.Device({"driver": "rtlsdr"})
for gain in device.listGains(SoapySDR.SOAPY_SDR_RX, 0):
        print("  %s: %s" % (gain, device.getGainRange(SoapySDR.SOAPY_SDR_RX, 0, gain)))
print()

Addition: if I replace SoapySDR.Device.enumerate('') to SoapySDR.Device.enumerate('driver=rtlsdr') it works always correct, I don't know the reason.

I can't obtain Herz-accurate tuning even with a GSPDO driven RTL-SDR V3

In order to simplify the deployment of VHF/UHF WSPR reporting sites, I am trying to use librtlsdr to tune to those 200 Hz wide bands. However I find that the USB audio output tone frequencies are off by 100's of hz from the 1000 hz I expect when tuning 1000 hz below a GPSDO stabilized reference carrier.

I have enabled the VCO diagnostic printout in pothoware/librtlsdr and the tone errors don't correlate with the tuning_error printouts. Even if these tuning errors cannot be avoided due to the chip architecture, If I knew the actual error I could frequency shift the audio file.

The ability to use RTL-SDRs for VHF/UHF should greatly enhance the number of such WSPR monitoring stations and hopefully lead to greater insights into RF propagation at those frequencies, and I'm ready to follow any path to a solution.

Thanks for any help and suggestions,

Rob
AI6VN

`rob@Wsprdaemon-Thinkcenter:~/rtltest$ ~/librtlsdr/build/src/rtl_fm -R 5 -f 575999000 -M usb | sox -r 24k -t raw -e s -b 16 -c 1 - 1000-hz.wav
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T/2 tuner
[R82XX] requested 56000000 Hz; selected mix_div=32 vco_freq=1792000000 nint=31 sdm=7282; actual_vco=1792000195; tuning error=+6Hz
Tuner gain set to automatic.
[R82XX] requested 57925000 Hz; selected mix_div=32 vco_freq=1853600000 nint=32 sdm=11833; actual_vco=1853600097; tuning error=+3Hz
Bandwidth set to automatic resulted in 290000 Hz.
[R82XX] requested 577672000 Hz; selected mix_div=4 vco_freq=2310688000 nint=40 sdm=7609; actual_vco=2310687597; tuning error=-100Hz
Tuned to 575.747000 MHz.
Oversampling input by: 42x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
[R82XX] requested 577952000 Hz; selected mix_div=4 vco_freq=2311808000 nint=40 sdm=8884; actual_vco=2311808203; tuning error=+50Hz
Sampling at 1008000 S/s.
Output at 24000 Hz.
Allocating 15 zero-copy buffers
Time expired, exiting!

User cancel, exiting...
rob@Wsprdaemon-Thinkcenter:/rtltest$ sox 1000-hz.wav -n stat -freq |& grep Rough
Rough frequency: 4217
rob@Wsprdaemon-Thinkcenter:
/rtltest$`

Issue with sync API

Referencing this issue: pothosware/SoapyRemote#9 I noticed that a FM demod demo was extremely choppy and causing audio underflows. This didnt happen with the RTL support from SoapyOsmo. I couldn't find anything obviously wrong with the use of the sync api or the conversion code.

So I switched to the async api on this branch and the problem went away: https://github.com/pothosware/SoapyRTLSDR/commits/async_stream

I suspect a bug in the sync API, and I wonder if anyone else is seeing a similar issue. Although the sync API is more fitting here, if its going to have issues, the async_stream branch needs some cleanup and can be merged.

setBandwidth/getBandwidth no-ops, should call rtlsdr_set_and_get_tuner_bandwidth?

SoapyRTLSDR's bandwidth methods currently only call the stubs in the superclass, which return 0 Hz:

SoapyRTLSDR/Settings.cpp

Lines 448 to 463 in a44abc3

void SoapyRTLSDR::setBandwidth(const int direction, const size_t channel, const double bw)
{
SoapySDR::Device::setBandwidth(direction, channel, bw);
}
double SoapyRTLSDR::getBandwidth(const int direction, const size_t channel) const
{
return SoapySDR::Device::getBandwidth(direction, channel);
}
std::vector<double> SoapyRTLSDR::listBandwidths(const int direction, const size_t channel) const
{
std::vector<double> results;
return results;
}

https://github.com/pothosware/SoapySDR/blob/master/lib/Device.cpp#L486-L499

should these methods be bridged to librtlsdr's rtlsdr_set_and_get_tuner_bandwidth() (and/or rtlsdr_set_tuner_bandwidth()??

Note that these librtlsdr APIs to get/set bandwidth are relatively new, not all installations may necessarily have it yet, so it may be worth holding off until it can be confirmed it is widely available as needed. I have no immediate need for it, just noticed this gap in librtlsdr->SoapyRTLSDR bridging while working on something else.

References:

Frequency update doesn't always seem to work

Leaving this issue here at the moment since I think it's only relevant to SoapyRTLSDR -- when tuning quickly in CubicSDR occasionally the last frequency update doesn't seem to "take" and the data being sent doesn't match the center frequency..

RPi Buster succcess??

I'm having trouble getting it to build on a Rpi with the latest Buster release. cmake runs OK but at make time I get... atomic 8 issue?

[100%] Linking CXX shared module librtlsdrSupport.so
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::getHardwareTime(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const': Settings.cpp:(.text+0x12c): undefined reference to __atomic_load_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::setHardwareTime(long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': Settings.cpp:(.text+0x174): undefined reference to __atomic_store_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::setSampleRate(int, unsigned int, double)': Settings.cpp:(.text+0x5b4): undefined reference to __atomic_load_8'
/usr/bin/ld: Settings.cpp:(.text+0x62c): undefined reference to __atomic_store_8' /usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::SoapyRTLSDR(std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&)':
Settings.cpp:(.text+0x4ca4): undefined reference to __atomic_store_8' /usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Streaming.cpp.o: in function SoapyRTLSDR::rx_callback(unsigned char*, unsigned int)':
Streaming.cpp:(.text+0x29f0): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rtlsdrSupport.dir/build.make:131: librtlsdrSupport.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rtlsdrSupport.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Long pause every time frequency is changed

#49 has made SoapyRTLSDR unusable in Gqrx because reception is interrupted for approximately one second every time the frequency is adjusted.

@cjcliffe Can you let me know what the bug was that prompted #49? I'd be happy to help find a better solution for it.

If you request an invalid sample rate, the internal member variable in Settings.cpp will be updated

Currently there is no way to determine if a sample rate was valid or not. You can certainly check the ranges and not allow invalid rates to go through as a workaround, but it seems that the function calls should do the right thing.

The error should be handled by either throwing an exception or keeping the sample rate the same, so the user can query "getSampleRate" to get the actual rate that is being used.

Since the actual rate that gets set can be slightly different than the rate requested, getSampleRate should query the device vs using the member variable sampleRate.

void SoapyRTLSDR::setSampleRate(const int direction, const size_t channel, const double rate)
{
    long long ns = SoapySDR::ticksToTimeNs(ticks, sampleRate);
    sampleRate = rate;
    resetBuffer = true;
    SoapySDR_logf(SOAPY_SDR_DEBUG, "Setting sample rate: %d", sampleRate);
    rtlsdr_set_sample_rate(dev, sampleRate);
    ticks = SoapySDR::timeNsToTicks(ns, sampleRate);
}

Fix E4000 gains

From cjcliffe/CubicSDR#169

Fix the gain settings for E4000 tuner.

static const int8_t if_stage1_gain[] = {
-3, 6
};

static const int8_t if_stage23_gain[] = {
0, 3, 6, 9
};

static const int8_t if_stage4_gain[] = {
0, 1, 2, 2
};

static const int8_t if_stage56_gain[] = {
3, 6, 9, 12, 15, 15, 15, 15
};

if_stage23_gain applies to stage 2 and 3, applies to stage 5 and 6

the numbers are dB

rtlsdr ppm correction, how

How can we correct the ppm value with soapyrtlsdr?
The current SoapySDRUtil --probe="driver=rtlsdr" isn't showing a corr=value option anymore.

`SoapySDRUtil --probe="driver=rtlsdr"
######################################################

Soapy SDR -- the SDR abstraction library

######################################################

Probe device driver=rtlsdr
Found Rafael Micro R820T tuner
Found Rafael Micro R820T tuner


-- Device identification

driver=RTLSDR
hardware=R820T
origin=https://github.com/pothosware/SoapyRTLSDR
rtl=0


-- Peripheral summary

Channels: 1 Rx, 0 Tx
Timestamps: NO
Other Settings:
* Direct Sampling - RTL-SDR Direct Sampling Mode
[key=direct_samp, default=0, type=string, options=(0, 1, 2)]
* Offset Tune - RTL-SDR Offset Tuning Mode
[key=offset_tune, default=false, type=bool]
* I/Q Swap - RTL-SDR I/Q Swap Mode
[key=iq_swap, default=false, type=bool]
* Digital AGC - RTL-SDR digital AGC Mode
[key=digital_agc, default=false, type=bool]


-- RX Channel 0

Full-duplex: YES
Supports AGC: YES
Stream formats: CS8, CS16, CF32
Native format: CS8 [full-scale=128]
Stream args:
* Buffer Size - Number of bytes per buffer, multiples of 512 only.
[key=bufflen, units=bytes, default=262144, type=int]
* Ring buffers - Number of buffers in the ring.
[key=buffers, units=buffers, default=15, type=int]
* Async buffers - Number of async usb buffers (advanced).
[key=asyncBuffs, units=buffers, default=0, type=int]
Antennas: RX
Full gain range: [0, 49.6] dB
TUNER gain range: [0, 49.6] dB
Full freq range: [23.999, 1764] MHz
RF freq range: [24, 1764] MHz
CORR freq range: [-0.001, 0.001] MHz
Sample rates: 0.25, 1.024, 1.536, 1.792, 1.92, 2.048, 2.16, 2.56, 2.88, 3.2 MSps`

Sampling Timing Lost on Tune

The rtlsdr usually has the pleasant feature that sample time stays consistent across tuning i.e. time * samplerate = samplenum .

SoapyRTLSDR prevents the user from using this timing information by automatically dropping buffers when retuning.
Alternatives might include:

  • propagating the sample timing information using the timeNs field
  • passing the stale buffers to the user, but providing to query at what sample time the tune happened, or what the tuning was for the last readStream call
  • allowing to query how many buffers were dropped

It's notable that dropping these buffers means a loss of useful data from before the tune happened.
Additionally, it's possible there may still be buffers accumulating that have the old tuning, despite the reset, if some slow page fault has left them hanging on the libusb queue.

initial 0.1.0 release tag

  • after some more testing and things settle down
  • default rtl support through soapy osmo to off
    • update wiki page for SoapyOsmo as well

Feature Request: Add toggle for v3 dongle sw controlled bias-t

Hi, would be a cool feature to be able to use v3 sw controlled bias-t. https://github.com/rtlsdrblog/rtl_biast/blob/master/src/rtl_biast.c Happy to test! Thanks!

######################################################

Soapy SDR -- the SDR abstraction library

######################################################

Probe device driver=rtlsdr
Found Rafael Micro R820T tuner
Found Rafael Micro R820T tuner


-- Device identification

driver=RTLSDR
hardware=RTLSDR
origin=https://github.com/pothosware/SoapyRTLSDR
rtl=0


-- Peripheral summary

Channels: 1 Rx, 0 Tx
Timestamps: NO
Other Settings:
* Direct Sampling - RTL-SDR Direct Sampling Mode
[key=direct_samp, default=0, type=string, options=(0, 1, 2)]
* Offset Tune - RTL-SDR Offset Tuning Mode
[key=offset_tune, default=false, type=bool]
* I/Q Swap - RTL-SDR I/Q Swap Mode
[key=iq_swap, default=false, type=bool]


-- RX Channel 0

Full-duplex: YES
Supports AGC: YES
Stream formats: CS8, CS16, CF32
Native format: CS8 [full-scale=128]
Stream args:
* Buffer Size - Number of bytes per buffer, multiples of 512 only.
[key=bufflen, units=bytes, default=262144, type=int]
* Ring buffers - Number of buffers in the ring.
[key=buffers, units=buffers, default=15, type=int]
* Async buffers - Number of async usb buffers (advanced).
[key=asyncBuffs, units=buffers, default=0, type=int]
Antennas: RX
Full gain range: [0, 49.6] dB
TUNER gain range: [0, 49.6] dB
Full freq range: [23.999, 1764] MHz
RF freq range: [24, 1764] MHz
CORR freq range: [-0.001, 0.001] MHz
Sample rates: 0.25, 1.024, 1.536, 1.792, 1.92, 2.048, 2.16, 2.56, 2.88, 3.2 MSps

Direct Mode, how?

I'd like to use HF but am having trouble getting my v3 into direct mode

What output can be used for CubicSDR with IQ output

Hello
I succeed to install Cubicsdr with soapy with ubuntu 14.4 . I would like to use IQ output in order to use TETRA decoder .
my standard command line is
demod/python/simdemod.py -o /dev/stdout -i /tmp/fifo1 | ./float_to_bits /dev/stdin /dev/stdout | ./tetra-rx /dev/stdin

I didn't find how to replace -i /tmp/fifo1 by other device like -i /dev/dsp in order to get IQ output from CubicSDR to Tetra

Same command line is working with funcube pro + using QTHID

Thanks for answer

pothos rtlsdr_get_device_usb_string failed.

I got the message: pothos rtlsdr_get_device_usb_string failed
when using the example file : simple_fm_demod.pothos
with PothosWare - Pothos SDR flow on MS Windows 10 on a Asus VivoBook working with a RTLSDR v4 USBstick

As a SDR noob, I do not know what is wrong or how to solve it.
Therefore any help/advise/tips are all welcome

Missing getSampleRateRange() implementation

Per title, the rtlsdr driver doesn't implement getSampleRateRange() even though a continuous range of sample rates is supported.

(This is a problem for software that uses listSampleRates() / getSampleRateRange() to determine allowable rates)

Invalid sample values Returned

Hi
When running the following code taken from the soapysdr c API example the samples returned for FM station(audible in sdrsharp) are invalid, I think. Do I need to do any post-processing before demodulation.

  //create a re-usable buffer for rx samples
    complex float buf[32768];
while(1)
{
        void *buffs[] = {buf}; //array of buffers
        int flags=0; //flags set by receive operation
        long long timeNs=0; //timestamp for receive buffer
         ret= SoapySDRDevice_readStream(sdr, rxStream, buffs, 4096, &flags, &timeNs, 1000000); //100000 
         
         for(int m=0;  m<ret*1;m++)//  /8
		{				
			i= creal(buf[m]) ;  
			q =cimag(buf[m]) ;  
			printf("i=%f q=%f\n",i,q);
}

The samples obtained are as follows

i=0.000000 q=0.000000 
i=0.000000 q=0.000000
i=0.000000 q=-1.#QNAN0
i=-374479884198376570000000000000.000000 q=0.000000
i=-95881357464619777000000000000000.000000 q=-6285423662376635500000000000000000000.000000
i=-95893446722815924000000000000000.000000 q=-23410895720502123000000000000.000000
i=-5716703634517820400000000.000000 q=-93679000630630013000000000000.000000

Adding function to set GPIO pins to the SoapyRTL Driver?

I want to add a GPIO interface to the Soapy RTL-SDR driver. I'm designing an automatic antenna tuner that I want to control using the GPIO pins on the RTL-SDR.

The Blade RF Soapy driver has a GPIO interface. I'd like to implement a similar interface for the RTL-SDR:

void writeGPIO(const std::string &bank, const unsigned value);
void writeGPIO(const std::string &bank, const unsigned value, const unsigned mask);

The issue is that the librtlsdr driver supports these changing these pins with rtlsdr_set_gpio_bit, but this function is not public by default.

So I have a couple questions:

  1. On the Soapy side, does this API make sense?
  2. What should I do about making that function public in the librtlsdr driver? Is there a way to check whether that function is available when compiling, either in a future version of the driver or a custom fork?

Thanks.

Initial test

Did a quick check with three different dongles:

[DEBUG] Device #0: Generic RTL2832U OEM
[DEBUG]     Manufacturer: Realtek, Product Name: RTL2838UHIDIR, Serial: 00000153
Found Rafael Micro R820T tuner
[DEBUG]      Tuner type: Rafael Micro R820T
[DEBUG] Device #0: Terratec NOXON DAB/DAB+ USB dongle (rev 2)
[DEBUG]     Manufacturer: Realtek, Product Name: RTL2832U, Serial: 00000001
Found Elonics E4000 tuner
[DEBUG]      Tuner type: Elonics E4000
[DEBUG] Device #0: Terratec NOXON DAB/DAB+ USB dongle (rev 1)
[DEBUG]     Manufacturer: NOXON, Product Name: DAB Stick, Serial: 0
Found Fitipower FC0013 tuner
[DEBUG]      Tuner type: Fitipower FC0013

All three are working fine, but audio is a little bit choppy, independent of bandwidth setting.

atomic lib linking error

When I compile SoapyRTLSDR on my Raspberry Pi 3 with GCC 8.3.0, by :

cmake -DCMAKE_INSTALL_PREFIX=/opt/install/SoapySDR  -DRTLSDR_INCLUDE_DIR=/opt/install/librtlsdr/include -DRTLSDR_LIBRARY=/opt/install/librtlsdr/lib/librtlsdr.so -DSOAPY_SDR_INCLUDE_DIR=/opt/install/SoapySDR/include -DSOAPY_SDR_LIBRARY=/opt/install/SoapySDR/lib/libSoapySDR.so ..
make -j

there are several errors provided by linker

[100%] Linking CXX shared module librtlsdrSupport.so
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function `SoapyRTLSDR::getHardwareTime(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const':
Settings.cpp:(.text+0x12c): undefined reference to `__atomic_load_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function `SoapyRTLSDR::setHardwareTime(long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
Settings.cpp:(.text+0x174): undefined reference to `__atomic_store_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function `SoapyRTLSDR::setSampleRate(int, unsigned int, double)':
Settings.cpp:(.text+0x580): undefined reference to `__atomic_load_8'
/usr/bin/ld: Settings.cpp:(.text+0x5f8): undefined reference to `__atomic_store_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Streaming.cpp.o: in function `SoapyRTLSDR::rx_callback(unsigned char*, unsigned int)':
Streaming.cpp:(.text+0x29f0): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rtlsdrSupport.dir/build.make:131: librtlsdrSupport.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rtlsdrSupport.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

CubicSDR sluggish with SoapyRTLSDR v0.23 + async setting bug

@guruofquality @cjcliffe Good morning !
This is a bug entry for the latest SoapySDR v0.23 seen on CubicSDR both on latest Cubic v0.22 Win64 and the one provided in the PothosSDR-2017.05.02-vc14-x64.exe distribution.
On both, CubicSDR OpenGL is sluggish as if "Limit CPU usage" option was ON constantly, while using a RTL-SDR.
I tracked down the problem noticing that with SoapyRTLSDR module v0.22 CubicSDR was fast as hell as before.

Finally it goes down to 2 things:

  • Changing in SoapyRTLSDR.hpp the constant #define DEFAULT_BUFFER_LENGTH back to 16384 restored the performance,
  • I also noticed an affectation cut-n-paste bug in Streaming.cpp (261) where there is asyncBuffs = asyncBuffs instead of asyncBuffs = asyncBuffs_in, making the async buffer number setting inoperative.

I don't know if both changes are related, but recompiling SoapyRTLSDR v0.23 with the above changes restored the perfomance of the latest CubicSDR builds.

Seen on a Win7 x64 platform.

Automatic gain mode setting, rtlsdr_set_tuner_gain_mode(dev, 0) equivalent

librtlsdr implements rtlsdr_set_tuner_gain_mode() here for setting "automatic" (0) or "manual" (1) gain mode, this API doesn't appear to be bridged in SoapyRTLSDR.

Should it be, or how can one enable auto gain? (curious how CubicSDR does it). Without setting some gain, I can only receive silence, using 40 dB as a default for now but having the hardware/driver automatically choose the default gain values seems to be preferable, especially if it can differ between devices or other configurations.

(Note, mainly to self: automatic gain is distinct from automatic gain correction (agc), librtlsdr's rtlsdr_set_agc_mode(), which is bridged in SoapyRTLSDR setGainMode(bool). But not https://github.com/pothosware/SoapyRTLSDR/search?q=rtlsdr_set_tuner_gain_mode)

undefined reference to "__atomic_load_8

So first sorry for my english (I'm french)
I'm trying to install librealsense on a raspberry PI 3 but when I'm buiding it's show this error :
~/Work/librealsense/build $ make -j1
[ 55%] Built target fw
[ 55%] Built target realsense-file
[ 55%] Built target realsense2
[ 55%] Built target libcurl
[ 55%] Built target glfw
[ 55%] Built target realsense2-gl
[ 55%] Linking CXX executable rs-hello-realsense
/usr/bin/ld : ../../librealsense2.so.2.50.0 : undefined reference to "__atomic_load_8".
/usr/bin/ld : ../../librealsense2.so.2.50.0 : undefined reference to "__atomic_store_8
/usr/bin/ld : ../../librealsense2.so.2.50.0 : undefined reference to "__atomic_fetch_add_8
collect2: error: ld returned 1 exit status
make[2]: *** [examples/hello-realsense/CMakeFiles/rs-hello-realsense.dir/build.make:110 : examples/hello-realsense/rs-hello-realsense] Erreur 1
make[1]: *** [CMakeFiles/Makefile2:1240 : examples/hello-realsense/CMakeFiles/rs-hello-realsense.dir/all] Erreur 2
make: *** [Makefile:149 : all] Erreur 2

If anyone has an idea of what to do ?

SoapyRTLSDR Number of samples to read

I have a problem reading samples from the dongle since in rx_fm there is a large number of samples (131,072) to read passed as an argument to the function as shown here in rtl_fm.c https://github.com/rxseger/rx_tools/blob/master/src/rtl_fm.c

#define DEFAULT_BUF_LENGTH (1 * 16384)

#define MAXIMUM_OVERSAMPLE		16
#define MAXIMUM_BUF_LENGTH		(MAXIMUM_OVERSAMPLE * DEFAULT_BUF_LENGTH)
samples_per_buffer = MAXIMUM_BUF_LENGTH/2
r = SoapySDRDevice_readStream(s->dev, s->stream, buffs, samples_per_buffer, &flags, &timeNs, timeoutNs);
		//fprintf(stderr, "ret=%d\n", r);

		if (r >= 0) {
			// r is number of elements read, elements=complex pairs, so buffer length in bytes is twice
			rtlsdr_callback(buf, r * 2, s);
		}

However, my program with same lines of code hangs until and unless i pass a very small value of samples to read from the dongle such as 512. Plz note that 131,072*2 (is passed to the function rtlsdr_callback(buf, r * 2, s); )
Can anyone tell what could be the issue?
Also i don't see any callback function in soapyrtlsdr that i can use to get samples from rtl sdr dongle. Plz guide me if there is any.
Thanks

No SoapySDR API returns the gain values list of RTLSDR dongles.

The RTL-SDR valid tuner gains values are returned by librtlsdr:rtlsdr_get_tuner_gains().
These values change with the tuner type. For R820T tuner for instance it's a nonlinear list of 29 values:
0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6

The SoapyRTLSDR::SoapyRTLSDR() constructor loads this full list from the dongle but -
since the SoapySDR API getGainRange() returns only a range (3-values tuple) -
only the minimum and maximum of these values, can be read (the third element, step, is zero):

//extract min/max overall gain range

int num_gains = rtlsdr_get_tuner_gains(dev, nullptr);

if (num_gains > 0)
{
    std::vector<int> gains(num_gains);
    rtlsdr_get_tuner_gains(dev, gains.data());
    gainMin = *std::min_element(gains.begin(), gains.end()) / 10.0;
    gainMax = *std::max_element(gains.begin(), gains.end()) / 10.0;
}

So it's matter to make the gains vector a class member and find a way (API) to return its contents to the
application.

Does Pothos SDR supported the RTLSDR v4 USBstick

Dear PothosWare,

Hope your doing well.
Please confirm, I have the gut feeling Pothos SDR , soapyRTLSDR block only supported the RTLSDR v3 USBstick (R860 tuner chip. )
and not the new the RTLSDR v4 USBstick (R828D tuner chip. )
Is my cut feeling corrct?
Please advise how to make it work with the v4 version (perhaps replace *.dll somewhere)
or perhaps hint when this feature is being developed?
Kind regards
a SDR noob

usb_claim_interface error -6

Hello I have installed the plugin for use the rtlsdr in pothos but get this error in message window and no data is received in diagram.

the rtl test is working correctly:

Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...
Allocating 15 zero-copy buffers
lost at least 80 bytes

and the SoapySDRUtil --probe="driver=rtlsdr" command seems like the wiki...

Thanks.

undefined reference to `__atomic_load_8'

I cannot seem to compile SoapyRTLSDR on my raspberry PI. I have an RTL SDR v3. I have followed steps in the various Wiki pages to install SoapySDR and SoapyRemote.

raspberrypi:~/SoapyRTLSDR/build# cat /etc/debian_version
10.0

raspberrypi:~/SoapyRTLSDR/build# cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 1
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 2
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

processor : 3
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 38.40
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4

Hardware : BCM2835
Revision : a02082
Serial : 0000000058407487

raspberrypi:~/SoapyRTLSDR/build# rtl_test
Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000010

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner

raspberrypi:/SoapyRTLSDR/build# cmake ..
-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Build type not specified: defaulting to release.
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29")
-- Checking for module 'librtlsdr'
-- Found librtlsdr, version 0.6.0-5-g8183
-- Found rtlsdr: /usr/local/lib/librtlsdr.so
-- RTLSDR_INCLUDE_DIRS - /usr/local/include
-- RTLSDR_LIBRARIES - /usr/local/lib/librtlsdr.so
-- Performing Test HAS_STD_CXX11
-- Performing Test HAS_STD_CXX11 - Success
-- Found Git: /usr/bin/git (found version "2.20.1")
-- Module rtlsdrSupport configured with version: 0.3.1-5c5d950
-- Configuring done
-- Generating done
-- Build files have been written to: /root/SoapyRTLSDR/build
raspberrypi:
/SoapyRTLSDR/build# make
Scanning dependencies of target rtlsdrSupport
[ 20%] Building CXX object CMakeFiles/rtlsdrSupport.dir/Version.cpp.o
[ 40%] Linking CXX shared module librtlsdrSupport.so
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::getHardwareTime(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const': Settings.cpp:(.text+0x12c): undefined reference to __atomic_load_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::setHardwareTime(long long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': Settings.cpp:(.text+0x174): undefined reference to __atomic_store_8'
/usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::setSampleRate(int, unsigned int, double)': Settings.cpp:(.text+0x5b4): undefined reference to __atomic_load_8'
/usr/bin/ld: Settings.cpp:(.text+0x62c): undefined reference to __atomic_store_8' /usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Settings.cpp.o: in function SoapyRTLSDR::SoapyRTLSDR(std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, std::__cxx11::basic_string<char, std::char_traits, std::allocator > > > > const&)':
Settings.cpp:(.text+0x4ca4): undefined reference to __atomic_store_8' /usr/bin/ld: CMakeFiles/rtlsdrSupport.dir/Streaming.cpp.o: in function SoapyRTLSDR::rx_callback(unsigned char*, unsigned int)':
Streaming.cpp:(.text+0x29f0): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/rtlsdrSupport.dir/build.make:131: librtlsdrSupport.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:73: CMakeFiles/rtlsdrSupport.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Samplerate error

Sample rate is set to 2.28571M (2285710) in the Soapy RTLSDR Source block (GNU Radio 3.9.4).
This causes the following error,

self.soapy_rtlsdr_source_0.set_sample_rate(0, samp_rate)
ValueError: source: Unsupported sample rate (2285710.000000). Rate must be in the range 250000.000000, 1024000.000000, 1536000.000000, 1792000.000000, 1920000.000000, 2048000.000000, 2160000.000000, 2560000.000000, 2880000.000000, 3200000.000000
Reattached kernel driver

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.