Hello guys, I need to run my program in the background whenever I power my BBB.
BBB has to receive the data whenever It gets an interrupt from STM32. This process should always running in the background. How should I approach?
I have a SPI C code that receives data whenever I execute in the bash. Now it should run in the background based on the interrupt.
Thanks,
Aji Mathew.
Sounds like you want to build a systemd service. You can set it up so that your C app will execute on powerup.
Here’s just an example I googled for: How to create a systemd service in Linux
2 Likes
Hello @Sabeeh_Khan,
If I need to create a service file and run in the background , should the file be in .sh script file ? As I said want to run my C program in the background . How should I approach?
Regards,
Aji Mathew.
I created a service file in the directory /lib/systemd/system as “spi-receive.service”.
[Units]
Description=Receive data from STM32 through SPI
After=multi-user.target
[Service]
ExecStart=/bin/bash /home/nanatom/2spi/exe
Type=simple
[Install]
WantedBy=multi-user.target
Where “exe” is the exe file of the C code to receive the data from the slave. But BBB is not receiving any data from the slave.
when I execute the command
debian@beaglebone:/lib/systemd/system$ sudo systemctl is-active spi-receive.service
failed
debian@beaglebone:/lib/systemd/system$ sudo systemctl status spi-receive.service
● spi-receive.service
Loaded: loaded (/lib/systemd/system/spi-receive.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2023-10-07 19:05:11 UTC; 14min ago
Process: 602 ExecStart=/bin/bash /home/nanatom/2spi/spi.sh (code=exited, status=127)
Main PID: 602 (code=exited, status=127)
Oct 07 19:05:10 beaglebone systemd[1]: Started spi-receive.service.
Oct 07 19:05:10 beaglebone bash[602]: /home/nanatom/2spi/exe: line 1: ./exe: No such file or directory
Oct 07 19:05:11 beaglebone systemd[1]: spi-receive.service: Main process exited, code=exited, status=127/n/a
Oct 07 19:05:11 beaglebone systemd[1]: spi-receive.service: Failed with result ‘exit-code’.
Thanks,
Aji Mathew
that is your problem there.
I have resolved that issue(by adding the complete path of the script file). Now the issue is SPI data reception is not happening even though there is no error with the service file.