Difference between revisions of "NTP"

From ArmadeusWiki
Jump to: navigation, search
(Created page with "==Get current Time from Internet== <pre class="apf"> </pre> ==Time synchronisation from GPS== * You will need the "real" NTP daemon, not the Busybox one. * Config file (''/e...")
 
(Time synchronisation from GPS)
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
From https://en.wikipedia.org/wiki/Network_Time_Protocol, ''"Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks."''
 +
Practically, it allows you to have current time/date on your APF even if your don't have an [[RTC]] (you will need an Internet connection or a GPS ;-)).
 +
 
==Get current Time from Internet==
 
==Get current Time from Internet==
 
<pre class="apf">
 
<pre class="apf">
 
+
# ntpd -nqp 217.147.208.1
 
</pre>
 
</pre>
  
 
==Time synchronisation from GPS==
 
==Time synchronisation from GPS==
 +
{| class="wikitable"
 +
|-
 +
! Buildroot !! Debian
 +
|-
 +
|
 
* You will need the "real" NTP daemon, not the Busybox one.
 
* You will need the "real" NTP daemon, not the Busybox one.
* Config file (''/etc/ntpd.conf''):
+
||
 +
<pre class="apf">
 +
root@opos6ul:~# apt-get install ntp
 +
</pre>
 +
|}
 +
 
 +
* Edit/Replace config file (''/etc/ntp.conf'') with:
 
<pre class="apf">
 
<pre class="apf">
 
# Allow only time queries, at a limited rate, sending KoD when in excess.
 
# Allow only time queries, at a limited rate, sending KoD when in excess.
Line 21: Line 35:
 
* ''mode 17'' is for 9600 bauds GPS providing GPRMC frames
 
* ''mode 17'' is for 9600 bauds GPS providing GPRMC frames
  
* To create /dev/gpsX (GPS is connected to UART2):
+
* To create /dev/gpsX (here GPS is connected to UART2):
 
<pre class="apf">
 
<pre class="apf">
 
# ln -sf /dev/ttymxc1 /dev/gps0
 
# ln -sf /dev/ttymxc1 /dev/gps0
 
</pre>
 
</pre>
  
* To launch ntpd:
+
* You can add the previous in ntpd start script (''/etc/init.d/ntp''):
 +
<source lang="diff">
 +
--- /etc/init.d/ntp
 +
+++ /etc/init.d/ntp
 +
@@ -59,6 +59,7 @@
 +
                        exit 1
 +
                fi
 +
                lock_ntpdate
 +
+              ln -sf /dev/ttymxc1 /dev/gps0
 +
                start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE ---startas $DAEMON -- -p $PIDFILE $NTPD_OPTS
 +
                status=$?
 +
                unlock_ntpdate
 +
 
 +
</source>
 +
 
 +
* To launch ntpd (if not automatically launched at startup):
 
<pre class="apf">
 
<pre class="apf">
 
# /usr/sbin/ntpd -g -c /etc/ntp.conf
 
# /usr/sbin/ntpd -g -c /etc/ntp.conf
Line 36: Line 65:
 
[[Category:Time]]
 
[[Category:Time]]
 
[[Category:NTP]]
 
[[Category:NTP]]
 +
[[Category:GPS]]

Latest revision as of 15:19, 31 May 2017

From https://en.wikipedia.org/wiki/Network_Time_Protocol, "Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks." Practically, it allows you to have current time/date on your APF even if your don't have an RTC (you will need an Internet connection or a GPS ;-)).

Get current Time from Internet

# ntpd -nqp 217.147.208.1

Time synchronisation from GPS

Buildroot Debian
  • You will need the "real" NTP daemon, not the Busybox one.
root@opos6ul:~# apt-get install ntp
  • Edit/Replace config file (/etc/ntp.conf) with:
# Allow only time queries, at a limited rate, sending KoD when in excess.
# Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]

server 127.127.20.0 mode 17 minpoll 4 maxpoll 4 prefer
fudge 127.127.20.0 flag3 1 flag2 0 flag1 1 time1 0.0

  • 127.127.20.0 means: "use /dev/gps0 and parse it as NMEA to get time" (See [1]).
  • mode 17 is for 9600 bauds GPS providing GPRMC frames
  • To create /dev/gpsX (here GPS is connected to UART2):
# ln -sf /dev/ttymxc1 /dev/gps0
  • You can add the previous in ntpd start script (/etc/init.d/ntp):
--- /etc/init.d/ntp
+++ /etc/init.d/ntp
@@ -59,6 +59,7 @@
                        exit 1
                fi
                lock_ntpdate
+               ln -sf /dev/ttymxc1 /dev/gps0
                start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE ---startas $DAEMON -- -p $PIDFILE $NTPD_OPTS
                status=$?
                unlock_ntpdate
  • To launch ntpd (if not automatically launched at startup):
# /usr/sbin/ntpd -g -c /etc/ntp.conf

Links