rtl_tcp server

Add useful snippets of code or links to entire SDR projects.
TonyHoyle
Posts: 13
Joined: Sun May 24, 2015 9:59 pm

rtl_tcp server

Postby TonyHoyle » Fri Jun 05, 2015 10:23 pm

I've knocked together and rtl_tcp server so I can listen to my raspberry pi remotely. It's pretty simple, but amazingly buggy for all its simplicity :p

I know it compiles under the RPi and under OSX (although I've not run it under OSX so it might crash and burn).

https://github.com/TonyHoyle/sdrplay

The readme contains the current bug list and installation notes. It's currently really only ready for developers - I'll produce a binary when it's a tad more stable.
Last edited by TonyHoyle on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

MikeR
Posts: 8
Joined: Sat Jun 06, 2015 7:13 pm
Location: Finland
Contact:

Re: rtl_tcp server

Postby MikeR » Sat Jun 06, 2015 7:40 pm

Hi Tony,
I didn't realise the platform was debian/arm when you posted this to facebook.

I built the code via github on one of my Raspberry PI2's - worked first time !
No errors and currently streaming from the PI2 to GQRX running on OS X -its stable providing
frequency isnt changed too often.

Log below. No idea why it doesn't link on a Fedora box - still investigating that.

Since its in rtl_tcp format, stuff like:-

cat > commandfifo & nc PI2smachineIP < commandfifo | baudline -session sdrplay -stdin -channels 2 -format u8 -quadrature -samplerate 2000000

is possible for very fast (>30 fps) spectral analysis on i7 hardware...

BR
Mike.

Debian Jessie:-
Linux mpi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux

pi@mpi ~/external-source $ git clone https://github.com/TonyHoyle/sdrplay
Cloning into 'sdrplay'...
remote: Counting objects: 84, done.
remote: Compressing objects: 100% (53/53), done.
remote: Total 84 (delta 36), reused 75 (delta 27), pack-reused 0
Unpacking objects: 100% (84/84), done.
Checking connectivity... done.
pi@mpi ~/external-source $ cd sdrplay/
pi@mpi ~/external-source/sdrplay $ mkdir build
pi@mpi ~/external-source/sdrplay $ cd build/
pi@mpi ~/external-source/sdrplay/build $ cmake ..
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/external-source/sdrplay/build
pi@mpi ~/external-source/sdrplay/build $ make
Scanning dependencies of target sdr
[ 25%] Building CXX object CMakeFiles/sdr.dir/main.cpp.o
[ 50%] Building CXX object CMakeFiles/sdr.dir/sdrplay.cpp.o
[ 75%] Building CXX object CMakeFiles/sdr.dir/mySocket.cpp.o
[100%] Building CXX object CMakeFiles/sdr.dir/error.cpp.o
Linking CXX executable sdr
[100%] Built target sdr
pi@mpi ~/external-source/sdrplay/build $
pi@mpi ~/external-source/sdrplay/build $ ls -la
total 72
drwxr-xr-x 3 pi pi 4096 Jun 6 22:08 .
drwxr-xr-x 5 pi pi 4096 Jun 6 22:08 ..
-rw-r--r-- 1 pi pi 11867 Jun 6 22:08 CMakeCache.txt
drwxr-xr-x 5 pi pi 4096 Jun 6 22:08 CMakeFiles
-rw-r--r-- 1 pi pi 1399 Jun 6 22:08 cmake_install.cmake
-rw-r--r-- 1 pi pi 6710 Jun 6 22:08 Makefile
-rwxr-xr-x 1 pi pi 34000 Jun 6 22:08 sdr
pi@mpi ~/external-source/sdrplay/build $ ./sdr
mSampleRate = 2.048000
mFrequency = 14.200000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.048MHz rf=14.200MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1

mir_sdr_2500_Init: revisionId = 0x0200, doing FW update
fwDownload: FW image size = 6008
mir_sdr_usb_USB DLL: Revision 0.1.1

mir_sdr_2500_Init: fnaddr = 2 detected, trying to change...

mir_sdr_2500_Init: fnaddr = 6

mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000005
initHw: Tuner Register0 = 0x04fe10
mir_sdr_SetFs: Sample Freq requested 2047999.978065
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2048000.0+0.0Hz=2048000.0Hz FsToggle->1
mir_sdr_SetRf: f->134200000.000Hz (int=16 frac=44c afc=0) fSynth:2147200000.000
mir_sdr_SetRf: Rf->RfNomHz+dRfHz+LifHz+Lif1Hz=14200000.0+0.0+0.0Hz+120000000.0Hz=134200000.0Hz RfToggle->1
mir_sdr_SetGr: GR->70[46,0,0,24] gRset->0xEE DCCALmode=4 DCCALspd=1 GrToggle->1
setToggleStates: initialising sampNum=0x00020206, gainSetting=0x0ee, FsToggle=0, RfToggle=1, GrToggle=1
setToggleStates: initialising Fs=2047999.978, Rf=134200000.000, Gr=70
mir_sdr_SetDcMode: DCCAL: mode->4 speedup->0
mir_sdr_SetDcTrackTime: DCTRK_TIM->63
Error: USB buffer overflow

mir_sdr_SetFs: Sample Freq requested 2048002.004623
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2048000.0+2.0Hz=2048002.0Hz FsToggle->1
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.000MHz rf=144.500MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1

mir_sdr_2500_Init: fnaddr = 2 detected, trying to change...

mir_sdr_2500_Init: fnaddr = 6

mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000014
initHw: Tuner Register0 = 0x04f440
mir_sdr_SetFs: Sample Freq requested 2000000.000000
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2000000.0+0.0Hz=2000000.0Hz FsToggle->1
mir_sdr_SetRf: f->144500000.000Hz (int=18 frac=fa afc=0) fSynth:2312000000.000
mir_sdr_SetRf: Rf->RfNomHz+dRfHz+LifHz+Lif1Hz=144500000.0+0.0+0.0Hz+0.0Hz=144500000.0Hz RfToggle->1
mir_sdr_SetGr: GR->70[46,24,0,0] gRset->0x22E DCCALmode=4 DCCALspd=1 GrToggle->1
setToggleStates: initialising sampNum=0x00017a02, gainSetting=0x22e, FsToggle=1, RfToggle=0, GrToggle=0
setToggleStates: initialising Fs=2000000.000, Rf=144500000.000, Gr=70
mir_sdr_SetGr: GR->25[25,0,0,0] gRset->0x19 DCCALmode=4 DCCALspd=1 GrToggle->1
mir_sdr_ReadPacket: Gain update confirmed: Gr=25dB GrToggle=1 gset=0x19
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=25dB fs=2.000MHz rf=44.500MHz bw=1.536MHz if=0.000MHz
Last edited by MikeR on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

TonyHoyle
Posts: 13
Joined: Sun May 24, 2015 9:59 pm

Re: rtl_tcp server

Postby TonyHoyle » Sat Jun 06, 2015 8:00 pm

I changed the cmake file to check a couple of different names for the library, which might help with fedora.
Last edited by TonyHoyle on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

MikeR
Posts: 8
Joined: Sat Jun 06, 2015 7:13 pm
Location: Finland
Contact:

Re: rtl_tcp server

Postby MikeR » Sat Jun 06, 2015 8:30 pm

The library names helped - The fedora box builds it now.

-Mike.
Last edited by MikeR on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

MikeR
Posts: 8
Joined: Sat Jun 06, 2015 7:13 pm
Location: Finland
Contact:

Re: rtl_tcp server

Postby MikeR » Sat Jun 06, 2015 8:43 pm

Spoke too soon, ./sdr: error while loading shared libraries: libmirsdrapi-rsp-1.1.so: cannot open shared object file: No such file or directory

On Fedora its:-

lrwxrwxrwx. 1 root root 45 Jun 4 14:20 /usr/local/lib/libmirsdrapi-rsp.so -> /usr/local/lib/libmirsdrapi-rsp-x86_64-1.1.so

Looks like libmirsdrapi-rsp.so is the lib on Fedora without version suffixing.

Making symlink to it solves the problem until the names are harmonised.

$ sudo ln -s libmirsdrapi-rsp.so libmirsdrapi-rsp-1.1.so

$ ./sdr
mSampleRate = 2.048000
mFrequency = 14.200000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.048MHz rf=14.200MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1
Last edited by MikeR on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

MikeR
Posts: 8
Joined: Sat Jun 06, 2015 7:13 pm
Location: Finland
Contact:

Fedora install no go...

Postby MikeR » Sat Jun 06, 2015 8:56 pm

Fedora 20 - The reality is no go....

Package 1:libusb-0.1.5-3.fc20.x86_64 already installed and latest version

[1922355.489406] usb 1-2.3: new high-speed USB device number 28 using xhci_hcd
[1922355.576230] usb 1-2.3: New USB device found, idVendor=1df7, idProduct=2500
[1922355.576235] usb 1-2.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0

$ ./sdr
mSampleRate = 2.048000
mFrequency = 14.200000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.048MHz rf=14.200MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1

Error: libusb_open() -3

mir_sdr_usb_Init: Timeout expired/failed to establish connection with the device

Trying sudo, bad idea I know...

sudo ./sdr
mSampleRate = 2.048000
mFrequency = 14.200000
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.048MHz rf=14.200MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1

mir_sdr_2500_Init: revisionId = 0x0200, doing FW update
fwDownload: FW image size = 6008

stops here...
[1922645.852824] sdr[6527]: segfault at 1c0 ip 00007fcf7006ae29 sp 00007fcf7005ee00 error 4 in libusb-1.0.so.0.1.0[7fcf70065000+e000]

I suspect "cat /etc/udev/rules.d/66-mirics.rules
SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",ATTRS{idVendor}=="1df7",ATTRS{idproduct}=="2500",MODE:="0666"
"

-Mike.
Last edited by MikeR on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

TonyHoyle
Posts: 13
Joined: Sun May 24, 2015 9:59 pm

Re: rtl_tcp server

Postby TonyHoyle » Sun Jun 07, 2015 2:07 pm

You need at least libusb 1.0.18 to use the SDRPlay.. 0.1.5 sounds ancient - are you sure fedora has nothing newer?
Last edited by TonyHoyle on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

TonyHoyle
Posts: 13
Joined: Sun May 24, 2015 9:59 pm

Re: rtl_tcp server

Postby TonyHoyle » Sun Jun 07, 2015 2:51 pm

The udev instructions supplied didn't work for me either.. Try

SUBSYSTEM=="usb",ENV{DEVTYPE}=="usb_device",ATTRS{idVendor}=="1df7",ATTRS{idProduct}=="2500",MODE:="0666"
Last edited by TonyHoyle on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

TonyHoyle
Posts: 13
Joined: Sun May 24, 2015 9:59 pm

Re: rtl_tcp server

Postby TonyHoyle » Sun Jun 07, 2015 5:19 pm

Ahh I see you used the same udev rule I did.. no idea then..

(Editing on this forum is wierd.. I edited my last post and it vanished..)
Last edited by TonyHoyle on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

MikeR
Posts: 8
Joined: Sat Jun 06, 2015 7:13 pm
Location: Finland
Contact:

Re: rtl_tcp server

Postby MikeR » Sun Jun 07, 2015 7:15 pm

Hi,
I built and installed libusb 1.0.19 to the fedora box. Now its worse than ever for the SDRPlay.

With libusb 1.0.19 it fails to read from the dongle. The old libusb had no problems
with the dongle while using sdr-j-viewer. - Maybe the driver needs re-installing to recognise the
usblib update? - either that or the process just broke libusb on this box - no idea and no time
to continue.

old libusb: sdr-j-viewer worked, sdr/sdrserver failed to read from the dongle.
new 1.0.19 libusb: sdj-viewer fails to read the streams. sdrserver fails to read the stream also.

sudo ./sdrserver -g
mir_sdr_Init: starting hardware initialization
mir_sdr_Init: gR=70dB fs=2.048MHz rf=14.200MHz bw=1.536MHz if=0.000MHz

mir_sdr_usb_USB DLL: Revision 0.1.1

mir_sdr_2500_Init: fnaddr = 2 detected, trying to change...

mir_sdr_2500_Init: fnaddr = 6

mir_sdr_2500_Init: adjusting squelch trim 0x1, rx gating enable 1, tx_trim 0, reg2 = 0x4801
initHw: Register7 = 0x000005
initHw: Tuner Register0 = 0x04fe10
mir_sdr_SetFs: Sample Freq requested 2047999.978065
mir_sdr_SetFs: Fs->FsNomHz+dFsHz=2048000.0+0.0Hz=2048000.0Hz FsToggle->1
mir_sdr_SetRf: f->134200000.000Hz (int=16 frac=44c afc=0) fSynth:2147200000.000
mir_sdr_SetRf: Rf->RfNomHz+dRfHz+LifHz+Lif1Hz=14200000.0+0.0+0.0Hz+120000000.0Hz=134200000.0Hz RfToggle->1
mir_sdr_SetGr: GR->70[46,0,0,24] gRset->0xEE DCCALmode=4 DCCALspd=1 GrToggle->1
mir_sdr_usb_StreamRead: Read failed to read sufficient data: requested 393216 read 0

mir_sdr_2500_StreamRead: Read failed
mir_sdr_usb_StreamRead: Read failed to read sufficient data: requested 393216 read 0

mir_sdr_2500_StreamRead: Read failed again
setToggleStates: failed mir_sdr_2500_StreamRead err=1
initHw: setToggleStates() Error 1
mir_sdr_Init: initState returns error 7
Last edited by MikeR on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason


Return to “Code Corner”

Who is online

Users browsing this forum: No registered users and 2 guests