help using rtc as a more accurate replacement for python's 'sleep' function
Does anyone know how to access the hardware (rtc) clock on linux?
I writing a program in python that needs to perform an operation and then sleep for an exact amount of time. Right now I have it using python's 'sleep' function which isn't always accurate enough.
As I understand it, the real-time clock(rtc) can be set to send a signal (like a new line or something) after a given amount of time. This sounds like the perfect solution to my problem.
I know the rtc has been used by C programs, but my program is written in python and I don't know much about C. I've looked at rtc.h for the symbols involved in interacting with the rtc, and I wrote a quick python script that tested values that wouldn't cause python's ioctl function to raise an exception when setting them on the rtc, and through that I have figured out the values to at least some of the symbols (RTC_UIE_ON/OFF i think). But I can't get it to work.
I really don't know what I'm doing and could use some help on this one.
All I need is a python script that:
-opens /dev/rtc
-sets the timer to signal every (30th of a second)
-waits for the signal (which should be recieved every 30th of a second) and does this forever
thanx
|