author | sandman <sandman> | 2002-06-19 13:22:17 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-19 13:22:17 (UTC) |
commit | 952cb1ec42e827f1bc45f9d3f0a1b685ff545790 (patch) (unidiff) | |
tree | 37c435e2b8e4de6c3c7dcf62b3fe33c8d2c97bc4 /core | |
parent | 8d6e1b42d3b5b8dc376f0979d9f4363d9a6c6970 (diff) | |
download | opie-952cb1ec42e827f1bc45f9d3f0a1b685ff545790.zip opie-952cb1ec42e827f1bc45f9d3f0a1b685ff545790.tar.gz opie-952cb1ec42e827f1bc45f9d3f0a1b685ff545790.tar.bz2 |
Added some debug capabilities via /tmp/opiealarm.log
-rw-r--r-- | core/opiealarm/opiealarm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/opiealarm/opiealarm.c b/core/opiealarm/opiealarm.c index a4d46ed..71367b3 100644 --- a/core/opiealarm/opiealarm.c +++ b/core/opiealarm/opiealarm.c | |||
@@ -219,40 +219,50 @@ int suspend ( int fix_rtc ) | |||
219 | fclose ( fp ); | 219 | fclose ( fp ); |
220 | 220 | ||
221 | alrt = atoi ( buf ); | 221 | alrt = atoi ( buf ); |
222 | 222 | ||
223 | if ( alrt == 0 ) | 223 | if ( alrt == 0 ) |
224 | error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" ); | 224 | error_msg_and_die ( 0, "/etc/resumeat contains an invalid time description" ); |
225 | 225 | ||
226 | /* subtract 5 sec from event time... */ | 226 | /* subtract 5 sec from event time... */ |
227 | alrt -= 5; | 227 | alrt -= 5; |
228 | 228 | ||
229 | if ( log ) | 229 | if ( log ) |
230 | fprintf ( log, "Setting RTC alarm to %d\n", alrt ); | 230 | fprintf ( log, "Setting RTC alarm to %d\n", alrt ); |
231 | |||
232 | tzset ( ); | ||
231 | 233 | ||
232 | alr = *gmtime ( &alrt ); | 234 | alr = *gmtime ( &alrt ); |
233 | 235 | ||
234 | // get system time | 236 | // get system time |
235 | time ( &syst ); | 237 | time ( &syst ); |
236 | sys = *localtime ( &syst ); | 238 | sys = *localtime ( &syst ); |
237 | 239 | ||
238 | // Write alarm time to RTC | 240 | // Write alarm time to RTC |
239 | if (( fd = open ( "/dev/misc/rtc", O_RDWR )) < 0 ) | 241 | if (( fd = open ( "/dev/misc/rtc", O_RDWR )) < 0 ) |
240 | error_msg_and_die ( 1, "/dev/misc/rtc" ); | 242 | error_msg_and_die ( 1, "/dev/misc/rtc" ); |
241 | 243 | ||
242 | // get RTC time | 244 | // get RTC time |
245 | memset ( &rtc, 0, sizeof ( struct tm )); | ||
243 | if ( ioctl ( fd, RTC_ALM_SET, &rtc ) < 0 ) | 246 | if ( ioctl ( fd, RTC_ALM_SET, &rtc ) < 0 ) |
244 | error_msg_and_die ( 1, "ioctl RTC_RD_TIME" ); | 247 | error_msg_and_die ( 1, "ioctl RTC_RD_TIME" ); |
245 | rtct = mktime ( &rtc ); | 248 | rtct = mktime ( &rtc ); |
246 | 249 | ||
250 | fprintf ( log, "System time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", sys. tm_mday, sys. tm_mon + 1, sys. tm_year + 1900, sys. tm_hour, sys. tm_min, sys. tm_sec, sys. tm_isdst, sys. tm_zone, sys. tm_gmtoff ); | ||
251 | fprintf ( log, "RTC time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", rtc. tm_mday, rtc. tm_mon + 1, rtc. tm_year + 1900, rtc. tm_hour, rtc. tm_min, rtc. tm_sec, rtc. tm_isdst, rtc. tm_zone, rtc. tm_gmtoff ); | ||
252 | fprintf ( log, "Wakeup time: %02d.%02d.%04d %02d:%02d:%02d DST: %d (TZ: %s, offset: %d)\n", alr. tm_mday, alr. tm_mon + 1, alr. tm_year + 1900, alr. tm_hour, alr. tm_min, alr. tm_sec, alr. tm_isdst, alr. tm_zone, alr. tm_gmtoff ); | ||
253 | |||
254 | fprintf ( log, "System/RTC diff: %d seconds\n", ( syst - rtct ) - sys. tm_gmtoff ); | ||
255 | |||
256 | |||
247 | rtc_sys_diff = ( syst - rtct ) - sys. tm_gmtoff; | 257 | rtc_sys_diff = ( syst - rtct ) - sys. tm_gmtoff; |
248 | 258 | ||
249 | if ( fix_rtc && (( rtc_sys_diff < -4 ) || ( rtc_sys_diff > 4 ))) { | 259 | if ( fix_rtc && (( rtc_sys_diff < -4 ) || ( rtc_sys_diff > 4 ))) { |
250 | struct tm set; | 260 | struct tm set; |
251 | 261 | ||
252 | set = *gmtime ( &syst ); | 262 | set = *gmtime ( &syst ); |
253 | 263 | ||
254 | fprintf ( log, "Correcting RTC: %d seconds\n", rtc_sys_diff ); | 264 | fprintf ( log, "Correcting RTC: %d seconds\n", rtc_sys_diff ); |
255 | 265 | ||
256 | if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 ) | 266 | if ( ioctl ( fd, RTC_SET_TIME, &set ) < 0 ) |
257 | error_msg_and_die ( 1, "ioctl RTC_SET_TIME" ); | 267 | error_msg_and_die ( 1, "ioctl RTC_SET_TIME" ); |
258 | } | 268 | } |