Project

General

Profile

Download (9.17 KB) Statistics
| Branch: | Tag: | Revision:
1 2ebeabac nagyrobi
<?php
2
/* $Id$ */
3
/*
4 29aef6c4 Jim Thompson
        Copyright (C) 2013-2014 Electric Sheep Fencing, LP
5 2ebeabac nagyrobi
	Copyright (C) 2013	Dagorlad
6
	All rights reserved.
7
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
/*
30
	pfSense_MODULE:	ntpd_pps
31
*/
32
33
##|+PRIV
34
##|*IDENT=page-services-ntpd-pps
35
##|*NAME=Services: NTP PPS page
36
##|*DESCR=Allow access to the 'Services: NTP PPS' page..
37
##|*MATCH=services_ntpd_pps.php*
38
##|-PRIV
39
40 b3974c79 Ermal
require_once("guiconfig.inc");
41
42
if (!is_array($config['ntpd']))
43
	$config['ntpd'] = array();
44
if (!is_array($config['ntpd']['pps']))
45
	$config['ntpd']['pps'] = array();
46 2ebeabac nagyrobi
47
if ($_POST) {
48
49
	unset($input_errors);
50
51
	if (!$input_errors) {
52
		if (!empty($_POST['ppsport']) && file_exists('/dev/'.$_POST['ppsport']))
53
			$config['ntpd']['pps']['port'] = $_POST['ppsport'];
54
		/* if port is not set, remove all the pps config */
55
		else unset($config['ntpd']['pps']);
56
57
		if (!empty($_POST['ppsfudge1']))
58
			$config['ntpd']['pps']['fudge1'] = $_POST['ppsfudge1'];
59
		elseif (isset($config['ntpd']['pps']['fudge1']))
60
			unset($config['ntpd']['pps']['fudge1']);
61
62
		if (!empty($_POST['ppsstratum']) && ($_POST['ppsstratum']) < 17 )
63
			$config['ntpd']['pps']['stratum'] = $_POST['ppsstratum'];
64
		elseif (isset($config['ntpd']['pps']['stratum']))
65
			unset($config['ntpd']['pps']['stratum']);
66
67
		if (!empty($_POST['ppsselect']))
68
			$config['ntpd']['pps']['noselect'] = $_POST['ppsselect'];
69
		elseif (isset($config['ntpd']['pps']['noselect']))
70
			unset($config['ntpd']['pps']['noselect']);
71
72
		if (!empty($_POST['ppsflag2']))
73
			$config['ntpd']['pps']['flag2'] = $_POST['ppsflag2'];
74
		elseif (isset($config['ntpd']['pps']['flag2']))
75
			unset($config['ntpd']['pps']['flag2']);
76
77
		if (!empty($_POST['ppsflag3']))
78
			$config['ntpd']['pps']['flag3'] = $_POST['ppsflag3'];
79
		elseif (isset($config['ntpd']['pps']['flag3']))
80
			unset($config['ntpd']['pps']['flag3']);
81
82
		if (!empty($_POST['ppsflag4']))
83
			$config['ntpd']['pps']['flag4'] = $_POST['ppsflag4'];
84
		elseif (isset($config['ntpd']['pps']['flag4']))
85
			unset($config['ntpd']['pps']['flag4']);
86
87
		if (!empty($_POST['ppsrefid']))
88
			$config['ntpd']['pps']['refid'] = $_POST['ppsrefid'];
89
		elseif (isset($config['ntpd']['pps']['refid']))
90
			unset($config['ntpd']['pps']['refid']);
91
			
92
		write_config("Updated NTP PPS Settings");
93
94
		$retval = 0;
95
		$retval = system_ntp_configure();
96
		$savemsg = get_std_save_message($retval);
97
	}
98
}
99
$pconfig = &$config['ntpd']['pps'];
100
101
$pgtitle = array(gettext("Services"),gettext("NTP PPS"));
102
$shortcut_section = "ntp";
103
include("head.inc");
104
?>
105
106
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
107
<?php include("fbegin.inc"); ?>
108
<form action="services_ntpd_pps.php" method="post" name="iform" id="iform">
109
<?php if ($input_errors) print_input_errors($input_errors); ?>
110
<?php if ($savemsg) print_info_box($savemsg); ?>
111
112 32a31f8a Colin Fleming
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="ntpd pps">
113 2ebeabac nagyrobi
  <tr>
114
	<td>
115
<?php
116
	$tab_array = array();
117
	$tab_array[] = array(gettext("NTP"), false, "services_ntpd.php");
118
	$tab_array[] = array(gettext("Serial GPS"), false, "services_ntpd_gps.php");
119
	$tab_array[] = array(gettext("PPS"), true, "services_ntpd_pps.php");
120
	display_top_tabs($tab_array);
121
?>
122
	</td>
123
  </tr>
124
  <tr>
125
	<td>
126
	<div id="mainarea">
127 32a31f8a Colin Fleming
	<table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
128 2ebeabac nagyrobi
		<tr>
129
			<td colspan="2" valign="top" class="listtopic"><?=gettext("NTP PPS Configuration"); ?></td>
130
		</tr>
131
		<tr>
132
			<td width="22%" valign="top" class="vncellreq">
133
			</td>
134
			<td width="78%" class="vtable"><?php echo gettext("Devices with a Pulse Per Second output such as radios that receive a time signal from DCF77 (DE), JJY (JP), MSF (GB) or WWVB (US) may be used as a PPS reference for NTP.");?> 
135
			<?php echo gettext("A serial GPS may also be used, but the serial GPS driver would usually be the better option.");?> 
136
			<?php echo gettext("A PPS signal only provides a reference to the change of a second, so at least one other source to number the seconds is required.");?>
137 8cd558b6 ayvis
			<br />
138
			<br /><strong><?php echo gettext("Note");?>:</strong> <?php echo gettext("At least 3 additional time sources should be configured under"); ?> <a href="services_ntpd.php"><?php echo gettext("Services > NTP"); ?></a> <?php echo gettext("to reliably supply the time of each PPS pulse."); ?>
139 2ebeabac nagyrobi
			</td>
140
		</tr>
141
<?php $serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE); ?>
142
<?php if (!empty($serialports)): ?>
143
		<tr>
144
			<td width="22%" valign="top" class="vncellreq">Serial port</td>
145
			<td width="78%" class="vtable">
146
				<select name="ppsport" class="formselect">
147
					<option value="">none</option>
148
					<?php foreach ($serialports as $port):
149
						$shortport = substr($port,5);
150 32a31f8a Colin Fleming
						$selected = ($shortport == $pconfig['port']) ? " selected=\"selected\"" : "";?>
151 2ebeabac nagyrobi
						<option value="<?php echo $shortport;?>"<?php echo $selected;?>><?php echo $shortport;?></option>
152
					<?php endforeach; ?>
153
				</select>&nbsp;
154
				<?php echo gettext("All serial ports are listed, be sure to pick the port with the PPS source attached."); ?>
155
			</td>
156
		</tr>
157
<?php endif; ?>
158
		<tr>
159
			<td width="22%" valign="top" class="vncellreq">Fudge time</td>
160
			<td width="78%" class="vtable">
161 32a31f8a Colin Fleming
				<input name="ppsfudge1" type="text" class="formfld unknown" id="ppsfudge1" min="-1" max="1" size="20" value="<?=htmlspecialchars($pconfig['fudge1']);?>" />(<?php echo gettext("seconds");?>)<br />
162 2ebeabac nagyrobi
				<?php echo gettext("Fudge time is used to specify the PPS signal offset from the actual second such as the transmission delay between the transmitter and the receiver.");?> (<?php echo gettext("default");?>: 0.0).</td>
163
		</tr>
164
		<tr>
165
			<td width="22%" valign="top" class="vncellreq">Stratum</td>
166
			<td width="78%" class="vtable">
167 32a31f8a Colin Fleming
				<input name="ppsstratum" type="text" class="formfld unknown" id="ppsstratum" max="16" size="20" value="<?=htmlspecialchars($pconfig['stratum']);?>" /><?php echo gettext("(0-16)");?><br />
168 2ebeabac nagyrobi
				<?php echo gettext("This may be used to change the PPS Clock stratum");?> (<?php echo gettext("default");?>: 0). <?php echo gettext("This may be useful if, for some reason, you want ntpd to prefer a different clock and just monitor this source."); ?></td>
169
		</tr>
170
		<tr>
171
			<td width="22%" valign="top" class="vncellreq">Flags</td>
172
			<td width="78%" class="vtable">
173 32a31f8a Colin Fleming
				<table summary="flags">
174 2ebeabac nagyrobi
					<tr>
175
						<td>
176 8cd558b6 ayvis
				<?php echo gettext("Normally there should be no need to change these options from the defaults."); ?><br />
177 2ebeabac nagyrobi
						</td>
178
					</tr>
179
				</table>
180
				<table>
181
					<tr>
182
						<td>
183 32a31f8a Colin Fleming
							<input name="ppsflag2" type="checkbox" class="formcheckbox" id="ppsflag2"<?php if($pconfig['flag2']) echo " checked=\"checked\""; ?> />
184 2ebeabac nagyrobi
						</td>
185
						<td>
186
							<span class="vexpl"><?php echo gettext("Enable falling edge PPS signal processing (default: rising edge)."); ?></span>
187
						</td>
188
					</tr>
189
					<tr>
190
						<td>
191 32a31f8a Colin Fleming
							<input name="ppsflag3" type="checkbox" class="formcheckbox" id="ppsflag3"<?php if($pconfig['flag3']) echo " checked=\"checked\""; ?> />
192 2ebeabac nagyrobi
						</td>
193
						<td>
194
							<span class="vexpl"><?php echo gettext("Enable kernel PPS clock discipline (default: disabled)."); ?></span>
195
						</td>
196
					</tr>
197
					<tr>
198
						<td>
199 32a31f8a Colin Fleming
							<input name="ppsflag4" type="checkbox" class="formcheckbox" id="ppsflag4"<?php if($pconfig['flag4']) echo " checked=\"checked\""; ?> />
200 2ebeabac nagyrobi
						</td>
201
						<td>
202
							<span class="vexpl"><?php echo gettext("Record a timestamp once for each second, useful for constructing Allan deviation plots (default: disabled)."); ?></span>
203
						</td>
204
					</tr>
205
				</table>
206
			</td>
207
		</tr>
208
		<tr>
209
			<td width="22%" valign="top" class="vncellreq">Clock ID</td>
210
			<td width="78%" class="vtable">
211 32a31f8a Colin Fleming
				<input name="ppsrefid" type="text" class="formfld unknown" id="ppsrefid" maxlength= "4" size="20" value="<?php htmlspecialchars($pconfig['refid']);?>" /><?php echo gettext("(1 to 4 charactors)");?><br />
212 2ebeabac nagyrobi
				<?php echo gettext("This may be used to change the PPS Clock ID");?> (<?php echo gettext("default");?>: PPS).</td>
213
		</tr>
214
		<tr>
215
			<td width="22%" valign="top">&nbsp;</td>
216
			<td width="78%">
217 32a31f8a Colin Fleming
			<input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
218 2ebeabac nagyrobi
			</td>
219
		</tr>
220
	</table>
221 32a31f8a Colin Fleming
</div>
222
</td>
223
</tr>
224 2ebeabac nagyrobi
</table>
225
</form>
226
<?php include("fend.inc"); ?>
227
</body>
228
</html>