NSTimer: serious drift in Time (in milliseconds)
NSTimer: serious drift in Time (in milliseconds)
- Subject: NSTimer: serious drift in Time (in milliseconds)
- From: Gilles Celli <email@hidden>
- Date: Fri, 10 Nov 2006 16:43:08 +0100
Hello,
My app which acquires data every 5 seconds from a Multimeter (via USB
port) seems to work fine.
However I remarked that there is a drift (milliseconds) in time when
using NSTimer.
The app starts at a given time say 10:00:30,000 (hh:min:sec,
millisec) and after 1 hour it loses about >500 millisec, and
finishes with 10:59:59,412.
What can be done to have an exact 5 second time interval ? Is this
even possible with NSTimer ?
Maybe a time check with corrections should be done...but this gets
complicated
compared to our UNIX based program which acquires exactly at the
given time, by using gettimeofday();
Code used:
// This will start the acquisition at 'startDate' (send timed message
to self)
timer = [ [[NSTimer alloc] initWithFireDate:startDate
interval:5.0
target:self
selector:@selector
(receiveData:)
userInfo:nil
repeats:YES] retain];
[[NSRunLoop currentRunLoop] addTimer:timer
forMode:NSDefaultRunLoopMode];
Any infos / suggestions greatly appreciated.
Thanks in advance,
Gilles
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden