gpsd-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-users] Control Gpsd


From: bruno suarez
Subject: Re: [gpsd-users] Control Gpsd
Date: Tue, 15 Mar 2016 23:42:48 +0100
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

One solution  (?) :

To control the operation of GPS and the GPS receiver, I thought about using GPSPIPE in a script but it seems that there was no timeout with.
So, by combining commands timeout and gpspipe this should work:
Eg:
$ timeout 20s gpspipe -r -n 10
$ echo $?
return 124 if timeout
otherwise 0

Bruno

Le 15/03/2016 19:42, bruno suarez a écrit :
no, but watchdog verifies that the process whose number is in the PID file still exists,
 so it amounts to the same as the script that you gave, right?

Bruno
Le 15/03/2016 19:09, Alexander Carver a écrit :
There's no guarantee that the PID file will go away if gpsd stops.

On 2016-03-15 10:59, bruno suarez wrote:
Another solution without programming is to use watchdog and monitoring
the pid file of gpsd

This works for me, if gpsd stops the system reboot

Bruno

Le 15/03/2016 18:01, bruno suarez a écrit :
Thanks for the help.
This is a good start for me ...
I'll try this, I think in the script (cron) I will restart Pi directly
because if there is a problem it may be the receiver or other items

Bruno

Le 15/03/2016 17:01, Alexander Carver a écrit :
I can't really give you an example because there's many ways of doing
it. It's all up to the programming languages you are most familiar with (and those that run on the Raspberry Pi). It's also not exactly a one or two line script although there are some very rough ways of doing it
in a small script, they're not very robust.

But in general you need to write a small program that connects to gpsd,
sends the WATCH command so that data streams from the attached GPS
receiver and then detect if that data stops flowing (because gpsd
crashed) or the data isn't updating (because the GPS receiver failed or disconnected). In that case you send a system call to kill the PID of
the gpsd process then start a new copy.


The small script version would be something like (this is completely
untested, don't use it)

#!/bin/bash
GPSDPID=$(ps ax | grep gpsd | grep -v grep | awk '{print $1}')
GPSDSTATE=$(ps ax | grep gpsd | grep -v grep | awk '{print $3}'
GPSDCMD="/path/to/gpsd --with-parameters"
if [ "$GPSDSTATE" == 'Z' ] || [ -z "$GPSDPID" ];
then
     echo 'gpsd is a zombie or it's completely missing, kill it'
     if [ -n "$GPSDPID" ];
     then
         kill -KILL $GPSDPID
         sleep 1
     fi

     $GPSDCMD
fi

Basically that script would look at the process list to see if gpsd was there, pull out the PID and the state and then see if the state is a Z (zombie process) or an empty string (the -z) in which case it died and needs to be restarted. This is a bad script because it can't catch many
problems that might leave gpsd running but not really functioning.

You are better off using something else to connect directly to gpsd's
TCP port and taking action if the data isn't there, the port closes or
some other detail you don't like.


On 2016-03-14 23:51, bruno suarez wrote:
Hello,

Thank you for the reply and the idea of chemical heat packs.
The watchdog is expected.

On monitoring GPSD, ok for the principle, but a sample script would
help
me (I am not a man of script!).


Thank you for your answers and tips
cordially
Bruno

Le 15/03/2016 07:36, Alexander Carver a écrit :
On 2016-03-14 12:06, bruno suarez wrote:
Hello,
For a stratospheric balloon project, I usea raspberry Rasbian
Jessie and
a USB GPS receiver.

Everything is OK with gpsd and my GPS receiver.
When I plug everything works correctly, gpsd start on the correct
port
/dev/ttyUSB0.

However, I want to make sure that everything works properly during
2/3
hours to extremely cold temperature

What is the easiest way to automatically control the operation of
GPSD
and relaunch it(on the same port detected ) if it is stopped or if
it is
in error.

Thank you for your answers and tips

Cordially
Bruno
First, pack your payload with heaters.  You can use chemical heat
packs
from a pharmacy that are normally used for heating muscles and joints
(these are the plastic bags that you smash to mix the chemicals and
they
get warm.)  In an insulated container you should stay within your
operating limits of the Pi (the lower limit is approximately -20
Celsius).

After that, just set up a script that watches for data coming from
gpsd
and, if there is no data, issue a kill for the PID of gpsd and restart it. Since gpsd can support more than one connection you can get data
for your recording/telemetry program and have a completely separate
program running to watch for a loss of communication.

Also make sure to enable the watchdog timer in the Pi so that it will
reboot if the whole system fails.  Make sure gpsd will start at
boot as
well as your data logging/telemetry program and the monitoring script.












reply via email to

[Prev in Thread] Current Thread [Next in Thread]