Skip to content

Linux Service Upgrade

Bennett Lewis edited this page Mar 21, 2020 · 8 revisions

Running important scripts as a systemd service on the raspi

Synopsis

Previously there had been some bash script written to start up the Rover-Controller script. Something went wrong with this so it has been changed to a Linux Service that starts on raspi-boot.

  1. go to /etc/systemd/system
  • cd /etc/systemd/system/
  1. create a service file
  • vim <my_service>.service
  1. Write configuration for your service (see next section)

The Controller service is in charge of creating a connection to the Xbox controller, reading it's input data, modifying, and sending that data via GPIO on the pi to the servos that drive the wheels of the mini rover.

[Unit]
Description=Rover Controlling script

[Service]
Type=simple
Restart=always
RestartSec=10
User=<YOURUSERNAME> # Check we actually need a username...
ExecStart=<Path/To/Controller/Script>

[Install]
WantedBy=multi-user.target

The Temperature service is in charge of connecting to the Arduino running all of our sensors. A Serial connection is made between the raspi and the arduino, the arduino sends a string containing the read data, which the service logs to a csv file.

[Unit]
Description=Temperature Reading And Logging Script

[Service]
Type=simple
Restart=always
RestartSec=10
User=pi
ExecStart=<Path/To/Temperature/Script>

[Install]
WantedBy=multi-user.target

References

Clone this wiki locally