Can't send OSC. RPi3 systemd ofxOsc


#1

hi.
I am trying to run oF on RPi3 with systemd.

//USE//
RPi3 raspbian stretch
oF 0.10.0

//PROBLEM//
when make run oF through systemd, oF run ok but can’t send osc.
here are status.

$ sudo systemctl -l status autoSetup
● autoSetup.service - inSetupAuto
   Loaded: loaded (/etc/systemd/system/autoSetup.service; enabled; vendor preset: enabled)
   Active: activating (start) since Wed 2018-12-05 17:17:20 UTC; 39s ago
 Main PID: 391 (Setup.sh)
   CGroup: /system.slice/autoSetup.service
           ├─391 /bin/bash /home/pi/AutoFunc/Setup.sh
           ├─420 sudo make run
           ├─445 make run
           ├─530 /bin/sh -c cd bin;./my_oFprogram
           └─531 ./my_oFprogram

Dec 05 17:17:24 raspberrypi Setup.sh[391]: [notice ] ofAppEGLWindow: setupNativeUDev(): created udev object
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [ error ] ofAppEGLWindow: setupMouse(): did not open mouse
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [ error ] ofAppEGLWindow: setupMouse(): did not open mouse, mouse_fd < 0
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [ error ] ofAppEGLWindow: setupKeyboard(): did not open keyboard
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [ error ] ofAppEGLWindow: setupKeyboard(): did not open keyboard, keyboard_fd < 0
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [notice ] ofAppEGLWindow: setupPeripherals(): native event setup complete
Dec 05 17:17:24 raspberrypi Setup.sh[391]: [ error ] ofxOscSender: couldn't create sender to 169.254.241.30 on port 9000: unable to connect udp socket

and then, kill the oF

$ sudo pkill -f my_oFprogram

and make run again

$ cd ~/openFrameworks/apps/myApps/my_oFprogram
$ sudo make run

can send osc perfectly.
(both oF programs are same programs.)

Does anybody know how to solve this problem?

Here are my codes.

$ sudo nano ~/AutoFunc/Setup.sh
cd /home/pi/openFrameworks/apps/myApps/my_oFprogram
sudo make run
exit
$ sudo  nano /etc/systemd/system/autoSetup.service
[Unit]
Description =inSetupAuto
After=network.target

[Service]
User = pi
Type=oneshot
ExecStart =/home/pi/AutoFunc/Setup.sh
Restart = no

[Install]
WantedBy = multi-user.target

#2

It could be a priority problem, probably the OF app is starting before the network and so it can’t create the socket cause there’s no network yet.

You should specify the priority in the systemd script so the app starts after the network is on, probably even specify some delay if you are using wifi since it might take a while to connect and to make it even safer make the app retry after some seconds if it couldn’t connect on the first try


#3

I used systemd-run as delay.
it works.
Thanks for your advice.