RTLSDR Scanner Multiprocessing

Al's picture

The RTLSDR scanner has been given a bit of an update behind the scenes.

It now analyses data using separate processes rather than threads which allows for far more efficient processor usage, as a result large scans are faster and the user interface is far more responsive.

Unfortunately I'm having problems with PyInstaller (which I use to create the binaries), as soon as this is fixed I'll upload them to Sourceforge.

Categories: 

Comments

15

Click to view comments

Dear Developer,
I would like to know, what long you mind it could take, until RTLSDR Scanner Multiprocessing is ready. I use it 24 hours per day for my Radio Telescope. My problem is just the big time it takes for making an scan with dwell 4 seconds and 1MHz bandwidth. Congratulations for the development of this essential tool.
Here daily live data taken with "RTLSDR Scanner" -> http://www.germersogorb.de/html/lbandlive.html
Some details about the radio telescope http://www.germersogorb.de/html/l-band_radioteleskop.html
Unfortunately everything in german and spanish only. (:-(

Thank you very much.
Regards,
M°Jesus

Al's picture

Hello,

This post is a bit out of date, multiprocessing is now used in the software but I was talking about creating Windows executables. I no longer distribute these binaries but use an installer instead.

The effect multiprocessing is best seen when using very short dwell times, with longer dwells the processing of the signal is much shorter than the capture time so little benefit is gained. Without multiprocessing slow machines could delay the next signal capture while the data was processed, this is no longer the case.

The main reason for the speed limitation is the sample rate of the RTLSDR dongle, at some point I'm going to add an option to change this but it won't make a big difference to scan times. As the scanner sweeps across a frequency range multiple times to get an approximation of a flat frequency response, the scan is slowed even more.

Thanks for the links, I found them interesting as it's always good to see how the software is used.

Thank you very much for your answer.

Regards,
M°Jesus

Tested on Ubuntu 14.04 !
I have just got it and my new Ubuntu 14.04 with RTLSDR-Scanner are running. I told you some months ago, I use ist for radio astronomy and for me it is very important to be able to use a great DWELL (4sec). It always went good under Windows 7 but now, on this Ubuntu PC, it is not possible to take a greater DWELL than 2s. Anyway it crahses and I always see "EXCEPT1" error. Any idea?
Thank you very much.
Best regards,
M°Jesús Sogorb Amoros

Al's picture

I wonder if it's a memory issue, how much RAM do you have and is it the 64 bit version of Ubuntu?

If you run it from a terminal window you will be able to see all of the error message, could you post it so I can try and track down the problem?

Thanks.

Good evening,

thank you very much for your help. I have a AMD (some years old) pc with 6Mb RAM for LINUX( the notebook with windows 7, where it always run has a greater performance) Anyway I just can set 1sec DWELL. I modified your python code, so that it can be executed without graphics and after being the scan ready, it writes a csv file. By executing you see the problem:

$ python ./rtlsdr_scan-only-2.py 96 97 3
Start Frequency is 96.
End Frequency is 97.
DWELL is 3
Samples
9000000.0
Found Elonics E4000 tuner
Exact sample rate is: 3000000.178814 Hz
EXCEPT 1
Found Elonics E4000 tuner
Exact sample rate is: 3000000.178814 Hz
EXCEPT 1
Found Elonics E4000 tuner
Exact sample rate is: 3000000.178814 Hz
EXCEPT 1
^CFound Elonics E4000 tuner
Traceback (most recent call last):
File "./rtlsdr_scan-only-2.py", line 284, in
main()
File "./rtlsdr_scan-only-2.py", line 281, in main
s.scanAndSave(start, stop, dwell, isCal)
File "./rtlsdr_scan-only-2.py", line 220, in scanAndSave
self.thread.run()
File "./rtlsdr_scan-only-2.py", line 146, in run
sdr = self.rtl_setup()
File "./rtlsdr_scan-only-2.py", line 159, in rtl_setup
sdr = rtlsdr.RtlSdr(self.index)
File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdr.py", line 59, in __init__
result = librtlsdr.rtlsdr_open(self.dev_p, device_index)
KeyboardInterrupt

With Ctrl+C I get every time different errors. For example once again:

$ python ./rtlsdr_scan-only-2.py 96 97 3
Start Frequency is 96.
End Frequency is 97.
DWELL is 3.
Samples
9000000.0
Found Elonics E4000 tuner
Exact sample rate is: 3000000.178814 Hz
Found Elonics E4000 tuner
Exact sample rate is: 3000000.178814 Hz
EXCEPT 1
^CTraceback (most recent call last):
File "./rtlsdr_scan-only-2.py", line 284, in
main()
File "./rtlsdr_scan-only-2.py", line 281, in main
s.scanAndSave(start, stop, dwell, isCal)
File "./rtlsdr_scan-only-2.py", line 220, in scanAndSave
self.thread.run()
File "./rtlsdr_scan-only-2.py", line 140, in run
scan = self.scan(sdr, freq)
File "./rtlsdr_scan-only-2.py", line 171, in scan
capture = sdr.read_samples(self.samples)
File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdr.py", line 328, in read_samples
raw_data = self.read_bytes(num_bytes)
File "/usr/local/lib/python2.7/dist-packages/rtlsdr/rtlsdr.py", line 305, in read_bytes
self.buffer = array_type()
KeyboardInterrupt

Is it maybe a question of samples??
Thank you very much again.

Best Regards,
Maria Jesus Sogorb Amoros

Al's picture

From the log you're sampling at 3Mb/s which gave me all sorts of problems and segmentation faults on Ubuntu 12.04.

At the moment Ctrl-C detection is not implemented so will cause errors.

I almost forgot, yes, it is the 64 Bit Version of Kubuntu 14.04 with the last kernel.
M°Jesús

Now I took the harddrive into a powelful pc and using a nano RTLSDR Stick, but the effect is the same (using now the unmodified tool):

$> ./rtlsdr_scan.py -s 96 -e 97 -d 3 test2.csv
RTLSDR Scanner

Found Elonics E4000 tuner
96 - 97MHz
-1.0dB Gain
4.194s Dwell
1024 FFT points
0MHz LO
Generic RTL2832U
Starting
Found Elonics E4000 tuner
Exact sample rate is: 2000000.052982 Hz
Speicherzugriffsfehler (Speicherabzug geschrieben) = segmentation fault (core dumped)

So I think it is not an issue of performance.
M°Jesús

Good Afternoon,

I have experimented a little bit the last days and debugged the application. Now I know the problem is in the following function:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
def read_bytes(self, num_bytes=DEFAULT_READ_SIZE):
''' Read specified number of bytes from tuner. Does not attempt to unpack
complex samples (see read_samples()), and data may be unsafe as buffer is
reused.
'''
# FIXME: libsdrrtl may not be able to read an arbitrary number of bytes

num_bytes = int(num_bytes)

# create buffer, as necessary
if len(self.buffer) != num_bytes:
array_type = (c_ubyte*num_bytes)
self.buffer = array_type()

result = librtlsdr.rtlsdr_read_sync(self.dev_p, self.buffer, num_bytes,\
byref(self.num_bytes_read))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

and just by the last call. It is possible under ubuntu to take a dwell (with sampling rate of 3M) up to 2 seconds. More than that, no chance to read this amount of samples.

My very last question: Is it possible to get the same effect like a high dwell of 4 seconds in RTLSDR-Scanner in any other way?
Thanks again and sorry for my amount of questions.

Best regards,
M°Jesus

Al's picture

Thanks very much for that, I while ago I committed some code which added a user selectable bandwidth. I reverted it due to the segmentation faults but never got chance to properly debug this issue so I'm glad you found it.

I think the solution is to run the capture in a loop and merge the results, I'll take a look at it.

Thank you for the effort you've put into this very cool piece of work.

It turns the rtl-sdr from a toy into a tool.

FYI it works very well in Gentoo.

Once again, thank you very much.

John Q. Smith

Al's picture

Thanks, it's always good to get comments like that!

Works great, thank you for a great tool!

Al's picture

Thank you, glad it's useful.

Click to add a comment