The content of this article is only the procedure that worked for the time being.
https://qiita.com/takmot/items/987b493afeeada75925f The UDP receiver program of the above article was created with .NET Core and published for Raspberry Pi.
I have placed this application on / home / pi / work / udp / publish / udp_receiver
on the Raspberry Pi. ʻUdp_receiver` is the executable file name.
Create a SystemD Unit file on your PC.
The file name should be ʻudp_receiver.service (
[executable file name] .service`).
The contents are as follows.
[Unit]
Description=UdpRecv
After=network.target
[Service]
User=root
Type=simple
ExecStart=/home/pi/work/udp/publish/udp_receiver
[Install]
WantedBy=multi-user.target
Description
is a name and is optional.
ʻExecStart` specifies the path of the program to be executed.
The rest should be fine.
Transfer the created SystemD Unit file to Raspberry Pi by FTP.
The storage path for the SystemD Unit file will be / etc / systemd / system /
.
Go to sudo mv udp_receiver.service /etc/systemd/system/
etc.
After that, execute the following command. * ʻUdp_receiver` is the executable file name.
sudo systemctl daemon-reload
sudo systemctl enable udp_receiver
Below are the execution results.
sudo systemctl start udp_receiver
Four. Check the operating status of the service
sudo systemctl status udp_receiver
The following is the execution result of sudo systemctl status udp_receiver
.
● udp_receiver.service - UdpRecv
Loaded: loaded (/etc/systemd/system/udp_receiver.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-09-23 16:33:39 JST; 5s ago
Main PID: 1240 (udp_receiver)
Tasks: 8 (limit: 4915)
Memory: 5.1M
CGroup: /system.slice/udp_receiver.service
mq1240 /home/pi/work/udp/publish/udp_receiver
September 23 16:33:39 raspberrypi systemd[1]: Started UdpRecv.
September 23 16:33:40 raspberrypi udp_receiver[1240]: Receive wait
Five. Restart your Raspberry Pi
sudo reboot
sudo ps -x
It started as follows.
Also, this time we have UDP port 8888 open, so check that as well.
sudo lsof -i:8888
Below are the results.
sudo systemctl stop udp_receiver
sudo systemctl disable udp_receiver
For the SystemD Unit file above The execution position of the program is "/".
In the case of a web application, there are js files and css files linked to html, If you specify them as relative paths Since the program goes to see the relative path from "/", there is no file and an error occurs. You can check for errors in this area with your browser's developer tools.
To resolve this issue, modify the SystemD Unit file as follows:
[Unit]
Description=UdpRecv
After=network.target
[Service]
User=root
Type=simple
WorkingDirectory=/home/pi/work/udp/publish #add to
ExecStart=/home/pi/work/udp/publish/udp_receiver
[Install]
WantedBy=multi-user.target
https://qiita.com/KEINOS/items/f3e6b3064b0cbe35fd03 https://tomosoft.jp/design/?p=11697
Recommended Posts