<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Tom,<div class=""><br class=""></div><div class="">Thanks for finding this, and pointing it out.</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class="">I think I have a better implementation of this, by exposing the ostringstream precision+fixed parameters to metric accessor AsString(). That means we can do this, even if converting between units. That is committed, and pushed, so I don't think this pull is needed and can be dropped.</div><div class=""><br class=""></div><div class="">This is implemented as:</div><div class=""><br class=""></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> virtual std::string AsString(const char* defvalue = "", metric_unit_t units = Other, int precision = -1);</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""><br class=""></span></font></div><div class=""><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> if (precision > 0)</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> {</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> ss.precision(precision); // Set desired precision</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> ss << fixed;</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 18px;" class=""> }</span></font></div></div></blockquote><div class=""><br class=""></div><div class="">I think that is a pretty clean implementation, and backwards-compatible. I did consider putting precision as a parameter to the metric itself, but different protocols may require different precisions, so probably better to have it exposed as it is. Maybe later we can have a default precision (in the same way as we have default units at the moment).</div><div class=""><br class=""></div><div class="">I also started the work on expanding the structure for ovms_server_v2 in general. It handles peer connections, and the blinking antenna on the App works well now. We should now be able to implement all of that as all the tools are in place. I think that should be my next target - get the ovms_server_v2 100% compatible with OVMS v2. The features/parameters are going to be a challenge.</div><div class=""><br class=""></div><div class="">Regards, Mark.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2 Nov 2017, at 4:57 PM, Tom Parker <<a href="mailto:tom@carrott.org" class="">tom@carrott.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I found that the android client crashes when my leaf with v3 hardware is charging. This is because it expects integers for some values and throws NumberFormatException parsing if it encounters a floating point string. The AsString() method on float metrics returns a floating point string and we have a bunch of metrics that used to be integers but are now (correctly) floats.<br class=""><br class="">I've sent a pull request with one possible solution <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/6" class="">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/6</a> but I'm pretty sure it's the wrong solution. I added a special case unit conversion to integer, but having done this I think an AsIntString(default, unit) method on the floating point metrics would be a more appropriate api. As I've written it, you can't combine a unit conversion and a rounding to integer.<br class=""><br class="">Thoughts?<br class=""><br class="">I also sent another pull request for a minimal implementation of the charger state related values in the v2 protocol, and some small leaf fixes.<br class=""><br class="">_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.teslaclub.hk" class="">OvmsDev@lists.teslaclub.hk</a><br class="">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev<br class=""></div></div></blockquote></div><br class=""></div></body></html>