[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82
Jan Luebbe
jluebbe at debian.org
Mon Feb 2 18:52:00 UTC 2009
The following commit has been merged in the master branch:
commit c88301d177ea07565f98dbcae998617781fac784
Author: Jan Luebbe <jluebbe at debian.org>
Date: Tue Jan 20 17:15:05 2009 +0100
otimed: set the system time directly (closes: #318)
diff --git a/framework/subsystems/otimed/clock.py b/framework/subsystems/otimed/clock.py
new file mode 100644
index 0000000..660ff97
--- /dev/null
+++ b/framework/subsystems/otimed/clock.py
@@ -0,0 +1,63 @@
+# -*- coding: UTF-8 -*-
+"""
+Open Time Daemon - Kernel clock interface
+
+(C) 2009 Jan 'Shoragan' Lübbe <jluebbe at lasnet.de>
+(C) 2009 Openmoko, Inc.
+GPLv2 or later
+
+Package: otimed
+Module: clock
+"""
+
+from ctypes import *
+from ctypes.util import find_library
+import math
+
+ADJ_OFFSET = 0x0001
+
+class TIMEVAL(Structure):
+ _fields_ = [
+ ("sec", c_long),
+ ("usec", c_long),
+ ]
+
+class TIMEX(Structure):
+ _fields_ = [
+ ("modes", c_int),
+ ("offset", c_long),
+ ("freq", c_long),
+ ("maxerror", c_long),
+ ("esterror", c_long),
+ ("status", c_int),
+ ("constant", c_long),
+ ("precision", c_long),
+ ("tolerance", c_long),
+ ("time", TIMEVAL),
+ ("tick", c_long),
+
+ ("ppsfreq", c_long),
+ ("jitter", c_long),
+ ("shift", c_int),
+ ("stabil", c_long),
+ ("jitcnt", c_long),
+ ("calcnt", c_long),
+ ("errcnt", c_long),
+ ("stbcnt", c_long),
+
+ ("reserved", c_int32 * 12),
+ ]
+
+libc = CDLL(find_library("c"))
+
+def adjust(delta):
+ tx = TIMEX()
+ print libc.adjtimex(byref(tx))
+ dsec = int(math.floor(delta))
+ dusec = int( (delta - dsec) * 1000000 )
+ usec = tx.time.usec + dusec
+ overflow, usec = divmod( usec, 1000000 )
+ sec = tx.time.sec + dsec + overflow
+ tv = TIMEVAL(sec, usec)
+ print libc.settimeofday(byref(tv), None)
+
diff --git a/framework/subsystems/otimed/otimed.py b/framework/subsystems/otimed/otimed.py
index 651eeb8..8034898 100644
--- a/framework/subsystems/otimed/otimed.py
+++ b/framework/subsystems/otimed/otimed.py
@@ -15,6 +15,8 @@ Module: otimed
__version__ = "0.2.1"
MODULE_NAME = "otimed"
+import clock
+
from datetime import datetime, timedelta
from math import sqrt
import shutil
@@ -220,8 +222,7 @@ class Time( dbus.service.Object ):
for source in self.timesources:
if not source.offset is None:
source.offset = source.offset - d
- t = datetime.utcnow() + d
- getOutput( "date -u -s %s" % t.strftime( "%m%d%H%M%Y.%S" ) )
+ clock.adjust( seconds )
getOutput( "hwclock --systohc" )
# reenable timeout
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list