Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Receptor and Emitter Autostart after boot #81

Open
DL1DMS opened this issue Dec 31, 2021 · 15 comments
Open

Receptor and Emitter Autostart after boot #81

DL1DMS opened this issue Dec 31, 2021 · 15 comments

Comments

@DL1DMS
Copy link

DL1DMS commented Dec 31, 2021

Hello,

I use vban for Amateur radio purposes.... How it is possible to "autostart" vban_emitter and vban_receptor at boot? It works fine by entering the commands by shell but I doesn't run by adding the following lines to the /etc/rc.local

vban_emitter -i 192.168.125.31 -p 6980 -s RX
vban_emitter -i 192.168.125.20 -p 6980 -s RX
vban_receptor -i 192.168.125.31 -p 6980 -s TX
vban_receptor -i 192.168.125.20 -p 6980 -s TX

Probably it's a stupid question but I'm still a greenhorn when it comes to Linux......

Best regards

Manuel

@tilleul
Copy link

tilleul commented Jan 18, 2022

  1. make sure you include the full path to your vban_emitter/receptor
  2. you need to end your commands with "&" (without quotes) to make them run in the background
  3. you possibly want to redirect those programs outputs to /dev/null

So you should have for your first line something like this:

/path/to/vban_emitter -i 192.168.125.31 -p 6980 -s RX >/dev/null &

@DL1DMS
Copy link
Author

DL1DMS commented Jan 20, 2022

Hey Tilleul,

Thanks for ur reply. My commands in /etc/rc.local look like this now.....

(sleep 10
/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null &
/usr/local/bin/vban_receptor -i 192.168.125.20 -p 6980 -s TX >/dev/null
)

But it doesn't work. Even without "(sleep 10" and ")" it doesn't wanna run.
When it open the console and enter both commands it works perfectly.

Any help appreciated. :)

Best regards
Manuel

@tilleul
Copy link

tilleul commented Jan 20, 2022

you should check your logs for error messages ... maybe the network is not ready ?

Also your second line also needs a final "&" to make it run in the background (but it won't solve your current problem)

@DL1DMS
Copy link
Author

DL1DMS commented Jan 20, 2022

Hello Tilleul,

thanks again for ur quick reply. Thanks for the hint with the "&". I think my network should be ready after 10 seconds but I'm not sure. Don't know how to enter the log files. First I tried the same stuff (using an amateur radio device by network) with mumble which was starting up and working after a delay of 10 seconds. But since I haven't had a possibility to control the audio levels (it was not possible to disable AGC) I now use VBAN which works just the way I want. Just the autostart doesn't work.

Best regards
Manuel

@tilleul
Copy link

tilleul commented Jan 21, 2022

Depending on your linux distro, check

journalctl

or probably the logs are in /var/log (lots of files in there)

@DL1DMS
Copy link
Author

DL1DMS commented Jan 21, 2022

Good morning,

didn't know the linux distribution makes a difference. I got Raspberry PI OS running. I'll try to check the logs and let u know. :)

Best regards

Manuel

@NeroBurner
Copy link
Contributor

NeroBurner commented Jan 21, 2022

Raspberry PI OS uses systemd as init-daemon (the first process, that starts all the other processes). I recommend to try to create a systemd-service for the startup-commands vban-emitter and receptor (I suggest one service per command)

https://www.raspberrypi.com/documentation/computers/using_linux.html#creating-a-service

One nice thing (among many others) about systemd services is, that you can explicitly state, that the service starts after the network is up (After=network.target)

edit: because it's not mentioned in the linked documentation: you can check the status (running and log output) with systemctl status name-of-your-service.service

@DL1DMS
Copy link
Author

DL1DMS commented Mar 23, 2022

Hello again,
sorry foy the long delay. I had much work and a deathcase in my family. Now I can focus on the boot problem again.
I created the following file:

/etc/systemd/system/vban-emitter-start.service

Content of the file:

[Unit]
Description=VBA-EMITTER-START
After=network.target

[Service]
ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null &
WorkingDirectory=
StandardOutput=null
StandardError=inherit
Restart=always
user=

[Install]
WantedBy=multi-user.target

(There's also a file for receptor looking almost the same except of the 2 lines which are "Description=VBA-EMITTER-START" and "ExecStart=/usr/local/bin/vban_receptor -i 192.168.125.20 -p 6980 -s TV >/dev/null &" but I wanna keep it simple right now.)

Ok.... I saves the file(s)....
Then I enabled the service (sudo systemctl enable vban-emitter-start.service)
Then I reloaded the daemon (sudo systemctl daemon-reload)
Then I started the service (sudo systemctl stop vban-emitter-start.service)
...and then I checked if the service is running properly..... but then I get an error message......again and again.

● vban-emitter-start.service - VBAN-EMITTER-START
     Loaded: loaded (/etc/systemd/system/vban-emitter-start.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2022-03-23 19:57:47 CET; 4s ago
    Process: 1573 ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX >/dev/null & (code=exited, status=254)
   Main PID: 1573 (code=exited, status=254)
        CPU: 67ms

Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Scheduled restart job, restart counter is at 5.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: Stopped VBAN-EMITTER-START.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Start request repeated too quickly.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Failed with result 'exit-code'.
Mär 23 19:57:47 YAESU-FT-DX10 systemd[1]: Failed to start VBAN-EMITTER-START.

I tried to reboot the raspberry, I tried to enter different users (su, pi) un the "user"-line but that didn't help either.
I don't know what to do and how to solve the problem. Anyone has an idea?

Saludos
Manuel

@NeroBurner
Copy link
Contributor

try to drop the redirection part >/dev/null & of the exec command. I think that isn't supported

@DL1DMS
Copy link
Author

DL1DMS commented Mar 24, 2022

Hello,

I dropped it... but then I keep gettin' the same error I think.....

● vban-emitter-start.service - VBAN-EMITTER-START
Loaded: loaded (/etc/systemd/system/vban-emitter-start.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2022-03-23 20:22:30 CET; 7s ago
Process: 1697 ExecStart=/usr/local/bin/vban_emitter -i 192.168.125.20 -p 6980 -s RX (code=exited, status=254)
Main PID: 1697 (code=exited, status=254)
CPU: 59ms

Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Scheduled restart job, restart counter is at 5.
Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: Stopped VBAN-EMITTER-START.
Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Start request repeated too quickly.
Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: vban-emitter-start.service: Failed with result 'exit-code'.
Mär 23 20:22:30 YAESU-FT-DX10 systemd[1]: Failed to start VBAN-EMITTER-START.

Saludos

Manuel

@NeroBurner
Copy link
Contributor

maybe the script starts too early. Does it work if you start the service by hand when you're having network connectivity? If that is working, then try to depend on the systemd-networkd-wait-online.service target instead of the multi-user target

https://www.freedesktop.org/software/systemd/man/systemd-networkd-wait-online.service.html

@DL1DMS
Copy link
Author

DL1DMS commented Mar 26, 2022

Hey NeroBurner,

thanks for u r reply. It frankly doesn't. At the moment I still always try to start the service by hand... If that would work I would implement it to start automatically. But right now I just get this error message.
I have no idea what could be wrong. :(
Best regards
Manuel

@NeroBurner
Copy link
Contributor

maybe the system unit doesn't have the environment variables set to connect to the pulseaudio server. Maybe try to look into that

@alterNERDtive
Copy link

After=network.target

Well, how about your sound system?

Either require sound.target or w/e does your sound, in my case pipewire-pulse.service. I also have it bound to the latter so it restarts when that restarts.

@Wright4i
Copy link

@DL1DMS Apologies for posting years later, but I stumbled across this issue and was able to recreate your error message. This comment is mostly for anyone else coming here with a similar issue & desire to setup VBAN as a service.

It was due to an underlying ALSA error that was being masked by your Restart=Always being too fast. If you add RestartSec=3 you should see the real error message when you run sudo systemctl status vban-emitter-start.service

On my machine is was erroring running as a service because it couldn't/wouldn't use the default audio device when running as a service, but when I ran it myself it would work.

The trick here is to determine the audio device aplay -L and then add -d YOUR_DEVICE like -d hw:CARD=K11 to the vban command. That fixed my ALSA error and the service began working.

I've added a Wiki page that hopefully helps someone else: https://github.com/quiniouben/vban/wiki/Quick-Start-Guide-%E2%80%90-VBAN-as-a-service-(Linux)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants