[Ovmsdev] timestamps on push notifications and logs
Mark Webb-Johnson
mark at webb-johnson.net
Thu Jun 19 13:47:57 HKT 2014
Nikolay,
It seems that this is only used in 1 place at the moment, net_msg.c to prepare the response to a STAT message.
A quick workaround is:
-- a/vehicle/OVMS.X/net_msg.c
+++ b/vehicle/OVMS.X/net_msg.c
@@ -994,7 +994,7 @@ char *net_prep_stat(char *s)
unit = " km";
}
- if (car_time != 0)
+ if (car_time > 315360000)
{
char *p = par_get(PARAM_TIMEZONE);
s = stp_time(s, NULL, car_time + timestring_to_mins(p)*60L);
That should only report the time (in STAT) if the car_time > 10years (1980 onwards). I think that should mean that it will only show the time if it accurately reflects the real time (or if a module inaccurately reflecting the time has been running continuously for more than 10 years!).
Please see if this works around the issue for you.
That then gives us time to make the migration of car_time out of the individual vehicle modules and to use a fn_bit less pressing.
Regards, Mark.
On 17 Jun, 2014, at 4:34 pm, Nikolay Shishkov <nshishkov at yahoo.com> wrote:
> Thanks Mark,
> I found the conversation here:
> http://lists.teslaclub.hk/pipermail/ovmsdev/2013-November/001819.html
>
> And I give up on the GPS time idea.
> When would the GSM time be available in the code?
>
> Nikolay
>
>
> On Tuesday, June 17, 2014 2:37 AM, Mark Webb-Johnson <mark at webb-johnson.net> wrote:
>
>
> Nikolay,
>
> I think having two separate times is more complicated than just one.
>
> This topic started originally because the car_time was/is wildly inaccurate. As Håkon put it - stopwatch: 8 hours, car_parktime: 6 hours!
>
> I think the approach we decided on back then (winter 2013/2014) is correct. It just needs to be implemented, and as most of the groundwork has now been done (thanks to Tom), what is left is not too hard. Rather than have the car modules init car_time=0 and then car_time++ on the roughly-per-second-ticker, what they will do is just set a fn_bit to offload that work to the framework.
>
> Regards, Mark.
>
> Hi,
>
>
> The car_time is incremented in the state_ticker1 (approx once every second).
> However I've noticed that this is extremely inacurate
>
> Today I started a stopwatch when parking the car, and compared it to the car_parktime in the iOS app:
> - Stopwatch: 8:00 (eight hours)
> - car_parktime: 6:01 (six hours and one minute
> A difference of 1 hour and 59 minutes during 8 hours!
>
> I wonder if this could be done in an other way?
> E.g. by pulling the time from the GPS?
>
> Best regards.
> Håkon Markussen
>
>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
>
>
> On 16 Jun, 2014, at 10:16 pm, Nikolay Shishkov <nshishkov at yahoo.com> wrote:
>
>> Thanks Mark,
>> Isn't it too complicated to fetch the time from the GSM modem?
>> How about changing the following 2 lines in the net.c code:
>> if( b = strtokpgmram( net_buf+2, "," ) )
>> ; // Time
>>
>> To something like this
>> if( b = strtokpgmram( net_buf+2, "," ) )
>> gps_time_str = *b; // Time
>> gps_time_acquired = car_time; // when was that time acquired
>>
>> Then we can discuss if car_time should be the same as gps_time (probably not), or if gps_time could be used for logging and other selected functions? Or even if we can have a get_time() function (what would be a good location) that would encapsulate the time getting process and do some simple magic - say something like this:
>>
>> long get_time() {
>> if (gps_time_acquired != 0)
>> return gps_time_long + (car_time - gps_time_acquired); = *b;
>> else
>> return car_time;
>> }
>>
>> Any issues with such approach? Apart from GPS antenna not connected to the board?
>>
>> Nikolay
>>
>>
>> Here:
>>
>> unsigned long car_time
>>
>> Time (in seconds), as measured by the car. The 0 value of this can be whatever the car module desires.
>> It is acceptable to merely initialize this to zero and increment it by 1 for every ticker1() received.
>> Alternatively, a more accurate method is to read the real time clock from the vehicle CAN bus (if available) and update from there.
>>
>>
>> I think the Tesla Roadster is the only vehicle actually updating it from the CAN bus. There was some (fairly recent) discussion about getting this from the GPS, and Tom did the foundation work (utils.{h,c} JDEpoch, JdToYMD, JdFromYMD, and datestring_to_timestamp in net.c), but we haven't completed the changes to the core net.c (+CCLK handler) to do this yet. I attach the mailing list eMail showing how this will be done.
>>
>> Regards, Mark.
>>
>>
>>
>> On 15 Jun, 2014, at 9:35 pm, Nikolay Shishkov <nshishkov at yahoo.com> wrote:
>>
>> > Hi,
>> >
>> > I am getting strange time on my push notifications and on the logs.
>> > Looking at the code it seem a variable called car_time is used to produce string indicating time.
>> > Also looking at the code I can not seem to find where this car_time variable is set. The only place I could find is the vehicle_teslaroadster.c .
>> >
>> > If I am not missing something wouldn't it be beneficial to get the time from the GPS or the GSM network instead?
>> >
>> > I am attaching a screenshot of my app where the timestamp of the push notification is visible together with the time displayed on my phone.
>> >
>> > Nikolay
>>
>> _______________________________________________
>> OvmsDev mailing list
>> 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
>
>
>
> _______________________________________________
> 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/20140619/01d885ed/attachment.htm>
More information about the OvmsDev
mailing list