Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


Search this Thread
Old 08-30-2012, 08:26 AM   #1
LQ Newbie
Registered: Jul 2011
Posts: 14

Rep: Reputation: Disabled
How to syncronize GPS-time with CPU clock?

Hello all,

I'm currently working with a seismic acquisition system containing an accelerometer, a TS-7260 single board computer with an embedded UNIX OS, a Sara SADC-20 AD converter and a FV-M7 GPS engine.

The thing is, that I got this system as a present which means I don't have wether readme files nor manuals on it. it was quite a struggle to find out the IP in order to connect via ssh or ftp aswell.

nevertheless, the acquisition starts automaticalls after booting and the digitizer receives the correct time stamp from the gps clock. nevertheless, the cpu clock always resets to 1st january 1970 00:00 which is pretty anoying.

Is it possible to embed a script that boots with the system and syncronizes the cpu clock with the GPS clock? And how do I check the GPS status?

Thanks a lot for your help guys!

Saludos desde Chile!
Old 08-30-2012, 08:57 AM   #2
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,053
Blog Entries: 6

Rep: Reputation: 797Reputation: 797Reputation: 797Reputation: 797Reputation: 797Reputation: 797Reputation: 797
You say UNIX but I'm wondering if you mean Linux?

What do you get from "uname -a" output?

Are you saying the "date" command gives you the correct time because it is synced to GPS? Is this done with ntp?

Does the hwclock command exist? It can be used to put the system time on the hardware clock. Most Linux systems have an init (boot script) that does this automatically during shutdown then they set the system time based on hardware clock during the boot.

Some systems have BIOS settings that tell the clock what to use so you might want to interrupt the boot and go into BIOS to see what, if any settings it offers.

Also the fact that the clock is reverting each time suggests your CMOS battery is defunct. Opening the system and locating this you may be able to find a replacement. (Many of these look like big watch batteries.)

As far as documentation goes. Web searches often help. I found several hits for your system board including this hardware manual:
Old 08-30-2012, 09:33 AM   #3
Registered: Aug 2002
Posts: 12,467

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
BTW that is a heck of a present. Be sure to read the manuals from the link I posted in your other thread.

This should be doable with a shell script but I have not tried it yet. In a nutshell the GPS receiver outputs its data via a serial connection to the SBC. The format of the data is called NEMA V3 with time is embedded in the messages. I would assume that all the start up scripts are in the /etc/init.d with a link to the /etc/rc.d/rc3.d directory. Basically scripts are started in numerical order i.e. S00xxx - S99xxx. You would want your script to run before the logging software starts.

The receiver continuously outputs data so you would need to have a read statement in a loop to capture just the RMC and decode the message. You should be able to set the clock to the nearest second.

PS. MensaWater this is a SBC so no BIOS and no battery backed clock that I am aware of.

Last edited by michaelk; 08-30-2012 at 09:38 AM.
Old 08-31-2012, 08:58 AM   #4
Registered: Aug 2002
Posts: 12,467

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
So I put together a simple script to set time.
sleep 2m
stty -F /dev/ttyAM1 raw ispeed 4800 ospeed 4800 cs8 -ignpar cstopb eol 10 eof 10
until [ "$mess" = "GPRMC" ]; do
  read instr < /dev/ttyAM1
  echo $instr
date $mon$day$hrmin"20"$yr"."$sec
The SBC has 3 serial ports ttyAM0-3, labeled on the board as com1-3 the console is ttyAM0 so I assume the receiver is connected to one of the other ports. Change the stty line to match how the receiver is actually wired. I also didn't put any checks in the loop to see if the receiver was locked on. The receiver should be locked on to at least one satellite in about 30 seconds and worst case a couple of minutes which is why there is the sleep statement. This is all based on your receiver outputting NEMA 0183 data at 4800 BPS.
2 members found this post helpful.
Old 08-31-2012, 11:20 AM   #5
LQ Newbie
Registered: Jul 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hey guys,
thanks a lot for your help I appreciate it a lot!!!!
The Sara SADC-20 AD digitizer gets the time information from a FV-M7 GPS engine with a hooked up antenna.
The "date" command gives me the cpu clock which is reset after each rebbot to 01-01-1970-00:00. This doesn t affect the correct time and date from the GPS in labeling the acquired files. nevertheless it would be nice to have the cpu clock synced with the gps.
If I type in the uname and hwclock command I get this:

$ uname -a
Linux ts7200 2.4.26-ts11 #22 Tue Jun 6 12:23:09 MST 2006 armv4l unknown

$ hwclock
hwclock: Could not access RTC: No such file or directory
Thanks for the code! But the stty command is not supported by the BusyBox v1.0 Linux version. Can I use the tty command instead?

Old 08-31-2012, 11:35 AM   #6
Registered: Aug 2002
Posts: 12,467

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
Sorry about that I was working from the development side which is a full up debian.
I will have to see what else I can do.

In the mean time you can manually set the time via the date command.

Last edited by michaelk; 08-31-2012 at 11:39 AM.
Old 09-07-2012, 01:09 PM   #7
LQ Newbie
Registered: Jul 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
Hey everybody,
thanks for the advice and help. Nevertheless I gave it up, since it costs me too much time, I don't have the knowledge and is not that necessary. So I don't have a solution for it....

Thanks a lot folks.


cpu, gps, syncronization

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
clock-adjustment time is offseet from clock-display time bezdomny Linux - Desktop 2 11-19-2008 02:48 PM
Time clock resetting with more than 2 cpu's boozer_2 Linux - Hardware 4 01-20-2008 12:04 PM
GPS or Atomic Clock for NTPD slacky Linux - Networking 3 12-15-2006 06:13 AM
Various clock issues: Clock shows wrong time only in Knoppmyth, & CMOS time change ? davidbix General 1 04-05-2006 09:58 PM
How to syncronize my system time by public time server? hakansun Linux - Networking 1 09-10-2004 05:10 AM

All times are GMT -5. The time now is 02:11 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration