time warp

Message ID 42BE5F2F.2070201@t-online.de
State New
Headers

Commit Message

Birgit & Andreas Böttger June 26, 2005, 7:54 a.m. UTC
  Udo Richter schrieb:
>>>I use the nice "set system time" feature of vdr.
>>>But sometimes vdr seems to read gabage time from DVB,
> 
> I hereby vote to fix this. I lost a recording today because of time
> errors.

After some tests with other transponders, I currently
use RTL again to set system time, because this is the
most used transponder here.

Sometimes there are "garbage times", but this is no
problem any longer :)

Jun 24 09:25:16 vdr vdr[20898]: diff = 86398, ignored to avoid time warp :)
Jun 24 09:33:38 vdr vdr[20898]: diff = 1047043634, ignored to avoid time warp :)
Jun 24 09:33:47 vdr vdr[20898]: diff = 5038, ignored to avoid time warp :)
Jun 24 09:42:10 vdr vdr[20898]: diff = 49262, ignored to avoid time warp :)
Jun 24 09:50:33 vdr vdr[20898]: diff = 1322, ignored to avoid time warp :)
Jun 24 10:33:29 vdr vdr[20898]: diff = 2843878, ignored to avoid time warp :)
Jun 24 10:33:31 vdr vdr[20898]: diff = 3314218, ignored to avoid time warp :)
Jun 24 10:50:36 vdr vdr[20898]: diff = 1742, ignored to avoid time warp :)
Jun 24 10:58:52 vdr vdr[20898]: diff = 528958, ignored to avoid time warp :)
Jun 24 10:58:56 vdr vdr[20898]: diff = 2132884262, ignored to avoid time warp :)
Jun 24 11:15:47 vdr vdr[20898]: diff = 9461758, ignored to avoid time warp :)
Jun 24 11:24:11 vdr vdr[20898]: diff = 22082, ignored to avoid time warp :)
Jun 24 16:00:54 vdr vdr[11790]: diff = 1916301377, ignored to avoid time warp :)
Jun 24 16:17:48 vdr vdr[11790]: diff = 1744739819, ignored to avoid time warp :)
Jun 24 17:08:13 vdr vdr[11790]: diff = 145784339, ignored to avoid time warp :)
Jun 24 17:24:55 vdr vdr[11790]: diff = 179202481, ignored to avoid time warp :)
Jun 24 17:41:52 vdr vdr[11790]: diff = 1618607957, ignored to avoid time warp :)
Jun 25 11:53:46 vdr vdr[7595]: diff = 9153240, ignored to avoid time warp :)
Jun 25 12:52:28 vdr vdr[7595]: diff = 3000, ignored to avoid time warp :)
Jun 25 13:09:24 vdr vdr[7595]: diff = 4380, ignored to avoid time warp :)
Jun 25 13:31:05 vdr vdr[7595]: diff = 3017820, ignored to avoid time warp :)
Jun 25 13:47:48 vdr vdr[7595]: diff = 5160, ignored to avoid time warp :)
Jun 25 14:04:47 vdr vdr[7595]: diff = 5441340, ignored to avoid time warp :)
Jun 25 14:55:18 vdr vdr[7595]: diff = 1119704119, ignored to avoid time warp :)
Jun 25 16:16:53 vdr vdr[7595]: diff = 311639, ignored to avoid time warp :)
Jun 25 16:58:58 vdr vdr[7595]: diff = 2281, ignored to avoid time warp :)
Jun 25 16:59:05 vdr vdr[7595]: diff = 69059, ignored to avoid time warp :)
Jun 25 17:15:54 vdr vdr[7595]: diff = 8399, ignored to avoid time warp :)

To help you, I have attached a patch against vdr-1.3.27.
This patch should also work with older versions of vdr.
Go to the VDR directory and type:
patch < vdr-1.3.27_time_warp.diff

Kind regards
Andreas Böttger
  

Comments

Udo Richter June 26, 2005, 11:26 p.m. UTC | #1
Birgit & Andreas Böttger wrote:
> After some tests with other transponders, I currently
> use RTL again to set system time, because this is the
> most used transponder here.

I'm pretty sure my case of time warping was due to bad weather. I've not
been home that time, but it was perfect sat dropout weather.

> To help you, I have attached a patch against vdr-1.3.27.
> This patch should also work with older versions of vdr.

Nice, but I'll have to merge it with the settime patch (using external
shell script to set time via sudo). Not a big deal, I'll write something
similar to yours.

Cheers,

Udo
  
Ludwig Nussel June 27, 2005, 9 a.m. UTC | #2
Udo Richter wrote:
> Birgit & Andreas Böttger wrote:
> [...]
> > To help you, I have attached a patch against vdr-1.3.27.
> > This patch should also work with older versions of vdr.
> 
> Nice, but I'll have to merge it with the settime patch (using external
> shell script to set time via sudo). Not a big deal, I'll write something
> similar to yours.

Let vdr do the user switching and save yourself from such hacks:
http://www.suse.de/~lnussel/vdr/vdr-1.3.24-su.diff

cu
Ludwig
  

Patch

diff -Nur vdr-1.3.27.ori/eit.c vdr-1.3.27/eit.c
--- vdr-1.3.27.ori/eit.c	2005-06-11 17:31:21.000000000 +0200
+++ vdr-1.3.27/eit.c	2005-06-25 09:23:57.000000000 +0200
@@ -266,14 +266,21 @@ 
   time_t sattim = getTime();
   time_t loctim = time(NULL);
 
-  if (abs(sattim - loctim) > 2) {
-     mutex.Lock();
-     isyslog("System Time = %s (%ld)\n", *TimeToString(loctim), loctim);
-     isyslog("Local Time  = %s (%ld)\n", *TimeToString(sattim), sattim);
-     if (stime(&sattim) < 0)
-        esyslog("ERROR while setting system time: %m");
-     mutex.Unlock();
+  static int lastDiff = 0;
+  int diff = abs(sattim - loctim);
+  if (diff > 2) {
+     if (abs(diff - lastDiff) < 3) {
+        mutex.Lock();
+        isyslog("System Time = %s (%ld)\n", *TimeToString(loctim), loctim);
+        isyslog("Local Time  = %s (%ld)\n", *TimeToString(sattim), sattim);
+        if (stime(&sattim) < 0)
+           esyslog("ERROR while setting system time: %m");
+        mutex.Unlock();
+     } else {
+        isyslog("diff = %d, ignored to avoid time warp :)", diff);
      }
+     lastDiff = diff;
+  }
 }