[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4694: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4695: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4696: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
8devices Community :: View topic - I2C RTC clock sincronization
8devices Community
https://www.8devices.com/community/

I2C RTC clock sincronization
https://www.8devices.com/community/viewtopic.php?f=1&t=51
Page 1 of 2

Author:  paco [ 03 Mar 2012, 17:10 ]
Post subject:  I2C RTC clock sincronization

Hello
I have a carambola with ntpclient and it is working fine.
I have added a I2C rtc clock and I would like to:
- If ntp works fine set rtcclock
- if ntp doesn't work get time rtc clock and set system time. This usually happend when there is not Internet connection.
I use
i2cget -y 0 0x68 reg b
in order to get rtcclock values in BCD.
reg is the register with diferent values 0 is for seconds, 1 for minutes, etc,..
I use RTC DS1307 it is cheap and easy to use.
There are two main problems:
- detect if there is a ntpclient or connection problem
- setting and getting system time from i2cget
Any idea about this?
I could do it but I would like to get elegant and profesional advices.
Thanks in advance.

Author:  David [ 04 Mar 2012, 09:35 ]
Post subject:  Re: I2C RTC clock sincronization

You could write a (bash) shell script or a Lua script to handle something like this:

1. Ask the ntpclient whether the time synchronization was successful, or if that's not possible check the internet connection
2. If so, set the RTC time using i2cset
3. If not, get the time from RTC using i2get

Which programming and Linux experience do you have? That would be good to know for further recommendations.

Author:  paco [ 04 Mar 2012, 18:07 ]
Post subject:  Re: I2C RTC clock sincronization


Author:  David [ 04 Mar 2012, 18:24 ]
Post subject:  Re: I2C RTC clock sincronization

Do you have any experience in Python? If not, I would consider skipping it for Carambola. The filesize is just way too big to fit on the 8MB of the Carambola.

For bash scripting, I like this page: http://tldp.org/LDP/abs/html/

Author:  paco [ 05 Mar 2012, 11:40 ]
Post subject:  Re: I2C RTC clock sincronization


Author:  paco [ 05 Mar 2012, 15:01 ]
Post subject:  Re: I2C RTC clock sincronization

Hello
I have found this in OpenWRT

/etc/hotplug.d/iface/20-ntpclient). The script starts the daemon in 4 phases:

preliminary test - the script checks if the ntpclient is already running.
drift - the scripts sets the specified drift in system clock.
ntp server check phase - the script tests the reachability of the ntp servers (hosts) from config file (uses the ntpclient for this). The script only checks hosts where the specified interface (or inherited interface from ntpclient section) matches the interface that triggered hotplug.d or where no interface is specified at all. If no ntp server is reachable the script quits.
operational phase - the ntpclient is started with the first reachable host and user configuration options (interval etc.) of polling and time adjustment

in the script 20-ntpclient the is a function

start_ntpclient() {
config_foreach set_drift ntpdrift
config_foreach check_server ntpserver
[ -z "$SERVER" ] && exit 0
logger starting ntpclient
$NTPC ${COUNT:+-c $COUNT} ${INTERVAL:+-i $INTERVAL} -s -l -D -p $PORT -h $SERVER 2> /dev/null
}

I think this line should call a script to set system clock from i2c rtc device, instead of exit
[ -z "$SERVER" ] && exit 0

I am right?

and after this line
a line calling calling other script to set i2c rtc device from system clock.
$NTPC ${COUNT:+-c $COUNT} ${INTERVAL:+-i $INTERVAL} -s -l -D -p $PORT -h $SERVER 2> /dev/null

I am right?

I don't know if there is a smartter way of doing this.
I don't if modify 20-ntpclient is smart enough, I mean I am updating ntpclient configuration files.

I can do both scripts in python.

Thanks in advance.

Author:  paco [ 05 Mar 2012, 23:15 ]
Post subject:  Re: I2C RTC clock sincronization

Hello
A not very smart solution.
in /etc/rtc.local a line
/root/setSysClock.sh
the above file as this content
#!/bin/sh
if ping -c1 google.com&> /dev/null;
then
echo "There is Internet connection: Setting RTC Clock";
python /root/setRtcClockFromSys.py;
else
echo "There is NOT Internet connection: Setting Sys Clock from RTC";
python /root/setSysClockFromRtc.py;
fi

Just did two python scripts.
Well come all kind of advices.
Thanks in advance

Author:  Zodiac69 [ 20 Dec 2012, 07:31 ]
Post subject:  Re: I2C RTC clock sincronization

Hi All

I know that this is an "old" post, but here is my 2cents... i am about to start with the hardware (DS1307) and see if i can get this working.

One the system is up and running and you are sure that the time should have been set, look at the system log:
"Dec 19 15:43:25 OpenWrt user.notice root: starting ntpclient"

1. If the next line date and time is the same, Time is NOT set.
2. Read RTC, if local date and time delta is greater than "x", set time

Z69

Author:  rmike [ 20 Dec 2012, 18:26 ]
Post subject:  Re: I2C RTC clock sincronization

Hi,

why don't you simply use hwclock as described here?:
viewtopic.php?f=6&t=224

Michael

Author:  valent [ 24 Feb 2014, 21:49 ]
Post subject:  Re: I2C RTC clock sincronization


Page 1 of 2 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/