Laks wrote:
> Hi
> how can i use the hwclock in my c source code?
> i need the time for my smart card reader which i am designing using the
> arm board
You won't need to read hwclock to get wall clock time. Use
gettimeofday() function to get current time (seconds since 1970-01-01
and microseconds) and then strftime if you need to format it in text
format. See 'man gettimeofday'. You do not need to care about hwclock
as soon as your system has proper startup and shutdown scripts.
In normal Linux operation (also most other OSs too), the hwclock is read
only at boot time and after that the operating system keeps time
independently from real-time clock. If you have network connectivity,
you may want to use ntp protocol to keep time in sync.
Thus normal operation would be:
- system is powered up
- in init scripts
- the RTC clock is read and kernel knows current time
- ntpdate is used to syncronise clocks, if possible after network
is configured
- ntp-client daemon is started that helps kernel to keep time (if you
are low with resources, you may not want to use ntp-daemon but to
run ntpdate every now and then using cron)
- your system does what ever you design it to do
- when system is shut down, current time is saved to realtime clock
(you may want to update RTC every now and then if you use ntp(date),
like daily with cron:
'ntpdate your.ntp.server.example && hwclock --systohc')
--
Markus
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|