<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div class="" style=""><span class="" style="">Thanks Mark, </span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;" class=""><span class="" style="">I found the conversation here:</span></div><div style="background-color: transparent;" class=""><span class="" style=""><a href="http://lists.teslaclub.hk/pipermail/ovmsdev/2013-November/001819.html" class="" style="">http://lists.teslaclub.hk/pipermail/ovmsdev/2013-November/001819.html</a><br class="" style=""></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal;
 background-color: transparent;" class=""><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;" class="">And I give up on the GPS time idea. </div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;" class="">When would the GSM time be available in the code? </div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color: transparent;" class=""><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-style: normal; background-color:
 transparent;" class="">Nikolay</div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;" class=""> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;" class=""> <div dir="ltr" class="" style=""> <font size="2" face="Arial" class="" style=""> On Tuesday, June 17, 2014 2:37 AM, Mark Webb-Johnson <mark@webb-johnson.net> wrote:<br class="" style=""> </font> </div>  <br class="" style=""><br class="" style=""> <div class="" style=""><div id="yiv7076646418" class="" style=""><div class="" style="">Nikolay,<div class="" style=""><br clear="none" class="" style=""></div><div class="" style="">I think having two separate times is more complicated than just one.</div><div class="" style=""><br clear="none" class="" style=""></div><div
 class="" style="">This topic started originally because the car_time was/is wildly inaccurate. As Håkon put it - stopwatch: 8 hours, car_parktime: 6 hours!</div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style="">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.</div><div class="" id="yiv7076646418yqtfd31049" style=""><div class="" style=""><br clear="none" class="" style=""></div><div class="" style="">Regards, Mark.</div><div class="" style=""><br clear="none" class="" style=""></div><div class="" style=""></div></div></div></div><div id="yiv7076646418" class="" style=""><div
 class="" style=""><div dir="ltr" class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" style=""><div class="" id="yiv7076646418yqtfd77548" style="">Hi,</div><br clear="none" class="" style=""><br clear="none" class="" style=""></div>The car_time is incremented in the state_ticker1 (approx once every second).<br clear="none" class="" style=""></div>However I've noticed that this is extremely inacurate <br clear="none" class="" style=""><br clear="none" class="" style="">
</div>Today I started a stopwatch when parking the car, and compared it to the car_parktime in the iOS app:<br clear="none" class="" style=""></div> - Stopwatch: 8:00 (eight hours)<br clear="none" class="" style=""></div> - car_parktime: 6:01 (six hours and one minute<br clear="none" class="" style=""></div>A difference of 1 hour and 59 minutes during 8 hours!<br clear="none" class="" style="">
<br clear="none" class="" style="">I wonder if this could be done in an other way? <br clear="none" class="" style="">E.g. by pulling the time from the GPS?<br clear="none" class="" style=""><br clear="none" class="" style=""></div>Best regards.<br clear="none" class="" style=""></div>Håkon Markussen<div class="" id="yiv7076646418yqtfd31735" style=""><br clear="none" class="" style=""></div></div></div></div><br class="" style="">_______________________________________________<br clear="none" class="" style="">OvmsDev mailing list<br clear="none" class="" style=""><a shape="rect" ymailto="mailto:OvmsDev@lists.teslaclub.hk" href="mailto:OvmsDev@lists.teslaclub.hk" class="" style="">OvmsDev@lists.teslaclub.hk</a><br clear="none" class="" style=""><a shape="rect" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank" class="" style="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><div class="" id="yqtfd47854" style=""><br
 clear="none" class="" style=""></div><br class="" style=""><div id="yiv7076646418" class="" style=""><div class="" style=""><div class="" style=""><br clear="none" class="" style=""><div class="" style=""><div class="" id="yiv7076646418yqtfd81966" style=""><div class="" style="">On 16 Jun, 2014, at 10:16 pm, Nikolay Shishkov <<a rel="nofollow" shape="rect" ymailto="mailto:nshishkov@yahoo.com" target="_blank" href="mailto:nshishkov@yahoo.com" class="" style="">nshishkov@yahoo.com</a>> wrote:</div><br clear="none" class="" style=""></div><blockquote type="cite" class="" style=""><div class="" style=""><div style="background-color:rgb(255, 255, 255);font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:12pt;" class=""><div class="" id="yiv7076646418yqtfd06621" style=""><div class="" style="">Thanks Mark, </div><div class="" style="">Isn't it too complicated to fetch the time from the GSM
 modem? </div><div class="" style="">How about changing the following 2 lines in the net.c code:</div><pre class="" style="font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size:12px;margin-top:0px;margin-bottom:0px;line-height:18px;"></pre><div class="" id="yiv7076646418LC947" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;">        <span class="" style="font-weight:bold;">if</span><span class="" style="">(</span> <span class="" style="">b</span> <span class="" style="font-weight:bold;">=</span> <span class="" style="">strtokpgmram</span><span class="" style="">(</span> <span class="" style="">net_buf</span><span class="" style="font-weight:bold;">+</span><span class="" style="color:rgb(0, 153, 153);">2</span><span class="" style="">,</span> <span class="" style="color:rgb(221, 17, 68);">","</span> <span class="" style="">)</span> <span class="" style="">)</span></div><div
 class="" id="yiv7076646418LC948" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;">            <span class="" style="">;</span>                                     <span class="" style="color:rgb(153, 153, 136);font-style:italic;">// Time</span></div><div class="" style=""><div class="" style="margin-top:0.1em;margin-bottom:0.1em;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;"><br clear="none" class="" style=""></div><div class="" style="margin-top:0.1em;margin-bottom:0.1em;font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;font-style:normal;background-color:transparent;">To something like this</div><pre class="" style="font-family:Consolas, 'Liberation Mono', Menlo, Courier,
 monospace;margin-top:0px;margin-bottom:0px;"></pre><div class="" id="yiv7076646418LC947" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;">        <span class="" style="font-weight:bold;">if</span><span class="" style="">(</span> <span class="" style="">b</span> <span class="" style="font-weight:bold;">=</span> <span class="" style="">strtokpgmram</span><span class="" style="">(</span> <span class="" style="">net_buf</span><span class="" style="font-weight:bold;">+</span><span class="" style="color:rgb(0, 153, 153);">2</span><span class="" style="">,</span> <span class="" style="color:rgb(221, 17, 68);">","</span> <span class="" style="">)</span> <span class="" style="">)</span></div><pre class="" style="color:rgb(51, 51, 51);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;margin-top:0px;margin-bottom:0px;"></pre><div class="" id="yiv7076646418LC948"
 style="padding-left:10px;height:18px;">            gps_time_str = *b<span class="" style="">;</span>                                     <span class="" style="color:rgb(153, 153, 136);font-style:italic;">// Time</span></div><pre class="" style="color:rgb(51, 51, 51);font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;margin-top:0px;margin-bottom:0px;"></pre><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;">            gps_time_acquired = car_time<span class="" style="">;</span>                      <span class="" style="color:rgb(153, 153, 136);font-style:italic;">// when was that time acquired</span></div><div class="" id="yiv7076646418LC948" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;"><span class="" style="color:rgb(153, 153, 136);font-style:italic;font-family:'Courier
 New';white-space:pre;">        </span><span class="" style="color:rgb(153, 153, 136);font-style:italic;font-family:'Courier New';">    </span><br clear="none" class="" style=""></div><div class="" style="color:rgb(51, 51, 51);"><span class="" style="font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;background-color:transparent;">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:</span><br clear="none" class="" style=""></div><div class="" style="color:rgb(51, 51, 51);"><span class="" style="font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;background-color:transparent;"><br clear="none" class="" style=""></span></div><div class="" style=""><pre class="" style="font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;margin-top:0px;margin-bottom:0px;"></pre><div class="" id="yiv7076646418LC947" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;">        long get_time() {</div><div class="" id="yiv7076646418LC947" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;"><span class="" style="white-space:pre;">   </span>if
 (gps_time_acquired != 0)</div><pre class="" style="font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;margin-top:0px;margin-bottom:0px;"></pre><div class="" id="yiv7076646418LC948" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;"><span class="" style="white-space:pre;">         </span>return gps_time_long + (car_time - gps_time_acquired); = *b<span class="" style="">;</span>                                     </div><div class="" id="yiv7076646418LC948" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;"><span class="" style="white-space:pre;">      </span>else</div><div class="" id="yiv7076646418LC948" style="color:rgb(51, 51, 51);padding-left:10px;height:18px;"><span class="" style="white-space:pre;">          </span>return car_time;</div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><span class="" style="white-space:pre;">    </span>}</div><div class="" id="yiv7076646418LC948"
 style="padding-left:10px;height:18px;"><br clear="none" class="" style=""></div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><span class="" style="font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;">Any issues with such approach? Apart from GPS antenna not connected to the board?</span></div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><span class="" style="font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;font-size:16px;line-height:normal;white-space:normal;"><br clear="none" class="" style=""></span></div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><span class="" style="font-family:HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande',
 sans-serif;font-size:16px;line-height:normal;white-space:normal;">Nikolay </span><br clear="none" class="" style=""></div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><br clear="none" class="" style=""></div><div class="" id="yiv7076646418LC948" style="padding-left:10px;height:18px;"><br clear="none" class="" style=""></div></div></div><pre class="" style="">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 <<a rel="nofollow" shape="rect" class="" target="_blank" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" style="">nshishkov at yahoo.com</a>> wrote:

><i class="" style=""> Hi, 
</i>><i class="" style=""> 
</i>><i class="" style=""> I am getting strange time on my push notifications and on the logs. 
</i>><i class="" style=""> Looking at the code it seem a variable called car_time is used to produce string indicating time. 
</i>><i class="" style=""> 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 .
</i>><i class="" style=""> 
</i>><i class="" style=""> If I am not missing something wouldn't it be beneficial to get the time from the GPS or the GSM network instead?
</i>><i class="" style=""> 
</i>><i class="" style=""> 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.
</i>><i class="" style=""> 
</i>><i class="" style=""> Nikolay</i></pre></div><div class="" style=""><br clear="none" class="" style=""></div></div></div>_______________________________________________<br clear="none" class="" style="">OvmsDev mailing list<br clear="none" class="" style=""><a rel="nofollow" shape="rect" ymailto="mailto:OvmsDev@lists.teslaclub.hk" target="_blank" href="mailto:OvmsDev@lists.teslaclub.hk" class="" style="">OvmsDev@lists.teslaclub.hk</a><br clear="none" class="" style="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<div class="" id="yiv7076646418yqtfd22019" style=""><br clear="none" class="" style=""></div></blockquote></div><div class="" id="yiv7076646418yqtfd18274" style=""><br clear="none" class="" style=""></div></div></div></div><br class="" style="">_______________________________________________<br clear="none" class="" style="">OvmsDev mailing list<br clear="none" class="" style=""><a shape="rect"
 ymailto="mailto:OvmsDev@lists.teslaclub.hk" href="mailto:OvmsDev@lists.teslaclub.hk" class="" style="">OvmsDev@lists.teslaclub.hk</a><br clear="none" class="" style=""><a shape="rect" href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank" class="" style="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><div class="" id="yqtfd89236" style=""><br clear="none" class="" style=""></div><br class="" style=""><br class="" style=""></div>  </div> </div>  </div> </div></body></html>