ehs5 RTC & System.currentTimeMillis() problem | Telit Cinterion IoT Developer Community
December 11, 2016 - 4:23pm, 3111 views
Hi,
This problem was at a forum, but adequately not answered.
https://iot-developer.thalesgroup.com/threads/real-time-clock-drafts-ehs6
Test program
import java.util.Date; import java.util.Timer; import java.util.TimerTask; import javax.microedition.midlet.MIDlet; import javax.microedition.midlet.MIDletStateChangeException; public class probe extends MIDlet { int i = 0; boolean tick = false; public probe() { } protected void destroyApp(boolean arg0) throws MIDletStateChangeException { notifyDestroyed(); } protected void pauseApp() { } protected void startApp() throws MIDletStateChangeException { TimerTask tmrtsk = new TimerTask() { public void run() { tick = true; } }; Timer tmr = new Timer(); tmr.schedule(tmrtsk, 5000, 5000); System.out.println("Start Step 1. ---------------------------------------"); while (i < 24) { tick = false; while (!tick) ; System.out.println("Step 1. Tick=" + i +" Time=" + new Date().toString()); i++; } i = 0; long st= System.currentTimeMillis(); System.out.println("Start Step 2. ---------------------------------------"); while (i < 60) { while (System.currentTimeMillis() - st < 5000) ; st = System.currentTimeMillis(); System.out.println("Step 2. Tick=" + i +" Time=" + new Date().toString()); i++; } i = 0; System.out.println("Start Step 3. ---------------------------------------"); while (i < 24) { tick = false; while (!tick) ; System.out.println("Step 3. Tick=" + i +" Time=" + new Date().toString()); i++; } System.out.println("Test completed."); destroyApp(true); } }
Result
<<11.12.2016 17:14:39: Start Step 1. ---------------------------------------
<<11.12.2016 17:14:44: Step 1. Tick=0 Time=Sun Dec 11 17:14:44 GMT+00:00 2016
........
<<11.12.2016 17:16:40: Step 1. Tick=23 Time=Sun Dec 11 17:16:40 GMT+00:00 2016
Start Step 2. ---------------------------------------
<<11.12.2016 17:16:45: Step 2. Tick=0 Time=Sun Dec 11 17:16:45 GMT+00:00 2016
<<11.12.2016 17:16:50: Step 2. Tick=1 Time=Sun Dec 11 17:16:50 GMT+00:00 2016
........
<<11.12.2016 17:21:12: Step 2. Tick=58 Time=Sun Dec 11 17:21:52 GMT+00:00 2016
<<11.12.2016 17:21:15: Step 2. Tick=59 Time=Sun Dec 11 17:21:57 GMT+00:00 2016
Start Step 3. ---------------------------------------
<<11.12.2016 17:21:16: Step 3. Tick=0 Time=Sun Dec 11 17:21:57 GMT+00:00 2016
..............
<<11.12.2016 17:23:11: Step 3. Tick=23 Time=Sun Dec 11 17:23:53 GMT+00:00 2016
Test completed.
The test shows: Frequent reading system time by a call of System.currentTimeMillis() leads to shift of real time clock . The shift has made 42 seconds in 5 minutes! (Seconds, not milliseconds)
This test works at the TC65T terminal without changes of real time clock.
How it is possible to solve this problem?
Hello,
Did you test with more than one module? Could you check the firmware version with ATI1 ? I have tested it with my module and was not able to reproduce this.
Regards,
Bartłomiej
Hello,
I checked this test with 4 modules. In all cases this result turned out. Modules without updating of the firmware. My project works at TC65T correctly. Upon transition to EHS5 the advancing of real time clock was found. I will try to update the firmware.
What latest version of up-dating and how it can be downloaded?
Hello,
I have checked that currently the official release is REVISION 03.001 A-REVISION 00.000.14.
So I have repeated my tests with this release and the time was drifting in the middle loop (the one that is reading System.currentTimeMillis()) as in your test.
I have also retested with the firmware that I was using before (newer but not the official release) and there was no drifting there.
So it seems that this was already fixed. Unfortunately I'm not able to tell you (we don't publish such information) when the next firmware will be released.
Best regards,
Bartłomiej
Hello,
Thanks for information. Let's wait for up-dating. So far I will try to change the project using the TIMER.
I hope up-dating will quit soon. We have great expectations on EHSx modules.
All the best!