Autostart OpenCPN on Boot

Since this project’s main intent is to create a dedicated chartplotter/autopilot, it doesn’t make sense that I need to open a terminal window, start the gpsd service, and then double-click the OpenCPN icon on the desktop to get everything up and running. It should all just start up once the RPi boots up, and since it’s simply a Linux computer, this is possible, and really quite easy

First, the gpsd service needs to be started. As mentioned previously, there are a few terminal commands that are used to start the service. I simply created a pearl script in /etc/init.d/  that performs those steps:

#! /bin/sh
# /etc/init.d/startgps
#
### BEGIN INIT INFO
# Provides: 			noip
# Required-Start:		$remote_fs $syslog
# Required-Stop:		$remote_fs $syslog
# Default-Start:		2 3 4 5
# Default-Stop:			0 1 6
# Short-Description:	Simple script to start a program at boot
# Description:			A simple star/stop script
### END INIT INFO

echo 'Starting GPSD'
sudo service gpsd restart
sudo killall gpsd
sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock

exit 0

Then, I registered it to run at startup using the update-rc.d command. After a reboot, I was able to simply open a terminal window and execute xgps successfully, proving that the GPS stream was available.

The next step was to launch OpenCPN. I tried many different ways, but many had difficulties reading the user config settings. The simplest way, that worked great, was to create a launcher and place it in an autostart folder inside /home/pi/.config. The launcher file was already on the desktop, so it was a simple copy/paste process.

And with that, on reboot, OpenCPN launches, and after a minute or two GPS acquires the satellites and the chartplotter portion of the project is complete.

Resources:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: