Hi,
Our project depends on a reliable clock that can works with timezones and daylight-saving Linux features.
The PLCnext Engineer IDE gives the possibility to set up the clock with an absolute numeric offset, fair enough for simulating timezone, but not compatible with the Linux daylight-saving feature. Anyways, we want our client to adjust the clock without using the IDE.
I am aware on how the „date“ versus „hwclock“ comands basically works but using them had led us in some situations where the system clock became unstable (especially after a power toggle).
It is probably my fault, but I wonder if its is not something special with your RTC implementation, or a particular limitation that make you says in the OS release notes (between 2021.0 LTS and 2021.9.0):
Local time zone setting****Setting local time zones is not fully supported.
Can you be more specific on this?
Can you gives me guidelines on how using the command line „date“ and „hwclock“?
Thanks
F.Blanchard
Using PLCnext AFC 2152, OS 2022.0.3 LTS, IDE 2021.0.LTS
Example:
// Set the date
root@axcf2152:~# date --set „Wed Mar 16 16:19:10 CDT 2022“
Wed Mar 16 16:19:10 CDT 2022
// Set the local time to UTC timezone
root@axcf2152:~# ln -sf /usr/share/zoneinfo/UTC /etc/localtime root@axcf2152:~# echo -e „UTC“ > /etc/timezoneroot@axcf2152:~# date
Wed Mar 16 21:20:30 UTC 2022
// Write this change to the hardware clock
root@axcf2152:~# hwclock --systohc
//Validation
root@axcf2152:~# date; hwclock
Wed Mar 16 21:24:59 UTC 2022
Wed Mar 16 21:25:00 2022 0.000000 seconds
// Set the local time zone back to its original setting.
root@axcf2152:~# ln -sf /usr/share/zoneinfo/CST6CDT /etc/localtime root@axcf2152:~# echo -e „CST6CDT“ > /etc/timezoneroot@axcf2152:~# date; hwclock
Wed Mar 16 16:25:52 CDT 2022
Wed Mar 16 21:25:52 2022 0.000000 seconds
// Power toggle or reboot here
root@axcf2152:~# date; hwclock Wed Mar 16 16:03 :25 CDT 2022
Wed Mar 16 15:03 :26 2022 0.000000 seconds
// Reboot here
root@axcf2152:~# date; hwclock
Wed Mar 16 16:06:01 CDT 2022
Wed Mar 16 21:06:02 2022 0.000000 seconds
root@axcf2152:~# echo
// Power toggle here (11 minutes OFF)
root@axcf2152:~# date; hwclock
Wed Mar 16 16:09:18 CDT 2022
Wed Mar 16 21:09:19 2022 0.000000 seconds
// Power toggle here (11 minutes OFF)
root@axcf2152:~# date; hwclock Wed Mar 16 16 :14:19 CDT 2022
Wed Mar 16 15 :14:20 2022 0.000000 seconds
// Power toggle here (11 minutes OFF)
root@axcf2152:~# date; hwclock
Wed Mar 16 16:19:59 CDT 2022
Wed Mar 16 21:20:00 2022 0.000000 seconds
root@axcf2152:~#
root@axcf2152:~#
root@axcf2152:~# date; hwclock Wed Mar 16 16 :25:23 CDT 2022
Wed Mar 16 15 :25:24 2022 0.000000 seconds
root@axcf2152:~#