[Ovmsdev] System date set?

Mark Webb-Johnson mark at webb-johnson.net
Sat Feb 24 23:40:41 HKT 2018


I’ve done a very rough implementation of this:

OVMS > time set 1519486746
Time set (at stratum 15)

OVMS > time status
UTC Time:   Sat Feb 24 15:39:09 2018
Local Time: Sat Feb 24 15:39:09 2018
Provider:   time

PROVIDER             STRATUM  UPDATE TIME
*time                     15       4 Sat Feb 24 15:39:10 2018

OVMS > time status
UTC Time:   Sat Feb 24 15:39:14 2018
Local Time: Sat Feb 24 15:39:14 2018
Provider:   time

PROVIDER             STRATUM  UPDATE TIME
*time                     15       9 Sat Feb 24 15:39:15 2018

I’ll work on it some more tomorrow. As it is, components can now call MyTime.Set(…) to feed their opinion of time into the system.

Regards, Mark.

> On 24 Feb 2018, at 10:23 PM, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
> 
> I forgot about vehicles. Tesla Roadster is the same.
> 
> I’ll write an ovms_time component now. Then, we can all submit time to it appropriately.
> 
> class OvmsTime
>   {
>   public:
>     OvmsTime();
>     ~OvmsTime();
> 
>   public:
>     void Set(char* provider, int stratum, bool trusted, time_t time);
>   };
> 
> extern OvmsTime MyTime;
> 
> Just follow the NTP stratum approach (distance from a zero-delay device). Trusted is a separate indication that just sets stratum level to 16. The provider is simply the logging TAG.
> 
> Internal implementation is like NTP. We track the last times from all providers, and pick the one with the lowest stratum that has reported within a reasonable time.
> 
> We can add the boot-time save/restore later (once Michael has done that code for safe boot, etc).
> 
> Regards, Mark.
> 
>> On 24 Feb 2018, at 9:19 PM, Geir Øyvind Vælidalo <geir at validalo.net <mailto:geir at validalo.net>> wrote:
>> 
>> Sounds like a plan. I can get time from the car too, but the resolution is several seconds, so I think we need to have some sort of priority here. Maybe SNTP first, then GPS, cellular and finally “car”?
>> 
>> Geir
>> 
>> Sendt fra min iPhone
>> 
>>> 24. feb. 2018 kl. 04:36 skrev Mark Webb-Johnson <mark at webb-johnson.net <mailto:mark at webb-johnson.net>>:
>>> 
>>> I don’t think so.
>>> 
>>> There are various sources for date/time. GPS. Cellular. SNTP. Need to ensure that they are not all fighting.
>>> 
>>> Another module to do this? Have components tell it their opinion of the time, then it centrally decides and updates system clock if necessary
>>> 
>>> Also store last clock in RTC ram so during a crash/reboot it can recover the last know time?
>>> 
>>> Regards, Mark
>>> 
>>>> On 24 Feb 2018, at 9:44 AM, Stephen Casner <casner at acm.org <mailto:casner at acm.org>> wrote:
>>>> 
>>>> Does the sytem date get set anywhere (presumably from GPS)?
>>>> 
>>>> This question occurred to me as I'm working on a side project using
>>>> the DEVKIT-C module which won't have access to GPS so I added the code
>>>> to set the data using SNTP.
>>>> 
>>>>                                                      -- Steve
>>>> _______________________________________________
>>>> OvmsDev mailing list
>>>> OvmsDev at lists.teslaclub.hk <mailto:OvmsDev at lists.teslaclub.hk>
>>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>> 
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.teslaclub.hk <mailto:OvmsDev at lists.teslaclub.hk>
>>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>> 
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.teslaclub.hk <mailto:OvmsDev at lists.teslaclub.hk>
>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
> 
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20180224/39566e8a/attachment.htm>


More information about the OvmsDev mailing list