Cannot get op25 to run as a service. Raspberry 4

Status
Not open for further replies.

davcross

Member
Premium Subscriber
Joined
Jun 9, 2016
Messages
17
Reaction score
5
Location
West Chester, Pa
I am trying to stream from op25 to Icecast as a service. I am using a RTL-SDR fob.

Everything runs fine as services except op25. If I run it interactively it works perfectly.

Does anyone see anything wrong with my config?



My service is op25-rx.service

[Unit]
Description=op25-rx
After=syslog.target network.target nss-lookup.target network-online.target
Requires=network-online.target

[Service]
User=1000
Group=1000
WorkingDirectory=/home/pi/op25/op25/gr-op25_repeater/apps
ExecStart=/bin/bash -- op25.sh
RestartSec=5
Restart=on-failure

[Install]
WantedBy=multi-user.target


My op25.sh is

./rx.py --nocrypt --args 'rtl' --gains 'lna:36' -S 960000 -X -M meta.json -l http:192.168.86.42:8080 -q 0 -v 1 -2 -V -T trunk.tsv -q 0 -w 2>stderr.log

My Trunk.tsv is:

"Sysname" "Control Channel List" "Offset" "NAC" "Modulation" "TGID Tags File" "Whitelist" "Blacklist" "Center Frequency"
"P25 SYSTEM" "851.86250" "0" "0xa" "cqpsk" "ccp25.tsv" "fire.tsv" "" ""
 

boatbod

Member
Joined
Mar 3, 2007
Messages
3,714
Reaction score
1,114
Location
Talbot Co, MD
Likely the issue is going to be in the liquidsoap configuration. Are you simultaneously trying to output local sound to pulseaudio as well as stream to icecast? If so, the reasion is that when starting as a service the pulseaudio daemon is not running because it gets started when you log in to the desktop.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,650
Reaction score
184
Location
Massachusetts
Is there a way around this? I have run into the same problem when trying to start TwoToneDetect as a service. TTD requires pulseaudio. Prior to pi4/Buster I could start it as a service, no longer. Could a line be added to the unit file to start the pulse daemon? If so, an example would be great.
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
1,206
Reaction score
462
Location
NE Wisconsin
Is there a way around this? I have run into the same problem when trying to start TwoToneDetect as a service. TTD requires pulseaudio. Prior to pi4/Buster I could start it as a service, no longer. Could a line be added to the unit file to start the pulse daemon? If so, an example would be great.

With the Raspberry Pi-4 (Raspbian Buster) there's no need to use pulseaudio to obtain analog audio output from liquidsoap unless perhaps you're using a USB device that requires pulseaudio support. If this is not the case, then simply use (uncomment) output.alsa(input) and comment out the remaining Local Audio Output choices. Be sure to the bcm2835 Headphones level in alsamixer to a level sufficient to drive your headphones or attached amplified speaker.

However, if your application does require pulseaudio support, then you can get pulseaudio to start at boot time such that both your op25-rx and op25-liq services will start and continue to run. Simply invoke the crontab editor crontab -e then scroll down to the bottom of the existing file and add @reboot pulseaudio --start then save, exit, and reboot the Pi.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,650
Reaction score
184
Location
Massachusetts
Thanks much, I will try the crontab route. As noted, TTD requires pulse, so I have no other option.
 

davcross

Member
Premium Subscriber
Joined
Jun 9, 2016
Messages
17
Reaction score
5
Location
West Chester, Pa
Likely the issue is going to be in the liquidsoap configuration. Are you simultaneously trying to output local sound to pulseaudio as well as stream to icecast? If so, the reasion is that when starting as a service the pulseaudio daemon is not running because it gets started when you log in to the desktop.

Here is my op25.liq config. It runs fine as a service.

#!/usr/bin/liquidsoap
# Example liquidsoap streaming from op25 to icecast
# (c) 2019-2021 gnorbury@bondcar.com, wllmbecks@gmail.com
#
set("log.stdout", false)
set("log.file", true)
set("log.level", 2)

# Make the native sample rate compatible with op25
set("frame.audio.samplerate", 8000)
input = mksafe(input.external(buffer=0.15, channels=2, samplerate=8000, restart_on_error=false, "./audio.py -s -x 2 "))

# Consider increasing the buffer value on slow systems such as RPi3. e.g. buffer=0.25
# Longer buffer results in less choppy audio but at the expense of increased latency.
# OPTIONAL AUDIO SIGNAL PROCESSING BLOCKS
# Uncomment to enable
#
# High pass filter
#input = filter.iir.butterworth.high(frequency = 200.0, order = 4, input)
# Low pass filter
#input = filter.iir.butterworth.low(frequency = 3250.0, order = 4, input)
# Compression
input = compress(input, attack = 2.0, gain = 0.0, knee = 13.0, ratio = 2.0, release = 12.3, threshold = -18.0, rms_window = 1.0)
# Normalization
input = normalize(input, gain_max = 6.0, gain_min = -6.0, target = -16.0, threshold = -65.0)

# LOCAL AUDIO OUTPUT
# Uncomment the appropriate line below to enable local sound
#
# Default audio subsystem
# uncomment next for original
#out (input)
#
# PulseAudio
#output.pulseaudio(input)
#
# ALSA
#output.alsa(input)

# ICECAST STREAMING
# Uncomment to enable output to an icecast server
# Change the "host", "password", and "mount" strings appropriately first!
# For metadata to work properly, the host address given here MUST MATCH the address in op25's meta.json file
#
output.icecast(%mp3(bitrate=16, samplerate=22050, stereo=false), description="op25", genre="Public Safety", url="", fallible=false, icy_metadata="false", host="192.168.86.42", port=8000, mount="op25", password="hackme", mean(input))
 

davcross

Member
Premium Subscriber
Joined
Jun 9, 2016
Messages
17
Reaction score
5
Location
West Chester, Pa
Likely the issue is going to be in the liquidsoap configuration. Are you simultaneously trying to output local sound to pulseaudio as well as stream to icecast? If so, the reasion is that when starting as a service the pulseaudio daemon is not running because it gets started when you log in to the desktop.


No, I am just feeding icecast. It runs fine in a terminal window, just not as a service.
 

wgbecks

Active Member
Joined
Jan 17, 2005
Messages
1,206
Reaction score
462
Location
NE Wisconsin
So, it its op25 that's not running as a service the verify that meta.json has the correct mountpoint, password, and inet address the same as you have configured in your op25.liq script to connect to the icecast server. Alternatively, try temporarily removing the -M meta.json from your rx.py command line as a test to see how that shakes out.

If this doesn't help, then feel free to send me a PM with your email contact and I will reply back with how to reach me whereby I am willing to help over the phone to get this sorted out.

Bill
 
Status
Not open for further replies.
Top