RPi 3 & RTL-SDR/OP25?

Status
Not open for further replies.

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
I'm a ham radio operator and I'm trying to figure out how to use rx.py output to Wireshark (OP25). I want to see the packet stream.

I am also using a Raspberry Pi3.

So far, I can get the rx.py to run but can't figure out how to monitor the packets in Wireshark.

Any help apprecaited
The wireshark patches are out of date and not being actively developed at present. You can however see some protocol by turning the log level up (-v 10).
 

falcongsr

Newbie
Joined
May 14, 2011
Messages
4
Reaction score
0
Hello. This is awesome.

I just got my Pi 3B+ set up. One of the things I prefer to do is to stream audio over mp3 to my phone. I'm sharing how I am doing this here in case it helps someone and maybe someone can suggest a simpler method for doing this.

How I stream mp3 audio from a Pi with other (non-SDR) radios.
- add a USB sound card to the Pi
- connect the audio out of the radio to the input of the sound card
- use VLC to encode the mp3 and serve the stream.

The VLC stream can be played directly by the phone in a browser or with the VLC client on the phone. With the VLC client you can adjust the latency and keep it low even streaming over the internet.

For op25 I have added a USB sound card (Behringer UCA222) and I send the decoded audio out of this device and then wrap it back into the inputs with an RCA cable physically connecting the outputs to the inputs.

For sending the audio out, the -U command is causing heavy stuttering and is completely unusable. This was also the case with the default sound card on the Pi (the headphone jack). So instead I am using netcat | aplay which works OK for either the headphone jack or the USB sound card.

./rx.py setup for netcat | aplay : -w -W 127.0.0.1 -u 56122

netcat | command for USB sound card: nc -kluvw 1 127.0.0.1 56122 | aplay -c1 -f S16_LE -r 8000 -D plughw:CARD=CODEC,DEV=0
(I used aplay -L to get the -D information)

vlc command: cvlc -vvv pulse://alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo --sout '#transcode{acodec=mp3,ab=48,channels=1}:standard{access=http,dst=0.0.0.0:1234/audio.mp3}'
(used pacmd list-sources to get the pulse:// information)

Listen to the mp3 stream use "Pi_IP_Address:1234/audio.mp3" in a browser, or for the VLC client you'll need to specify http:// in front of the string.

My questions:

- Is there a better way to send audio to the sound card other than netcat | aplay? Like I said -U stuttering heavily so I'm not sure if it handles underruns better than netcat | aplay. I assume I'm losing some audio because of underruns. The op25 documentation mentions an "audio.sh" but I cannot find it.

- It would be great to get rid of the sound card obviously. In the past I had lots of trouble streaming rtl_fm streams because of the squelch causing the stream data to stop. boatbod's posts seem to suggest this is being handled cleanly for op25 so there might be a way to send audio info to VLC without having to use extra hardware.

Thank you for all of the contributions and helpful discussions.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
Hello. This is awesome.

I just got my Pi 3B+ set up. One of the things I prefer to do is to stream audio over mp3 to my phone. I'm sharing how I am doing this here in case it helps someone and maybe someone can suggest a simpler method for doing this.

How I stream mp3 audio from a Pi with other (non-SDR) radios.
- add a USB sound card to the Pi
- connect the audio out of the radio to the input of the sound card
- use VLC to encode the mp3 and serve the stream.

The VLC stream can be played directly by the phone in a browser or with the VLC client on the phone. With the VLC client you can adjust the latency and keep it low even streaming over the internet.

For op25 I have added a USB sound card (Behringer UCA222) and I send the decoded audio out of this device and then wrap it back into the inputs with an RCA cable physically connecting the outputs to the inputs.

For sending the audio out, the -U command is causing heavy stuttering and is completely unusable. This was also the case with the default sound card on the Pi (the headphone jack). So instead I am using netcat | aplay which works OK for either the headphone jack or the USB sound card.

./rx.py setup for netcat | aplay : -w -W 127.0.0.1 -u 56122

netcat | command for USB sound card: nc -kluvw 1 127.0.0.1 56122 | aplay -c1 -f S16_LE -r 8000 -D plughw:CARD=CODEC,DEV=0
(I used aplay -L to get the -D information)

vlc command: cvlc -vvv pulse://alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo --sout '#transcode{acodec=mp3,ab=48,channels=1}:standard{access=http,dst=0.0.0.0:1234/audio.mp3}'
(used pacmd list-sources to get the pulse:// information)

Listen to the mp3 stream use "Pi_IP_Address:1234/audio.mp3" in a browser, or for the VLC client you'll need to specify http:// in front of the string.

My questions:

- Is there a better way to send audio to the sound card other than netcat | aplay? Like I said -U stuttering heavily so I'm not sure if it handles underruns better than netcat | aplay. I assume I'm losing some audio because of underruns. The op25 documentation mentions an "audio.sh" but I cannot find it.

- It would be great to get rid of the sound card obviously. In the past I had lots of trouble streaming rtl_fm streams because of the squelch causing the stream data to stop. boatbod's posts seem to suggest this is being handled cleanly for op25 so there might be a way to send audio info to VLC without having to use extra hardware.

Thank you for all of the contributions and helpful discussions.
Whose version of op25 are you using? It makes a difference to how the alsa buffers are assigned and used. Plenty of people use -U but there might be things you need to do to optimize the installation on a pi3. (Reduce the sample rate is the single biggest help)

Have you experimented with loopback driver "aloop"? Two sound cards is definitely not the way I'd attempt to set up a loopback... :)
 

falcongsr

Newbie
Joined
May 14, 2011
Messages
4
Reaction score
0
Whose version of op25 are you using? It makes a difference to how the alsa buffers are assigned and used. Plenty of people use -U but there might be things you need to do to optimize the installation on a pi3. (Reduce the sample rate is the single biggest help)



Have you experimented with loopback driver "aloop"? Two sound cards is definitely not the way I'd attempt to set up a loopback... :)

I'm running your boatbod fork. Do you mean rtl sample rate (-S) or audio rate?

I am not familiar with "aloop". I'll take a look at it also.

I'm only using the one sound card, sending audio to the output and then back to the input. I know there should be a way to do this in software to save the extra digital-analog-digital conversion step. I was just happy to get something working in less than a day.

Every other Pi-based project took weeks of tinkering and learning, but op25 I literally just threw it together and got it working :) thank you.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
I'm running your boatbod fork. Do you mean rtl sample rate (-S) or audio rate?

I am not familiar with "aloop". I'll take a look at it also.

I'm only using the one sound card, sending audio to the output and then back to the input. I know there should be a way to do this in software to save the extra digital-analog-digital conversion step. I was just happy to get something working in less than a day.

Every other Pi-based project took weeks of tinkering and learning, but op25 I literally just threw it together and got it working :) thank you.
The pi3 works best with smaller rf sample rate (-S 370000) because otherwise so much cpu gets eaten up transferring data over the usb bus. You'll have to experiment a bit to find the optimal value that allows for reliable decode with minimal overruns.

Aloop has to be configured and modloaded but it's great for connecting alsa devices for streaming solutions. I use it for darkice.
 

atms169

Member
Joined
Aug 17, 2004
Messages
50
Reaction score
0
Location
Las Vegas, Nevada
The wireshark patches are out of date and not being actively developed at present. You can however see some protocol by turning the log level up (-v 10).

So I see the packet stream but it does not look like the raw data. I can't decipher which is the HDU and LDU packets.
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
So I see the packet stream but it does not look like the raw data. I can't decipher which is the HDU and LDU packets.
It it is what it is.

If you need raw data you can hack the p25 frame assembler code but be warned the data is either in bitstream or dibit form and none of the error correction will have been done yet.

If you want p25 message data you have to dive into either p25p1_fdma or p25p2_tdma
 

NebraskaCoder

Member
Premium Subscriber
Joined
Oct 26, 2016
Messages
325
Reaction score
98
Location
Omaha, NE
What is the best way to find my tuning values like sampling rate, ppm, offset, etc...? It is harder for me to see the ppt graph in detail. It seems multiple different sets of values work. I have an RTL2832U dongle.

Sent from my SM-G965U using Tapatalk
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
What is the best way to find my tuning values like sampling rate, ppm, offset, etc...? It is harder for me to see the ppt graph in detail. It seems multiple different sets of values work. I have an RTL2832U dongle.

Sent from my SM-G965U using Tapatalk
Sample rate can start at 960000 as that value world on any rtl dongle. In practice you may need to lower it later to reduce audio stutter on the rpi3.

ppm (-q) is usually best derived iteratively. Use the fft plot and/or mixer plot to center the control channel signal peak by adjusting ppm up or down. On tcxo dongles you usually only need a ppm value of +/-1 our so.

finetune (-d) is set after ppm to center the mixer peak. If you need fine tune greater than about +/-400 you should consider adjusting ppm again.

ftt plot shows the big picture. When you can no longer see fine enough detail, switch to the mixer plot and aim to get the 'balance' value as close to 0 as possible.
 

NebraskaCoder

Member
Premium Subscriber
Joined
Oct 26, 2016
Messages
325
Reaction score
98
Location
Omaha, NE
This is a perfect write up. Thank you! I will give this a try later here.

Sent from my SM-G965U using Tapatalk
 

falcongsr

Newbie
Joined
May 14, 2011
Messages
4
Reaction score
0
Hello, is there a way to increase the audio gain output of the decoder? I have maxed out audio settings via pulse audio but I still have low volume.

One thing I can do is use sox to add gain to the output before playing it, but I was wondering if there are any controls in rx.py. I see the -g option but it doesn't seem to affect anything.

Thanks!
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
Hello, is there a way to increase the audio gain output of the decoder? I have maxed out audio settings via pulse audio but I still have low volume.

One thing I can do is use sox to add gain to the output before playing it, but I was wondering if there are any controls in rx.py. I see the -g option but it doesn't seem to affect anything.

Thanks!
No, there are no audio gain controls within op25. You may be able to use alsamixer or pavctl to adjust the underlying gain within the os's sound drivers.
 

falcongsr

Newbie
Joined
May 14, 2011
Messages
4
Reaction score
0
Thank you for the quick reply boatbod. I never got aloop working (too busy at work right now), and I am running the op25 audio out to another system right now. I realized the USB sound card I am using has a headphone output with a cheap audio amp and a volume knob, so I will use that and I will have some more adjustable audio gain before sending the audio into my streaming system. (I already maxed out everything in pavucontrol/alsamixer.)

Eventually I will consolidate both of my audio streams onto one system and eliminate the physical sound card routing, but that's a project for another year.

Thanks again.

btw, is there a way to donate to the op25 project / your fork?
 

kb9mwr

Member
Joined
Apr 8, 2003
Messages
280
Reaction score
103
Location
Green Bay, WI
btw, is there a way to donate to the op25 project / your fork?

Max has asked if anyone has a NXDN radio, as that would aide him in adding that support:

https://forums.radioreference.com/d...ital-voice-dmr-dstar-p25-ysf.html#post2960941

Else, osmocom is the foundation behind op25, and a few other interesting Open Source Mobile Communications projects including the RTL-SDR replacement driver:

Osmocom now accepts financial contributions - Miscellaneous Projects - Open Source Mobile Communications
 

ve2cq

Member
Joined
Nov 24, 2011
Messages
35
Reaction score
0
Location
Quebec Canada
Multi_RX.py

Hello, Trying to use multi_rx.py to receive 2 digital modes local ham repeaters; one on DStar at 144,950 MHz, and the other on C4FM Fusion at 147,120 MHz. Since they are 2,17 MHz apart, i figured they should be copied by a RTL-SDR dongle, which is capable of 2,4 MHz bandwidth. Don't know if this is possible, thought.

Using a json file:

{
"channels": [

{
"demod_type": "fsk4",
"destination": "udp://127.0.0.1:56122",
"excess_bw": 0.2,
"filter_type": "gmsk",
"frequency": 144950000,
"if_rate": 24000,
"name": "dstar",
"symbol_rate": 4800
},
{
"demod_type": "fsk4",
"destination": "udp://127.0.0.1:56124",
"excess_bw": 0.2,
"filter_type": "rrc",
"frequency": 147120000,
"if_rate": 24000,
"name": "ysf",
"symbol_rate": 4800
},
],
"devices": [
{
"args": "rtl:0",
"frequency": 146035000,
"gains": "lna:48",
"name": "rtl0",
"offset": 0,
"ppm": 60,
"rate": 1000000,
"tunable": false
}
]
}
_______________

I've set the rtl:0 value at 146,035 MHz, which is right in the middle of both repeaters.

When I try using the command line, i get this error message:

pi@raspberrypi:~/op25/op25/gr-op25_repeater/apps $ python multi_rx.py -c DIGITAL.json -v 9
linux; GNU C++ version 4.9.1; Boost_105500; UHD_003.007.003-0-unknown

Traceback (most recent call last):
File "multi_rx.py", line 216, in <module>
rx = rx_main()
File "multi_rx.py", line 203, in __init__
config = json.loads(open(options.config_file).read())
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
pi@raspberrypi:~/op25/op25/gr-op25_repeater/apps $
_______________

Is what I'm trying to do possible ? Any ideas ?

Thanks
 

N6ML

Member
Joined
Sep 26, 2008
Messages
1,290
Reaction score
499
Hello, Trying to use multi_rx.py to receive 2 digital modes local ham repeaters; one on DStar at 144,950 MHz, and the other on C4FM Fusion at 147,120 MHz. Since they are 2,17 MHz apart, i figured they should be copied by a RTL-SDR dongle, which is capable of 2,4 MHz bandwidth. Don't know if this is possible, thought.

Using a json file:

{
"channels": [

{
"demod_type": "fsk4",
"destination": "udp://127.0.0.1:56122",
"excess_bw": 0.2,
"filter_type": "gmsk",
"frequency": 144950000,
"if_rate": 24000,
"name": "dstar",
"symbol_rate": 4800
},
{
"demod_type": "fsk4",
"destination": "udp://127.0.0.1:56124",
"excess_bw": 0.2,
"filter_type": "rrc",
"frequency": 147120000,
"if_rate": 24000,
"name": "ysf",
"symbol_rate": 4800
},
],
"devices": [
{
"args": "rtl:0",
"frequency": 146035000,
"gains": "lna:48",
"name": "rtl0",
"offset": 0,
"ppm": 60,
"rate": 1000000,
"tunable": false
}
]
}
_______________

I've set the rtl:0 value at 146,035 MHz, which is right in the middle of both repeaters.

When I try using the command line, i get this error message:

pi@raspberrypi:~/op25/op25/gr-op25_repeater/apps $ python multi_rx.py -c DIGITAL.json -v 9
linux; GNU C++ version 4.9.1; Boost_105500; UHD_003.007.003-0-unknown

Traceback (most recent call last):
File "multi_rx.py", line 216, in <module>
rx = rx_main()
File "multi_rx.py", line 203, in __init__
config = json.loads(open(options.config_file).read())
File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
pi@raspberrypi:~/op25/op25/gr-op25_repeater/apps $
_______________

Is what I'm trying to do possible ? Any ideas ?

The error is caused by the comma after the last item in the "channels" list (between the "}" and the "]") - that's not allowed in JSON

I haven't really tried multi-RX, so not sure if it works that way, but fixing that syntax error should get you closer.....
 
Last edited:

ve2cq

Member
Joined
Nov 24, 2011
Messages
35
Reaction score
0
Location
Quebec Canada
Thanks dseven, you nailed it !

Now, this is what I'm getting:

pi@raspberrypi:~/op25/op25/gr-op25_repeater/apps $ python multi_rx.py -c DIGITAL.json -v 9
linux; GNU C++ version 4.9.1; Boost_105500; UHD_003.007.003-0-unknown

device: {'gains': 'lna:48', 'args': 'rtl:0', 'tunable': False, 'rate': 1000000, 'frequency': 146035000, 'ppm': 60, 'offset': 0, 'name': 'rtl0'}
gr-osmosdr 0.1.3 (0.1.3) gnuradio 3.7.5
built-in source types: file osmosdr fcd rtl rtl_tcp uhd miri hackrf bladerf rfspace airspy
Using device #0 Realtek RTL2838UHIDIR SN: 00000001
Found Rafael Micro R820T tuner
Exact sample rate is: 1000000.026491 Hz
* * * Frequency 144950000 not within spectrum band of any device - ignoring!
* * * Frequency 147120000 not within spectrum band of any device - ignoring!
_________________________

Well, guess my intuition was wrong... I tought that since they were 2,17 MHz apart, it would be under the 2,4 MHz bandwidth limit the the RTL-SDR dongle has, seems I was wrong...

If I set the "frequency": 145400000, it seems to be OK with the 144950000, but it ignores the 147120000. HIgher than 145400000, it ignores both

My intention was to make this work at first, then set this up to stream at Broadcastify. Back to square one, I guess.
 

N6ML

Member
Joined
Sep 26, 2008
Messages
1,290
Reaction score
499
If you want to try to cover 2.17MHz, you'll need to set "rate" to something higher than 1000000! Try 2400000 ....
 

ve2cq

Member
Joined
Nov 24, 2011
Messages
35
Reaction score
0
Location
Quebec Canada
If you want to try to cover 2.17MHz, you'll need to set "rate" to something higher than 1000000! Try 2400000 ....

Geez.... what a gross newbie error on my part ... Thanks dseven, works now!

Now, next goal would be to use multi_rx, and combine both signals to one stream.
I've checked Boatbod's instructions in his post about setting things up to stream to Broadcastify, but he uses tx.py, not multi_rx.py.

Guess a loopback audio device combining both streams could be used; anyway with my setup, I think only one signal would be decoded at a time, so combining both frequencies to one stream should be feasible ?

Thanks
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,630
Reaction score
1,025
Location
Talbot Co, MD
Geez.... what a gross newbie error on my part ... Thanks dseven, works now!

Now, next goal would be to use multi_rx, and combine both signals to one stream.
I've checked Boatbod's instructions in his post about setting things up to stream to Broadcastify, but he uses tx.py, not multi_rx.py.

Guess a loopback audio device combining both streams could be used; anyway with my setup, I think only one signal would be decoded at a time, so combining both frequencies to one stream should be feasible ?

Thanks
Theoretically audio.py can be used to make sockaudio.py combine two streams from separate udp ports into L and R channels of a single alsa device.
 
Status
Not open for further replies.
Top