Reputation: 137
I am doing a project read GPS values output from a GPS dongle and need to programmatically start the gpsd daemon.
i.e. I need to automate the following command; sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
I was able to read the coordinates through the code after manually starting the daemon as above. But don't know how to start the daemon through he code.
Upvotes: 3
Views: 2447
Reputation: 368
Since gpsd is a daemon, you can just set the daemon up to be run automatically at startup. How to do this depends on which startup system you have. For example, if you have systemd, you have to write a gpsd.service file, something like this
[Unit]
Description=GPSd daemon service file
[Service]
Type=forking
User=root
Group=dialout
TimeoutStartSec=0
ExecStart=/usr/local/sbin/gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
[Install]
# Grouping mechanism that let systemd start groups of processes up at the same time
WantedBy=multi-user.target
then install it in /lib/systemd/system
and finally using the following commands
$ sudo systemctl enable gpsd
$ sudo systemctl start gpsd
the start command is just to run gpsd as systemd daemon without rebooting your system.
Upvotes: 3