Active Topics

 


Reply
Thread Tools
int_ua's Avatar
Posts: 676 | Thanked: 1,067 times | Joined on Jul 2010 @ Kyiv, Ukraine
#1
Main python script, gps_date.py:
Code:
#!/usr/bin/python
import location
import gobject
from sys import stderr


def on_error(control, error, data):
    stderr.write("location error: %d... quitting" % error)
    data.quit()


def on_changed(device, data):
    if not device:
        return

    if device.fix:
        if device.fix[1] & location.GPS_DEVICE_TIME_SET:
            timestamp, accuracy = device.fix[2:4]
            if accuracy == 0:
                print "%d" % timestamp
                data.stop()


def on_stop(control, data):
    data.quit()


def start_location(data):
    data.start()
    return False


method = location.METHOD_USER_SELECTED

loop = gobject.MainLoop()
control = location.GPSDControl.get_default()
device = location.GPSDevice()
control.set_properties(preferred_method=method,
                       preferred_interval=location.INTERVAL_DEFAULT)

control.connect("error-verbose", on_error, loop)
device.connect("changed", on_changed, control)
control.connect("gpsd-stopped", on_stop, loop)

gobject.idle_add(start_location, control)

loop.run()
Bash wrapper, must be executed with su privileges:
Code:
#!/bin/bash
/usr/bin/gnu/date --set "@$(python gps_date.py)"
hwclock -r
hwclock -w
hwclock -r
 

The Following 7 Users Say Thank You to int_ua For This Useful Post:
nokiabot's Avatar
Posts: 1,974 | Thanked: 1,834 times | Joined on Mar 2013 @ india
#2
great been looking for something like this and can you make one which does via wifi ?
as i am tired of putting date on my other n900
 
peterleinchen's Avatar
Posts: 4,118 | Thanked: 8,901 times | Joined on Aug 2010 @ Ruhrgebiet, Germany
#3
@nokiabot
package: ntpd

@int_ua
nice one.
(for me gpsrecorder does that, but now I can do script based)
__________________
SIM-Switcher, automated SIM switching with a Double (Dual) SIM adapter
--
Thank you all for voting me into the Community Council 2014-2016!

Please consider your membership / supporting Maemo e.V. and help to spread this by following/copying this link to your TMO signature:
[MC eV] Maemo Community eV membership application, http://talk.maemo.org/showthread.php?t=94257

editsignature, http://talk.maemo.org/profile.php?do=editsignature
 

The Following 2 Users Say Thank You to peterleinchen For This Useful Post:
Posts: 89 | Thanked: 194 times | Joined on Feb 2010
#4
Would it be easier if ntpd could use the GPS as a clock source?
 
pichlo's Avatar
Posts: 6,447 | Thanked: 20,981 times | Joined on Sep 2012 @ UK
#5
It does! Albeit indirectly. It uses NTP, utilizing GPS as one of the clock sources. Read about the strata in the linked article.
__________________
Русский военный корабль, иди нахуй!
 

The Following 2 Users Say Thank You to pichlo For This Useful Post:
Posts: 89 | Thanked: 194 times | Joined on Feb 2010
#6
Originally Posted by pichlo View Post
It does! Albeit indirectly. It uses NTP, utilizing GPS as one of the clock sources. Read about the strata in the linked article.
Yes, I know that. What I meant is wouldn't it be easier if the ntpd on the n900 used the n900's GPS as a clock source.

Could ntpd clock driver type 20 (127.127.20.x) "Generic NMEA GPS Receiver" talk to the n900's GPS?
 

The Following User Says Thank You to JohnHughes For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 03:59.