1. Sync time
The problem is to synchronize time on bbb. My device, after power on, querry time from server and set up linux time:
system( "date 061621252015.42" );
But time(NULL) results UTC time (i think). Well, the answer is set TZ variable to UTC before setup time:
setenv("TZ", "UTC", 1);
system( dateCommand.c_str() );
Well, this is working propertly.
2. Drift? time
Almost ;)
This time lags about 10 min for 1 hour.
Experiment:
1. set hwclock from sysclock
2. wait 30 minutes
Result: diff = 11 +- 2 sec
root@beaglebone:~# hwclock -u
Tue Jun 16 21:33:15 2015 0.000000 seconds
root@beaglebone:~# date
Tue Jun 16 21:33:04 UTC 2015
3. wait 55 min
Result: diff = 2:30 !!
root@beaglebone:~# date
Tue Jun 16 22:02:48 UTC 2015
root@beaglebone:~# hwclock -u
Tue Jun 16 22:05:32 2015 0.000000 seconds
root@beaglebone:~# date
Tue Jun 16 22:02:53 UTC 2015
Second question, Is hwclock show correct time?
I hope yes.
Experiment:
22:08:00
root@beaglebone:~# hwclock -u
Tue Jun 16 22:08:09 2015 0.000000 seconds
(My device is not use my time to sync, then 9sec is ok )
23:11:00
root@beaglebone:~# hwclock -u
Tue Jun 16 23:11:09 2015 0.000000 seconds
Looks good!)
|