From 5c8843d5fb080c196c0d9dfcfeb526afa3cba23d Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 21 Aug 2012 16:22:31 -0400 Subject: Teach ntpd how to get its time from a local GPS on serial. --- usr/local/www/services_ntpd.php | 35 ++++++++++++++++++++++++++++++++--- usr/local/www/status_ntpd.php | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 3 deletions(-) (limited to 'usr/local/www') diff --git a/usr/local/www/services_ntpd.php b/usr/local/www/services_ntpd.php index 0cbaf2a..1aa53fb 100644 --- a/usr/local/www/services_ntpd.php +++ b/usr/local/www/services_ntpd.php @@ -59,6 +59,11 @@ if ($_POST) { elseif (isset($config['ntpd']['interface'])) unset($config['ntpd']['interface']); + if (!empty($_POST['gpsport']) && file_exists('/dev/'.$_POST['gpsport'])) + $config['ntpd']['gpsport'] = $_POST['gpsport']; + else + unset($config['ntpd']['gpsport']); + write_config("Updated NTP Server Settings"); $retval = 0; @@ -110,12 +115,36 @@ include("head.inc"); echo ">{$ifacename}\n"; } ?> -
Interfaces without an IP address will not be shown.
-
Selecting no interfaces will listen on all interfaces with a wildcard. -
Selecting all interfaces will explicitly listen on only the interfaces/IPs specified. +
+
+
+
+ + + + + + + Serial GPS + + +
+
+
+
+
+
General"); ?> +   diff --git a/usr/local/www/status_ntpd.php b/usr/local/www/status_ntpd.php index 9aa6039..2b9ac72 100644 --- a/usr/local/www/status_ntpd.php +++ b/usr/local/www/status_ntpd.php @@ -43,6 +43,7 @@ require_once("guiconfig.inc"); exec("/usr/local/bin/ntpq -pn | /usr/bin/tail +3", $ntpq_output); + $ntpq_servers = array(); foreach ($ntpq_output as $line) { $server = array(); @@ -91,6 +92,20 @@ foreach ($ntpq_output as $line) { $ntpq_servers[] = $server; } +exec("/usr/local/bin/ntpq -c clockvar", $ntpq_clockvar_output); +foreach ($ntpq_clockvar_output as $line) { + if (substr($line, 0, 9) == "timecode=") { + $tmp = explode('"', $line); + $tmp = $tmp[1]; + if (substr($tmp, 0, 6) == '$GPRMC') { + $gps_vars = explode(",", $tmp); + $gps_ok = ($gps_vars[2] == "A"); + $gps_lat = $gps_vars[3] / 100.0 . $gps_vars[4]; + $gps_lon = $gps_vars[5] / 100.0 . $gps_vars[6]; + } + } +} + $pgtitle = array(gettext("Status"),gettext("NTP")); $shortcut_section = "ntp"; include("head.inc"); @@ -163,6 +178,25 @@ include("head.inc"); + + + + + + + + + + + + + + + + + +
Google Maps Link
+ -- cgit v1.1