Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

gps datalogging

Sun Oct 06, 2013 6:37 pm

Hi all,
I have finished installing my USB GPS dongle and I'm happy its stable. This took a bit of sorting as it wasn't picking up the dongle on startup, but all sorted now.
So, my plan is for the pi to site on the parcel shelf of my car, and start logging when the pi starts up, ie when I start the ignition. I'm going to power it from a cigarette lighter, so thats the on/off sorted.
I don't need a network connection as I simply want it to log where I've been. I can then upload the files later either using rSync or manual upload.
What I can't seem to get sorted is the logging facility. I want it to log from when the pi is started. How do I do this? I've searched through the forum, but nothing seems to solve the problem. I've written a command into rc.local that is meant to start the logging, but it isn't working.
The commands are:

sudo killall gpsd
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
sudo service ntp restart

gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock
gpxlogger -m -f /home/pi/gpslog'%Y%m%d%H%M'

Can anyone help me solve this simple problem?

P

Carnildo
Posts: 15
Joined: Wed Jan 09, 2013 7:51 am

Re: gps datalogging

Sun Oct 06, 2013 10:26 pm

What isn't working about it? Does replacing your logging command with "gpspipe -w -d -l -o `mktemp --dir /home/pi/XXXXX.gps -u`" (note the backticks) give you a randomly-named file with a load of JSON-formatted lines, similar to

Code: Select all

{"class":"TPV","tag":"RMC","device":"/dev/ttyUSB0","mode":3,"time":"2013-10-06T21:03:55.000Z","ept":0.005,"lat":43.873318333,"lon":-114.585166667,"alt":588.800,"epx":9.460,"epy":11.870,"epv":34.500,"track":148.5000,"speed":0.000,"climb":0.000,"eps":23.74}
If not, what do you get?

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: gps datalogging

Sun Oct 06, 2013 10:56 pm

A) In rc.local you dont need to use "sudo" you are already running as root.

B) Just to be sure, do a "which gpsd" to find where its installed and then use the full path for both the commands and other filenames.

C) if you add ">> /home/pi/test.log" to the end of each command line you should be able to read resultng errors from "/home/pi/test.log", and after it works you can remove this.

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Mon Oct 07, 2013 11:21 am

Hi,
The problem at the moment is that the RPi doesn't start logging when it is switched on. When I start cgps, it finds the satellites quite quickly, and if I manually issue the command, then it begins to log.
I suppose I want to know what I need to change to make it start logging automagically

P

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Mon Oct 07, 2013 8:06 pm

Hi Carnildo

When I input the line you suggest I get a lot of text just as you have shown.

P

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Mon Oct 07, 2013 8:18 pm

topguy wrote:A) In rc.local you dont need to use "sudo" you are already running as root.

B) Just to be sure, do a "which gpsd" to find where its installed and then use the full path for both the commands and other filenames.

C) if you add ">> /home/pi/test.log" to the end of each command line you should be able to read resultng errors from "/home/pi/test.log", and after it works you can remove this.
Hi, the output of the test log is:
<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.1" creator="GPSD 3.6 - http://catb.org/gpsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/1"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1
http://www.topografix.com/GPX/1/1/gpx.xsd">
<metadata>
<time>2013-10-07T20:13:57.000Z</time>
</metadata>
</gpx>

Makes no sense to me thou :P

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: gps datalogging

Mon Oct 07, 2013 9:46 pm

I assume that its the gpxlogger command that does the actual logging. It could be that it starts too soon after gpsd.

You could add "sleep 60" or something between gpsd and gpxlogger.

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Tue Oct 08, 2013 7:43 pm

I tried the sleep 60 command, and no success. I really don't know where to go to next with this. Can anyone help?

Carnildo
Posts: 15
Joined: Wed Jan 09, 2013 7:51 am

Re: gps datalogging

Fri Oct 11, 2013 8:42 am

Does running gpxlogger manually work?

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Fri Oct 11, 2013 9:26 am

If I run the command manually it does work

Carnildo
Posts: 15
Joined: Wed Jan 09, 2013 7:51 am

Re: gps datalogging

Fri Oct 11, 2013 6:41 pm

I've been doing some testing with my own GPS receiver, and I've found the following:

1) gpxlogger will exit if it doesn't get a location message from gpsd in the first five seconds.
2) gpsd will not start sending location messages until the GPS receiver gets a fix, which may take several minutes if the receiver is being cold-started.

My guess is that gpxlogger is being started too soon. Does changing the "sleep 60" to "sleep 1800" (half an hour) fix things?

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Sun Oct 13, 2013 6:17 pm

Hi,
I've been progressing really well with this, but it still isn't exactly as I want it. I have written my 1st script which is:

Code: Select all

#!/bin/bash
echo startup.sh : Launching gps:
sudo killall gpsd
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

sudo service ntp start
sudo gpsd /dev/ttyUSB0 -F /var/run/gpsd.sock

echo startup.sh : Launching gpxlogger:

cgps -s
gpxlogger -f /home/pi/gpslog'%d%m%Y%H%M'
This is then written into a .bash.rc. I did this as opposed to writing it into the rc.local startup script. I am worried about gumming up the startup sequence.

The problem is that it doesn't startup automatically unless I log in through ssh. When I do, it generally works a treat. So, here's the question:
"How do I get this script to run when I switch the pi on and it boots up headless?"

Powerphil
Posts: 72
Joined: Sat Aug 04, 2012 9:36 pm

Re: gps datalogging

Fri Oct 18, 2013 6:34 pm

Can anyone help me with this? I'm hoping to solve it by the weekend

deimosmuc
Posts: 1
Joined: Mon Sep 02, 2019 12:40 pm

Re: gps datalogging

Mon Sep 02, 2019 12:43 pm

Hello
I have the same issue too.
I guess this is similar to this one: https://raspberrypi.stackexchange.com/q ... -cgps-runs

Did someone found a solution in the meantime?
(adding "-e sockets" does not work for me)

Return to “Other projects”