OpenWrt Forum Archive

Topic: GPSd & NTPd not working

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello there,

I wanted to use the attached GPS Mouse of my Fon2100 to get the current time before I fire up my Kismet Server.
So I installed gpsd (2.37) and ntpd (Ver. 4.2.4p6), both via opkg (8.09 RC 2 installed).

I did start gpsd with  gpsd /dev/ttyS0 -D 5 -n -N to see my data and it works. I can connect with cgps to the Fon and see GPS Data (valid one) and time as well - so GPS and stuff works.

I changed the /etc/ntp.conf to

# use a random selection of 8 public stratum 2 servers
# see http://twiki.ntp.org/bin/view/Servers/NTPPoolServers

#restrict default nomodify notrap noquery
#restrict default noquery


restrict 127.0.0.1

driftfile  /tmp/ntp.drift

#server 0.openwrt.pool.ntp.org iburst
#server 1.openwrt.pool.ntp.org iburst
#server 2.openwrt.pool.ntp.org iburst
#server 3.openwrt.pool.ntp.org iburst

server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.035 refid GPS

server 127.127.28.1 minpoll 4 maxpoll 4 prefer
fudge 127.127.28.1 refid GPS1

# GPS(NMEA)+PPS
#server 127.127.20.0 minpoll 4 prefer
#fudge 127.127.20.0 flag3 1 flag2 0

# SMA PPS
#server 127.127.28.0 minpoll 4 prefer
#fudge 127.127.28.0 refid PPS flag3 1

#server 192.168.1.253

started ntpd with ntpd -g

and watch the data with ntpq -p

sadly thats everything:
root@OpenWrt:/etc# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
SHM(0)          .GPS.            0 l    -   16    0    0.000    0.000   0.122
SHM(1)          .GPS1.           0 l    -   16    0    0.000    0.000   0.122


so it seems he doesnt get any time data...

how can i fix that?


Thanks,

DeusEx

I've been fighting with this on and off for a while.

Seems that gpsd will sometimes talk to each other, but not always.  Actually, mostly not.  I have no idea why.

I'm getting good data from gpsd 2.37, I can cat /dev/usb/tts/0 and see good data.

I set up ntpd to use SHM, but I get nothing.  No data flows between gpsd and ntpd.

I've tried using straight nmea at 127.127.20.0 and I see a lot of nmea mesages flying by, but the time never changes.

I'm using ntpd -g -q -x

I'd love to get any suggestions on this.  I need to get this working.

Seems that the problem may have been in the older binaries I was using.  I opkg remove'd ntpd and gpsd and reinstalled from the openwrt repository.

Uncommented the appropriate gps server lines, commented out the server lines in ntp.conf, and it all works.

I did use OpenWRT 8.09 and the new netcat and modified the orginial code posted in this forum - this works now:

        #setup time via gps
        i=0;
        while (i=$(($i+1)) && [ "$i" -lt 5 ]);
        do
        sleep 5
           (echo d ; sleep 1; echo d; sleep 1; echo d) | (nc localhost 2947) > /tmp/gps_time &
           TEST=$!
           sleep 4
        kill -s SIGINT $TEST
        killall nc
        date=$`cat /tmp/gps_time | tail -n 1`
        year=$(echo $date | sed 's/.*D=\([0-9]*\)-.*/\1/')
        [ "$year" -gt 2004 ] && break
        done;
        echo "slept $i times while waiting gps lock.."
       
        echo "Setting date $date"
        date -s $(echo $date | sed 's/GPSD,D=\([0-9]*\)\(.*\):.*/\2\1/' | sed 's/[^0-9]//g')

Hehe.  That's my original code.  :-)

Glad you made it work.  I'll try your version when I get home.  I'm still figting with it.

Apparently the NMEA stuff from the GPS has a lot of jitter and ntpd refuses to use it or something.  I still haven't gotten to the bottom of it.

Ah nice, so it was you! ^-^.
Well I did use it for my pRoToTyPe Project..
( http://www.nico-maas.de.vu/?p=339 )
Seems to be working out quite well.
But I did fight really long on this code piece to get it "really" working - as this is used in my Wardriver to "hold" the complete stuff until an valid GPS Time and therefor valid GPS Lock is set by your script.
Then, kismet is started.
So it was really important to get that thingy working without perl and stuff...
Because correct time on kismet and only firing up as soon as valid data is there - thats the only way to go ;-)...

thanks for writing the orginial code again you really made my day! ^-^

I think your code bricked my router.  :-(  Actually, I suspect that it's my older version of busybox that doesn't like "kill -s SIGNAL" and instead is killing init or some such.

I don't have a serial console, but that's what I think is happening.

Fortunately my config is fairly simple and I can reflash easily.

The adventure never ends.  :-)

Hehe... I just checked out the current snapshot.  It has gpsd 2.90 and a 2.6 kernel, so this may be a good thing....  :-)

(Last edited by cptdondo on 20 Feb 2010, 04:38)

o.o oh.
i'm sorry to hear that!
well the kill thing does give me something like an error like "s" does not exist.
but it does kill the nc process correctly o.o...
i tested that on 8.09rc2 and 8.09 final.  ^^'...

mh...
o.o oh really? does the current 2.90 version of gpsd also work with the 8.09 final of openwrt? O.o
that would be nice.
i think the current 2.3x something is quite buggy... ^^'''....

greetings,

nico

The discussion might have continued from here.