[Ovmsdev] Porting code from v2 to v3

Nikolay Shishkov nshishkov at yahoo.com
Thu Jul 26 15:59:47 HKT 2018


Quick update:I managed to do a not so quick update on one of the ovms v.3 boxes that sits in a Think and can confirm that the porting seems to work. I could see speed, parking time, ambient temperature.
I had very strange problems doing the OTA update. The firmware start download and I can see the messages progressing, but it would halt in between 700kB and 1600kB and then stay there until I refresh the browser. And when I refresh the browser I am asked of my password which leads me to that there must have been a crash in the meantime. 
I was finally able to get the OTA update work by disconnecting the box from the car and powering it via USB. This is a single data point but it kind of points to a problem with the code that communicates with the car. 
I was not able to get a laptop connected to checkout the console, but managed to get the following log - not sure how to interpret it.  Last boot was 87 second(s) agoTime at boot: 2018-07-25 18:07:43 GMTThis is reset #3 since last power cycleDetected boot reason: Crash (12/12)Crash counters: 3 total, 0 early
Last crash: Alloca exception on core 0Registers:PC : 0x400dc8ec PS : 0x00060234 A0 : 0x8008f440 A1 : 0x3ffc45b0A2 : 0x00000020 A3 : 0x00000001 A4 : 0x00000000 A5 : 0x3ffb44b8A6 : 0x3ffb47e4 A7 : 0x3ffb458c A8 : 0x3ffb44d4 A9 : 0x3ffc4590A10 : 0x00000000 A11 : 0x7fffffff A12 : 0x8008e65b A13 : 0x3ffcc450A14 : 0x00000003 A15 : 0x00060023 SAR : 0x00000000 EXCCAUSE: 0x00000005EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000Backtrace:0x400dc8ec 0x4008f43d 0x4008e181 0x400818cc 0x40082163 0x40083c4d 0x400dc8e9Version: 3.1.008-29-gaf41242/ota_1/edge (build idf v3.1-dev-987-g55d915e Jul 6 2018 00:14:59)Running partition: ota_1Boot partition: ota_1Firmware: 3.1.008-29-gaf41242/ota_1/edge (build idf v3.1-dev-987-g55d915e Jul 6 2018 00:14:59)
How is performance and power usage affected when using StandardMetrics.xxxxx->SetValue in the IncomingFrameCan1 method?Most of the messages update value every 100ms, and except maybe speed, battery current and voltage, most of the parameters are not changing that often. And even for the speed, current and voltage, it is probably enough to update StandardMetrics in the 1 second ticker... does this make sense or is the difference non-existing. 
Thanks for all the hand holding and help, Nikolay 
   On Thursday, July 19, 2018, 1:11:46 PM GMT+2, Nikolay Shishkov <nshishkov at yahoo.com> wrote:  
 
  Done. https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/143

I have not tested this in a vehicle.It would take some time to receive the new boxes, but I thought it may help someone to go further. 




    On Thursday, July 19, 2018, 12:46:28 PM GMT+2, Mark Webb-Johnson <mark at webb-johnson.net> wrote:  
 
 Best is to create a pull request, and let us know. We can check and merge with master.
Regards, Mark
On 19 Jul 2018, at 6:41 PM, Nikolay Shishkov <nshishkov at yahoo.com> wrote:


 Thank you guys!I think I am ready with something I want to create pull request on. Do I do this through my own repository, or can I just send someone a diff?Nikolay
    On Thursday, July 19, 2018, 12:37:58 PM GMT+2, Michael Balzer <dexter at expeedo.de> wrote:  
 
  Nikolay,
 
 
 

     - what is the best way to compare OvmsMetricStrings? Or should I dublicate the state in an enum and use that? - what is the best way to compare the OvmsMetricFloat to a literal float?     
 
 If you want to compare a state code encoded as a string, you can simply compare the std::string returned by AsString() with hard coded strings, e.g.
 
     std::string charge_state = StdMetrics.ms_v_charge_state->AsString();
     if (charge_state == "charging")
         …
 
 If you'd rather use the old numeric state codes, there are utility functions in the ovms_utils module for encoding / decoding them.
 
 As Mark wrote, you get the float value by the AsFloat() method and can compare that directly to a float literal. We haven't added comparison operators to the metrics classes yet, just assignment (and that needs casts in many cases). If you'd like to add more operators/types, go ahead.
 
 
 

 
     - what is the current way of doing net_req_notification     
 
  Not required in v3. If you change a metric that needs notification, the serverv2 and serverv3 will act appropriately. 
 
 And if you want to customize standard notifications, you can do so by overloading the vehicle methods:
 
     virtual void NotifyChargeState();
     virtual void NotifyChargeStart();
     virtual void NotifyHeatingStart();
     virtual void NotifyChargeStopped();
     virtual void NotifyChargeDone();
     virtual void NotifyValetEnabled();
     virtual void NotifyValetDisabled();
     virtual void NotifyValetHood();
     virtual void NotifyValetTrunk();
     virtual void NotifyAlarmSounding();
     virtual void NotifyAlarmStopped();
     virtual void Notify12vCritical();
     virtual void Notify12vRecovered();
 
 If you want to add vehicle specific notifications, take a look at the Twizy module (rt_notify).
 
 You can simply send a notification from any command output by issuing MyNotify.NotifyCommand() (att: stack intensive) or send any string by MyNotify.NotifyString(). There are also varargs versions with "f" suffix acting like printf.
 
 For building strings from command methods, there is the StringWriter class, that's a std::string that can be used as an OvmsWriter. Example:
 
     StringWriter buf(200);
     CommandStat(COMMAND_RESULT_NORMAL, &buf);
     MyNotify.NotifyString("info", "charge.sufficient", buf.c_str());
 
 Best practice is to send notifications from within an event handler (e.g. Ticker1), so they run asynchronously in the event task context instead of blocking something.
 
 Regards,
 Michael
 
 PS: we should start collecting these pieces for the developer manual, the general system API is quite mature now
 
 
 
On 19 Jul 2018, at 6:00 AM, Nikolay Shishkov <nshishkov at yahoo.com> wrote:  

      Hi,  I am working on the Think City EV code and have some questions. - what is the best way to signal that the charging connector is plugged? ms_v_charge_pilot? previously it was cardoorbits1.  
  - what is the best way to compare OvmsMetricStrings? Or should I dublicate the state in an enum and use that? 
  - what is the best way to compare the OvmsMetricFloat to a literal float? 
  - what is the current way of doing net_req_notification 
  Thanks in advance, Nikolay      On Tuesday, July 17, 2018, 3:37:49 AM GMT+2, Mark Webb-Johnson <mark at webb-johnson.net> wrote:  
      
  
 
 -- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
 _______________________________________________
OvmsDev mailing list
OvmsDev at lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev
  

_______________________________________________
OvmsDev mailing list
OvmsDev at lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev

_______________________________________________
OvmsDev mailing list
OvmsDev at lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev
    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20180726/3c61597f/attachment-0001.html>


More information about the OvmsDev mailing list