LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   openSUSE Linux NTP server with GPS (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/opensuse-linux-ntp-server-with-gps-824129/)

TB0ne 08-04-2010 09:07 AM

openSUSE Linux NTP server with GPS
 
Current setup is openSUSE 11.2, but should work on other versions as well. Using the 'stock' NTP and GPSD software, available through the repos, you're able to get a stratum-1 clock up and running, for under $100USD.

Get your GPS receiver. Don't get anything fancy...just needs to support NMEA data. Have seen USB connected units for $59USD, and I'm using a Bluetooth GPS receiver that I got for $89.
Connect it to your Linux system, somehow...this will depend on the type of device. A USB device will show up as a serial device, like /dev/ttyUSB0, etc. The Bluetooth device shows up after I bind it with rfcomm, as /dev/rfcomm2. Regardless, connect the thing.
Start the GPSD daemon. I use "gpsd -n -b /dev/rfcomm2", obviously replacing the device name with whatever device you've got. The man pages for GPSD tell you about the options, but the "-n" tells GPSD to poll the device, and 'activate' it. Otherwise, some devices will just sit there, waiting for software to TELL it to do something. The "-b" is for "bluetooth mode", setting it to read-only. Some devices don't like being written to...your mileage may vary.
The GPSD daemon contains a shared memory segment, specifically there to let NTPD talk to it. In your ntp.conf file, put lines similar to this:
Code:

server 127.127.28.0 minpoll 4 maxpoll 4
fudge 127.127.28.0 time1 0.420 refid GPS

The '127.127.28.0' is what you're interested in. The '.28' tells it to use the SHM segment of GPSD, the '.0', says use the first one (since you COULD have multiple GPS devices running...).
Fire up ntpd, usually with "/etc/init.d/ntp start". Check your system logs, and especially your NTP log. You MAY see something like this in your NTP log:
Quote:

SHM shmget (unit 0): Permission denied
If you do, that just means that SELinux is blocking access to the SHM. In the case of openSUSE, run Yast, go into AppArmor, and set NTP to be "complain", rather than "enforce". Restart NTP.

How do you know if it's working? Run "ntpq -p", and you should see something like...
Code:

    remote          refid      st t when poll reach  delay  offset  jitter
==============================================================================
*SHM(0)          .GPS.            0 l    4  16  377    0.000    1.955  58.555

Remote server is the SHM, ID'ed as GPS. A negative offset means that the PC is faster than perfect; a positive offset means that the PC is lagging behind. The negative of this value would be reflected in ntpq -p after the ntpd samples the driver: ntpq's "offset" is described as "the difference between the server system time (which is the time distributed) and the NTP-time (the time steered to the external UTC-traceable clocks)." Reach for the GPS should always be 377: it is eight ones in binary, meaning the latest eight consecutive samples were successful. Let it settle down, and your offset should get better and better. You can see this by doing "ntptrace"...
Code:

localhost: stratum 1, offset -0.031305, synch distance 0.796513, refid 'GPS'
See?? Stratum 1 clock (0 is highest...meaning atomic-clock type accuracy, 16 lowest/untrusted or inaccurate time source). Point everything else on your network to this one system, and enjoy your clock.

mhz_orcl 10-18-2012 12:08 PM

Hi, Your Post really helped me.

Looking for some urgent help, To build a NTP server I have installed Open Suse Linux and plugged in Garmin 18xLVc,5m GPS device with a Searial Cable.

After installed gpsd deamon 3.4 i have followed all required steps to work my gps but I am confused to see its result.

Here is my result:

1) The gpsd is running like :

linux-3s8f:/opt/gpsd-3.4 # gpsd -N -n -D 2 /dev/ttyS0
gpsd:INFO: launching (Version 3.4)
gpsd:INFO: listening on port gpsd
gpsd:INFO: NTPD ntpd_link_activate: 1
gpsd:INFO: stashing device /dev/ttyS0 at slot 0
gpsd:INFO: opening GPS data source type 2 at '/dev/ttyS0'
gpsd:INFO: speed 4800, 8N1
gpsd:INFO: PPS cycle: 691074274, duration: 691074274 @ 1350553157.301474
gpsd:INFO: PPS cycle: 691395220, duration: 320946 @ 1350553157.622420
gpsd:INFO: speed 9600, 8O1
gpsd:INFO: speed 4800, 8N1
gpsd:INFO: gpsd_activate(): activated GPS (fd 5)
gpsd:INFO: device /dev/ttyS0 activated
gpsd:INFO: running with effective group ID 16
gpsd:INFO: running with effective user ID 65534
gpsd:INFO: startup at 2012-10-18T09:39:19.000Z (1350553159)
gpsd:INFO: PPS cycle: 2420985, duration: 100007 @ 1350553159.722459
gpsd:INFO: PPS cycle: 1000017, duration: 900010 @ 1350553160.622469
gpsd:INFO: PPS cycle: 1000022, duration: 100012 @ 1350553160.722481
gpsd:INFO: PPS cycle: 1000025, duration: 900013 @ 1350553161.622494
gpsd:INFO: PPS cycle: 1000010, duration: 99997 @ 1350553161.722491
gpsd:INFO: PPS cycle: 1000015, duration: 900018 @ 1350553162.622509
gpsd:INFO: PPS cycle: 1000021, duration: 100003 @ 1350553162.722512
gpsd:INFO: PPS cycle: 1000015, duration: 900012 @ 1350553163.622524
gpsd:INFO: PPS cycle: 1000015, duration: 100003 @ 1350553163.722527
gpsd:INFO: PPS cycle: 999994, duration: 899991 @ 1350553164.622518
gpsd:INFO: PPS cycle: 1000020, duration: 100029 @ 1350553164.722547
gpsd:INFO: PPS cycle: 1000041, duration: 900012 @ 1350553165.622559
gpsd:INFO: PPS cycle: 1000026, duration: 100014 @ 1350553165.722573


2) I have checked
gpspipe -r

Output:
{"class":"VERSION","release":"3.4","rev":"3.4","proto_major":3,"proto_minor":6}
{"class":"DEVICES","devices":[{"class":"DEVICE","path":"/dev/ttyS0","activated":"2012-10-18T09:33:29.473Z","native":0,"bps":4800,"parity":"N","stopbits":1,"cycle":1.00}]}
{"class":"WATCH","enable":true,"json":false,"nmea":true,"raw":0,"scaled":false,"timing":false}


3)
I have configured /etc/ntp.conf

server 127.127.28.0 minpoll 4
fudge 127.127.28.0 time1 0.535 refid NMEA
server 127.127.28.1 minpoll 4 prefer
fudge 127.127.28.1 refid PPS


Next I have restarted the ntp

/etc/init.d/ntp start


4) To see the result typed

ntpq -p

output:
remote refid st t when poll reach delay offset jitter
==============================================================================
SHM(0) .NMEA. 0 l - 16 0 0.000 0.000 0.000
SHM(1) .PPS. 0 l - 16 0 0.000 0.000 0.000


Note, the offset, jitter is not showing any value?

Please tell me where is the problem? Is my gps device is working? How i can understand?

Any steps i missed or what?

Please help me its really urgent to get a solution, My project is stopped.

Br
mhz_orcl

TB0ne 10-18-2012 01:42 PM

Quote:

Originally Posted by mhz_orcl (Post 4809268)
Hi, Your Post really helped me.
Looking for some urgent help, To build a NTP server I have installed Open Suse Linux and plugged in Garmin 18xLVc,5m GPS device with a Searial Cable.
After installed gpsd deamon 3.4 i have followed all required steps to work my gps but I am confused to see its result.


3)
I have configured /etc/ntp.conf

server 127.127.28.0 minpoll 4
fudge 127.127.28.0 time1 0.535 refid NMEA
server 127.127.28.1 minpoll 4 prefer
fudge 127.127.28.1 refid PPS


Note, the offset, jitter is not showing any value? Please tell me where is the problem? Is my gps device is working? How i can understand? Any steps i missed or what?

Please help me its really urgent to get a solution, My project is stopped.

This is NOT URGENT for anyone here...we volunteer our time, so asking for 'urgent' priority help is fairly rude.

There are a few things that (if you read the initial post), are different. First, the NTP line in your is NMEA, when it should be GPS. Second, have you checked SElinux (as mentioned), to allow NTP to access that shared memory segment?

On a side note, if you're indoors, a GPS signal will be VERY weak, if you can get one at all. Where is your antenna? Have you tried running something like gpsmon, or even minicom on that tty port to see what kind of data you're getting?


All times are GMT -5. The time now is 09:04 AM.