How to start gpsd with systemd on opensuse 13.2?

I am migrating an openSuSE 12.1 level system to 13.2. I have a Garmin 18x gps connected via serial cable to serial port that talks to ntpd via shared memory segment. Works good on 12.1.

On opensuse 12.1 there exists an
/etc/init.d/gpsd
script to start/stop/restart gpsd.

On opensuse 13.2, no such script exists because of systemd. I would have expected there to be a provided gpsd.service file, but I see none and there is none listed in the list of files provided for gpsd when viewed in Yast. The Fedora and Arch distros provide a gpsd.service file. Is this an error to omit it for opensuse? There does still exist an " /etc/sysconfig/gpsd" file on 13.2.

A related question is, what is the replacement for the /etc/init.d/setserial script that allowed one to issue setserial commands to serial devices at boot time?

Hi
Not systemd, it uses udev, see the rpm description;


After installing this RPM, gpsd will automatically connect to USB GPSes
when they are plugged in and requires no configuration.

I would guess that you need to enable the udev option in the sysconfig file for it to start on a reboot if it works when you plug the device in.

If it doesn’t start on plugging in to a usb port, you would need to add your device to the rule.

The device is not a USB device, and based upon the description, the sysconfig setting cannot apply. It is a true serial device (DB9 connector) connected always (not hot-plugged) to a serial (aka COM) port of the system. It would seem that udev always sets up a /dev/ttyS0 and /dev/ttyS1 device because they are always present on this motherboard.

The device (/dev/ttyS1 in this case) already exists whether or not a serial device of any sort (modem, gps, other) is plugged into it. It doesn’t make sense to me why udev has to be manipulated for this. But, that’s why I am here asking for guidance.

On Tue 23 Dec 2014 02:56:01 PM CST, eheman wrote:

malcolmlewis;2684753 Wrote:
> Hi
> Not systemd, it uses udev, see the rpm description;
> >
Code:

> >
> After installing this RPM, gpsd will automatically connect to USB
GPSes > when they are plugged in and requires no configuration.
>

> >
> I would guess that you need to enable the udev option in the sysconfig
> file for it to start on a reboot if it works when you plug the device
> in.
>
> If it doesn’t start on plugging in to a usb port, you would need to
> add your device to the rule.

The device is not a USB device, and based upon the description, the
sysconfig setting cannot apply. It is a true serial device (DB9
connector) connected always (not hot-plugged) to a serial (aka COM) port
of the system. It would seem that udev always sets up a /dev/ttyS0 and
/dev/ttyS1 device because they are always present on this motherboard.

The device (/dev/ttyS1 in this case) already exists whether or not a
serial device of any sort (modem, gps, other) is plugged into it. It
doesn’t make sense to me why udev has to be manipulated for this. But,
that’s why I am here asking for guidance.

Hi
Ahh, my bad…

Still possibly udev related, so if you manually start gpsd pointing at
the serial port, the device works as expected?


Cheers Malcolm °¿° LFCS, SUSE Knowledge Partner (Linux Counter #276890)
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.28-4-default
If you find this post helpful and are logged into the web interface,
please show your appreciation and click on the star below… Thanks!

Yes, gpsd starts manually ok.

Since my last visit, I coded up this partial /usr/lib/systemd/system/gpsd.service file based upon the gpsd.service file I found on the web that is supposedly packaged with the other distributions mentioned earlier:


[Unit]
Description=GPS (Global Positioning System) Daemon
#Requires=gpsd.socket


[Service]
EnvironmentFile=-/etc/sysconfig/gpsd
ExecStartPre=/usr/bin/setserial -b /dev/ttyS1 uart 16550A port 0x02f8 irq 3 baud_base 115200 spd_normal skip_test low_latency
ExecStart=/usr/sbin/gpsd $GPSD_OPTIONS /dev/ttyS1

[Install]
WantedBy=multi-user.target
#Also=gpsd.socket

Then:


systemctl  --system daemon-reload
systemctl  start gpsd.service
systemctl status gpsd.service
gpsd.service - GPS (Global Positioning System) Daemon
   Loaded: loaded (/usr/lib/systemd/system/gpsd.service; disabled)
   Active: active (running) since Tue 2014-12-23 17:18:51 EST; 6min ago
  Process: 6662 ExecStartPre=/usr/bin/setserial -b /dev/ttyS1 uart 16550A port 0x02f8 irq 3 baud_base 115200 spd_normal skip_test low_latency (code=exited, status=0/SUCCESS)
 Main PID: 6666 (gpsd)
   CGroup: /system.slice/gpsd.service
           └─6666 /usr/sbin/gpsd -N -b -n /dev/ttyS1

The content of /etc/sysconfig/gpsd


## Path:        Hardware/GPS
## Description: GPS Daemon

## Type:        yesno
## Default:     no
#
# Whether or not to start gpsd automatically on plugin event
#
GPSD_STARTBYUDEV="yes"

## Type:        integer
## Default:     2947
#
# Use different port for the daemon
#
GPSD_PORT=""

## Type:        string
## Default:     ""
#
# Further options to gpsd
#
GPSD_OPTIONS="-N -b -n"

I further had to perform a


aa-complain /usr/sbin/ntpd

So that ntpd and gpsd could share the memory segment.

So, I am closer, but still not complete on getting ntpd and gpsd working together on 13.2.

OOC, why do you need the setserial stuff? Won’t gpsd find the correct baud rate? Or are you trying to accomplish something else?

On 2015-01-14 14:36, rogeroberholtzer wrote:

> OOC, why do you need the setserial stuff? Won’t gpsd find the correct
> baud rate? Or are you trying to accomplish something else?

As far as I remember, serial ports do not autoconfigure; you have to
define the speed. I’m unsure if there is more recent/sophisticated
hardware that autoconfigures.


Cheers / Saludos,

Carlos E. R.
(from 13.1 x86_64 “Bottle” at Telcontar)

gpsd is expressedly capable of figuring out the baud rate unless you have seriously weird hardware hooked up. For me this /usr/lib/systemd/system/gpsd.service seems to do the trick (with many thanks to your crib):


[Unit]
Description=GPS (Global Positioning System) Daemon
#Requires=gpsd.socket

[Service]
EnvironmentFile=-/etc/sysconfig/gpsd
ExecStart=/usr/sbin/gpsd -N -S $GPSD_PORT $GPSD_OPTIONS

[Install]
WantedBy=multi-user.target

And this is my /etc/sysconfig/gpsd:


## Path:        Hardware/GPS
## Description: GPS Daemon

## Type:        yesno
## Default:     no
#
# Whether or not to start gpsd automatically on plugin event
#
GPSD_STARTBYUDEV="no"

## Type:        integer
## Default:     2947
#
# Use different port for the daemon
#
GPSD_PORT="2947"

## Type:        string
## Default:     ""
#
# Further options to gpsd
#
GPSD_OPTIONS="/dev/ttyS0 /dev/ttyS1"

I hard-coded the -N option, since this is required by systemd if used this way and not really a user option.

By the way my next stop is to hook this up to ntpd. From the sounds of it you may already have some experience to pass on… :wink:

Catperson