Hello,
 
there is a bug in the pSOS kernel-space skin, calculating calendar time
to ticks and vice versa.
The file xenomai/ksrc/skins/psos+/tm.c should be fixed like this:
 
 
 
--- xenomai-2.4/ksrc/skins/psos+/tm.c
+++ xenomai-2.4/ksrc/skins/psos+/tm.c
@@ -204,8 +204,8 @@
   /* Add one day for leap year after February. */
   *count += 1;
 
- for (n = month - 1; month > 0; month--)
-  *count += tm_month_sizes[month - 1];
+ for (n = 0; n < month-1; n++)
+  *count += tm_month_sizes[n];
 
  *count += day - 1;
  *count *= 24;
@@ -223,9 +223,10 @@
 static void tm_ticks_to_date(u_long *date,
         u_long *time, u_long *ticks, xnticks_t count)
 {
- u_long year, month, day, hour, min, sec, allsecs, rem;
+ u_long year, month, day, hour, min, sec, rem;
+ xnticks_t allsecs;
 
- allsecs = (u_long)xnarch_ulldiv(count,
xntbase_get_ticks2sec(psos_tbase), &rem);
+ allsecs = xnarch_ulldiv(count, xntbase_get_ticks2sec(psos_tbase),
&rem);
 
  year = 0;
 
@@ -257,14 +258,14 @@
   month++;
  }
 
- day = allsecs / tm_secbyday;
- allsecs -= (day * tm_secbyday);
- day++;   /* Days are 1-based. */
- hour = (allsecs / tm_secbyhour);
- allsecs -= (hour * tm_secbyhour);
- min = (allsecs / tm_secbymin);
- allsecs -= (min * tm_secbymin);
  sec = allsecs;
+ day = sec / tm_secbyday;
+ sec -= (day * tm_secbyday);
+ day++;   /* Days are 1-based. */
+ hour = (sec / tm_secbyhour);
+ sec -= (hour * tm_secbyhour);
+ min = (sec / tm_secbymin);
+ sec -= (min * tm_secbymin);
 
  *date = (year << 16) | (month << 8) | day;
  *time = (hour << 16) | (min << 8) | sec;

 
 
Thank you
Markus
 
_______________________________________________
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core

Reply via email to