Black Lives Matter - Action and Equality. ... Adafruit is part of the Stop Hate for Profit campaign. Adafruit is open and shipping.
0

Raspberry Pi GPS Stratum 1 NTP Server
Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Please be positive and constructive with your questions and comments.

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 11:34 am

how to download this? with wget?

I just downloaded chrony, so ntp ist disabled. How can I "close" chrony and enable ntp?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 11:52 am

Tobi2707 wrote:how to download this? with wget?

I just downloaded chrony, so ntp ist disabled. How can I "close" chrony and enable ntp?


Yes, you can use wget if you like, or just visit the page with a browser.

You can do 'service chronyd stop' then 'update-rc.d chronyd disable'. To re-enable ntpd, do 'update-rc.d ntpd enable'

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 11:57 am

Maybe you could tell me the single steps, too fast for me:P
i have the gpsinit now in /home/pi
whats next?

where to create the gpsinit_time.conf? sudo nano ?/gpsinit_time.conf?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 12:03 pm

You can create gpsinit_time.conf also in /home/pi with nano. You shouldn't need to use sudo.

Once you've created the file...

Code: Select all | TOGGLE FULL SIZE
# chmod a+x gpsinit
# ./gpsinit -s 115200 -f gpsinit_time.conf /dev/ttyAMA0
Making sure the unit is in NMEA mode
Making sure the speeds match
GPS and port are now synchronized at 115200
Processing commands...
PMTK314,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
PMTK220,250
Done
#

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 12:12 pm

This is my result:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ chmod a+x gpsinit
pi@raspberrypi ~ $ sudo nano ./gpsinit_time.conf
pi@raspberrypi ~ $ ./gpsinit -s 115200 -f gpsinit_time.conf /dev/ttyAMA0
Making sure the unit is in NMEA mode
Making sure the speeds match
Traceback (most recent call last):
  File "./gpsinit", line 252, in <module>
    sys.exit(main() or 0)
  File "./gpsinit", line 211, in main
    resp = getNMEAResponse(fg, "PMTK001")
  File "./gpsinit", line 66, in getNMEAResponse
    line = fg.readline().strip()
  File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 449, in read
    buf = os.read(self.fd, size-len(read))
OSError: [Errno 11] Resource temporarily unavailable
pi@raspberrypi ~ $


Path to Files:
Code: Select all | TOGGLE FULL SIZE
/home/pi/gpsinit_time.conf
/home/pi/gpsinit


Content of gpsinit_time.conf:
Code: Select all | TOGGLE FULL SIZE
PMTK314,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0

PMTK220,250

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 12:20 pm

Are you sure that gpsd, chronyd and ntpd are all stopped?

If so, just try it a few times. You can also try changing the speed to 57600 and see if that works.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 12:21 pm

Oh Sorry did not stop ntp before running this command, but there is still another error:
Code: Select all | TOGGLE FULL SIZE
Failed to get ACK.
PMTK220,250
Failed to get ACK.
Done


EDIT full message:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ ./gpsinit -s 115200 -f gpsinit_time.conf /dev/ttyAMA0
Making sure the unit is in NMEA mode
Making sure the speeds match
GPS and port are now synchronized at 115200
Processing commands...
PMTK314,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0
Failed to get ACK.
PMTK220,250
Failed to get ACK.
Done
pi@raspberrypi ~ $

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 12:27 pm

Do 'stty -F /dev/ttyAMA0' and 'cat /dev/ttyAMA0' and see what you get...

Code: Select all | TOGGLE FULL SIZE
# stty -F /dev/ttyAMA0
speed 115200 baud; line = 0;
min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
# cat /dev/ttyAMA0
$GPGLL,3999.9961,N,10599.9027,W,160347.500,A,D*4A
$GPRMC,160347.500,A,3999.9961,N,10599.9027,W,0.01,293.36,200315,,,D*74
$GPZDA,160347.500,20,03,2015,,*53
$GPGLL,3999.9961,N,10599.9027,W,160347.750,A,D*4D
$GPRMC,160347.750,A,3999.9961,N,10599.9027,W,0.01,281.65,200315,,,D*76
$GPZDA,160347.750,20,03,2015,,*54
^C


If you get this, change the 'mode 16' in ntp.conf to 'mode 88' and restart ntpd.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 12:32 pm

Output is right:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ stty -F /dev/ttyAMA0
speed 115200 baud; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; start = <undef>; stop = <undef>; susp = <undef>; rprnt = <undef>;
werase = <undef>; lnext = <undef>; flush = <undef>; min = 1; time = 0;
-brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
pi@raspberrypi ~ $ cat /dev/ttyAMA0
$GPGGA,162943.000,5005.4467,N,00902.4970,E,2,08,0.92,141.2,M,48.0,M,0000,0000*6D
$GPGSA,A,3,15,17,14,24,12,22,06,25,,,,,1.20,0.92,0.78*06
$GPRMC,162943.000,A,5005.4467,N,00902.4970,E,0.05,308.16,200315,,,D*6C
$GPVTG,308.16,T,,M,0.05,N,0.10,K,D*30
$GPGGA,162944.000,5005.4467,N,00902.4970,E,2,08,0.92,141.2,M,48.0,M,0000,0000*6A
$GPGSA,A,3,15,17,14,24,12,22,06,25,,,,,1.20,0.92,0.78*06
$GPRMC,162944.000,A,5005.4467,N,00902.4970,E,0.02,264.88,200315,,,D*60
$GPVTG,264.88,T,,M,0.02,N,0.04,K,D*3E


Mode 16 is changed to 88.

and server0 from pool is commented out but i get this output:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo ntpdate -bu 0.debian.pool.ntp.org
20 Mar 17:28:44 ntpdate[2864]: step time server 87.230.95.114 offset -0.100498 sec

Do i have to change something because of this in ntp.conf or can i restart ntp service?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 12:35 pm

That's perfect! The ntpdate command just sets the system clock 1 time.

Yes, just start ntpd.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 12:38 pm

okay, output is:

Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ ntpq -pn
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 127.127.22.0    .PPS0.           1 l    -    8    0    0.000    0.000   0.000
 127.127.20.0    .GPS0.           1 l    -    8    0    0.000    0.000   0.000

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 12:43 pm

And you changed the mode to 88? Hmmm. You should be seeing something. Again, make sure that gpsd and chronyd are stopped. and try again.

You can also stop ntpd and run the stty and cat commands again just to make sure the gps is still in the correct configuration.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 2:25 pm

At first here is my actual ntp. conf:
Code: Select all | TOGGLE FULL SIZE
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift


# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable


# You do need to talk to an NTP server or two (or three).
#server ntp.your-provider.example

# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
# pick a different set every time it starts up.  Please consider joining the
# pool: <http://www.pool.ntp.org/join.html>
#server 0.debian.pool.ntp.org iburst # prefer
#server 1.debian.pool.ntp.org iburst
#server 2.debian.pool.ntp.org iburst
#server 3.debian.pool.ntp.org iburst

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# that might be intended to block requests from certain clients could also end
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient


#PPS and GPS
server 127.127.22.0 minpoll 3 iburst prefer
fudge 127.127.22.0 stratum 1 flag2 0 flag3 1 flag4 0 time1 0.485 refid PPS0

server 127.127.20.0 mode 88 minpoll 3 iburst  prefer
fudge 127.127.20.0 stratum 1 flag1 0 flag2 0 flag3 0 flag4 0 time1 0.560 time2 0 refid GPS0


Here the cat:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ cat /dev/ttyAMA0
$GPGGA,182326.000,5002.1745,N,00902.3163,E,1,08,0.97,102.2,M,48.0,M,,*67

$GPGSA,A,3,25,06,14,31,24,02,12,29,,,,,1.31,0.97,0.88*05

$GPGSV,3,1,10,25,71,294,31,12,63,070,20,29,44,206,23,14,38,265,30*77

$GPGSV,3,2,10,02,34,096,16,24,32,147,15,06,22,048,25,31,21,309,29*78

$GPGSV,3,3,10,03,01,349,,43,,,*43

$GPRMC,182326.000,A,5002.1745,N,00902.3163,E,0.32,124.35,200315,,,A*6B

$GPVTG,124.35,T,,M,0.32,N,0.59,K,A*31

$GPGGA,182327.000,5002.1745,N,00902.3165,E,1,08,0.97,102.2,M,48.0,M,,*60

$GPGSA,A,3,25,06,14,31,24,02,12,29,,,,,1.31,0.97,0.88*05

$GPRMC,182327.000,A,5002.1745,N,00902.3165,E,0.23,115.63,200315,,,A*6D


The tty:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ stty -F /dev/ttyAMA0
speed 115200 baud; line = 0;
intr = <undef>; quit = <undef>; erase = <undef>; kill = <undef>; eof = <undef>; start = <undef>;
stop = <undef>; susp = <undef>; rprnt = <undef>; werase = <undef>; lnext = <undef>; flush = <undef>;
ignbrk -brkint -imaxbel
-opost -onlcr
-isig -iexten -echo -echoe -echok -echoctl -echoke


And the ppstest:
Code: Select all | TOGGLE FULL SIZE
pi@raspberrypi ~ $ sudo ppstest /dev/pps0
trying PPS source "/dev/pps0"
found PPS source "/dev/pps0"
ok, found 1 source(s), now start fetching data...
source 0 - assert 1426869601.706173675, sequence: 195 - clear  0.000000000, sequence: 0
source 0 - assert 1426869602.706186675, sequence: 196 - clear  0.000000000, sequence: 0

There must be a mistake anywhere...

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Re: Raspberry Pi GPS Stratum 1 NTP Server

by gtj on Fri Mar 20, 2015 2:43 pm

Set the time1 parameters to 0.0 for both the GPS and PPS and restart ntpd.

gtj
 
Posts: 109
Joined: Wed Feb 04, 2015 9:11 pm

Re: Raspberry Pi GPS Stratum 1 NTP Server

by Tobi2707 on Fri Mar 20, 2015 2:58 pm

still same problem...
That's very mysterious... Everything GPS and PPS is working but in ntp nothing happens.

The ntp.conf is right?

Did you read the document i wrote? are there all steps right?

Tobi2707
 
Posts: 87
Joined: Thu Mar 12, 2015 8:07 am

Please be positive and constructive with your questions and comments.