<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi Andrew and others,<br>
<br>
Thanks for the replies on this thread.&nbsp; I actually have my script
mostly working now in the incarnation directly below when I double
click it from the desktop.&nbsp; I haven't gotten around to trying to auto
boot it yet.&nbsp; I could have posted this question on the NTP questions
list at ntp.org, however it was more of a Linux specific thing so I
posted it here.&nbsp; I've been throwing a bunch of other questions at them
anyway.<br>
<br>
Two things were keeping my script from not working at all, which are
now fixed:<br>
<br>
The absence of this line: #!/bin/bash, which I'll probably change to
#!/bin/sh - as Mike W. suggested.&nbsp; I have no idea what this does!&nbsp;
Looks like a comment to me.<br>
<br>
Also, I had quotes around all the commands, which the system didn't
like.<br>
<br>
I posted a thread with this subject yesterday: "how I did Ubuntu + NTPD
+ GPS, but how do I keep it?"&nbsp; All of my saga is described there.&nbsp; In
answer to your question, my GPS is a GlobalSat BU-353 and I'm running
Ubuntu 11.04.<br>
<br>
Like I said, the script is essentially working.&nbsp; It's whole purpose is
to stop NTPD, initialize the USB com port for the GPS, then restart
NTPD.&nbsp; I know that the GPS works once that's done.<br>
<br>
Right now, I'm having a problem that's driving me insane.&nbsp; Here's an
NTPQ printout before running my script.&nbsp; Notice that the computer is
synchronized closely to the time servers and there is no GPS.&nbsp; The top
server is the current clock.<br>
<br>
<tt>ron@asus-k52f-1:/etc$ ntpq -p<br>
&nbsp;&nbsp;&nbsp;&nbsp; remote&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; refid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st t when poll reach&nbsp;&nbsp; delay&nbsp;&nbsp; offset&nbsp;
jitter<br>
==============================================================================<br>
*nist1-ny.ustimi .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp; 118&nbsp; 128&nbsp; 377&nbsp;&nbsp; 54.015&nbsp;&nbsp; -3.923&nbsp;
10.731<br>
-216.119.63.113&nbsp; .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp; 63&nbsp; 128&nbsp; 377&nbsp;&nbsp; 55.535&nbsp;&nbsp;
12.876&nbsp;&nbsp; 3.762<br>
+india.colorado. .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp; 61&nbsp; 128&nbsp; 377&nbsp;&nbsp; 60.914&nbsp;&nbsp;
-7.932&nbsp;&nbsp; 2.995<br>
+ping-audit-207- .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp; 126&nbsp; 128&nbsp; 277&nbsp;&nbsp; 84.008&nbsp;&nbsp;
-6.617&nbsp;&nbsp; 5.344<br>
</tt><br>
Then, I run the script.&nbsp; Here is the NTPQ printout shortly after
running the script:<br>
<br>
<tt>ron@asus-k52f-1:/etc$ ntpq -p<br>
&nbsp;&nbsp;&nbsp;&nbsp; remote&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; refid&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; st t when poll reach&nbsp;&nbsp; delay&nbsp;&nbsp; offset&nbsp;
jitter<br>
==============================================================================<br>
*GPS_NMEA(5)&nbsp;&nbsp;&nbsp;&nbsp; .GPS1.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 l&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp; 8&nbsp; 377&nbsp;&nbsp;&nbsp; 0.000&nbsp; 595.804&nbsp;
88.950<br>
&nbsp;nist1-ny.ustimi .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp; 55.065&nbsp; 570.579&nbsp;
52.070<br>
&nbsp;216.119.63.113&nbsp; .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp; 55.089&nbsp; 594.824&nbsp;
44.885<br>
&nbsp;india.colorado. .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp; 60.848&nbsp; 633.795&nbsp;
63.543<br>
&nbsp;ping-audit-207- .ACTS.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 u&nbsp;&nbsp; 10&nbsp;&nbsp; 64&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp; 85.777&nbsp; 576.470&nbsp;
45.730<br>
</tt><br>
Now, the GPS has appeared, so I know the USB com port is working.&nbsp;
However, now my clock is ~ 500 ms off from ALL the servers including
the GPS.&nbsp; I have the time coming from the GPS fudged so it closely
matches the NIST servers.&nbsp; So, I don't really think this is related to
the GPS, per se, but NTPD is going bonkers or NTPQ is going bonkers.&nbsp;
All I know is I'm going bonkers and I cannot figure out where this
instant offset is coming from.<br>
<br>
On Windows, using a recent version of the Windows port of NTPD from
Dave Hart's website, I can stop the service with it closely
synchronized with either the GPS or the internet servers, tinker with
the configuration, and restart NTPD and it picks up right where it left
off, with almost no additional offset at all.&nbsp; I MAY have seen it do
this once or twice in Windows, but I can't remember for sure.&nbsp; The
restart sequence at the bottom of my script is supposed to clear up the
problem, and that seems to work sometimes when I do it manually.<br>
<br>
I don't know what's going on here.&nbsp; Anybody have any clues?&nbsp; Thanks for
all the help.<br>
<br>
By the way, I'd also like to know how to make my script print things on
the screen as it progresses through.&nbsp; In DOS, I'd use ECHO, but I don't
know the command here.<br>
<br>
Sincerely,<br>
<br>
Ron<br>
<br>
<br>
---------------------------<br>
<br>
Current version of my script file.<br>
<br>
<tt>#!/bin/bash<br>
<br>
# script file to stop ntpd, initialize the usb gps, then restart ntpd<br>
# Ron Frazier - 2012-02-15<br>
<br>
# stop ntpd<br>
sudo /etc/init.d/ntp stop<br>
<br>
# set up the com port<br>
log_daemon_msg "Setting /dev/ttyUSB0 comm parameters."<br>
sudo stty -F /dev/ttyUSB0 57600 igncr clocal -echo -ixon<br>
<br>
# set up link to /dev/gps5<br>
log_daemon_msg "Creating link to /dev/gps5."<br>
sudo ln -T /dev/ttyUSB0 /dev/gps5<br>
<br>
# set the clock<br>
sudo ntpdate -b nist1-ny.ustiming.org<br>
<br>
# start ntpd<br>
sudo /etc/init.d/ntp start<br>
<br>
# wait 5 seconds<br>
sleep 5<br>
<br>
# ---- cycle ntpd again<br>
<br>
# stop and restart ntpd<br>
sudo /etc/init.d/ntp restart<br>
<br>
# wait 5 seconds<br>
sleep 5<br>
</tt><br>
<br>
<br>
On 02/15/2012 07:43 PM, Andrew Wade wrote:
<blockquote
 cite="mid:CACUD18ouZ6As7kmt=ZequY62D6-MoG3Dcqf6=pX1ghJH0pn5dw@mail.gmail.com"
 type="cite">Can you tell us the model of the USB GPS device? &nbsp;I see
some other posts about that same command:&nbsp;
stty -F /dev/ttyUSB0 57600 igncr clocal -echo -ixon&nbsp;
  <div><br>
  </div>
  <div>I want to understand which commands you are using are working or
not (or if you just grabbed them from another source and tried to do
the same thing in a different Linux OS with no luck)</div>
  <div><br>
  </div>
  <div>Also, what Linux are you using?<br>
  <br>
  <div class="gmail_quote">On Wed, Feb 15, 2012 at 5:08 PM, Michael H.
Warfield <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:mhw@wittsend.com">mhw@wittsend.com</a>&gt;</span> wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
    <div class="im">On Wed, 2012-02-15 at 14:24 -0500, Jim Kinney wrote:<br>
&gt; add a line at the very beginning of the file as below:<br>
    <br>
&gt; #!/bin/bash<br>
    <br>
    </div>
#!/bin/sh -<br>
    <br>
If you're not specifically using incompatible bashisms, go with /bin/sh<br>
(which is bash anyways) just as a matter of good practice. &nbsp;Ends up<br>
doing the same thing, just better practice.<br>
    <br>
The following dash ('-') is not NEARLY as important on Linux systems as<br>
it is on other flavors of *NIX because SUID scripts are not allowed, but<br>
it's generally a good idea (BCP) to include that '-' and is generally a<br>
standard practice in most "sh/bash/as/ksh" scripts. &nbsp;There use to be<br>
some old security vulnerabilities on SunOS with SUID scripts where the<br>
'-' was not included, which is where that practice originated.<br>
    <div class="im"><br>
&gt; better choice to have it start automagically is to write a script
modeled<br>
&gt; after the ones in /etc/init.d to set up the gps modem and have
that process<br>
&gt; run before the ntpd is started.<br>
    <br>
    </div>
Concur. &nbsp;Create yourself a nice gps-setup script and link it to<br>
99-gps-setup to take care of those things. &nbsp;Pouring it into rc.local is<br>
an option but not nearly as elegant.<br>
    <br>
Mike<br>
  </blockquote>
  </div>
  </div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 

(PS - If you email me and don't get a quick response, you might want to
call on the phone.  I get about 300 emails per day from alternate energy
mailing lists and such.  I don't always see new messages very quickly.)

Ron Frazier

770-205-9422 (O)   Leave a message.
linuxdude AT c3energy.com
</pre>
</body>
</html>