[Ovmsdev] Fwd: How does TPMS work now?

Michael Balzer dexter at expeedo.de
Mon Jan 25 19:59:12 HKT 2021


sharkcow,

the metrics shell command currently only supports getting & setting full 
values, i.e. all values at once on a vector metric.

Workaround: use Javascript:

sc ev 'm="v.t.health"; v=OvmsMetrics.Value(m); v[2]=80; 
OvmsCommand.Exec("met set "+m+" "+v);'

Not very handy that way. You can define a function for that in your 
ovmsmain.js:

function metricSetElem(metric, index, value) {
   vector = OvmsMetrics.Value(metric);
   vector[index] = value;
OvmsCommand.Exec("metric set " + metric + " " + vector);
}

…and then call it like this:

sc ev 'metricSetElem("v.t.health", 2, 80)'

Or you could add support to address single vector elements to the 
"metric" command.

OTOH, setting a metric manually is normally only needed during 
development though, so you already have artificial test values, why not 
simply set the whole vector?


Regarding reading vector metrics in a web plugin, that's straight 
forward: the vector is stored as an array in the global metrics object. 
Addressing elements is as simple as…

metrics["v.t.health"][2]

…and of course you can do everything you normally can do with an array.

Setting metric values from the web UI isn't a standard operation, so you 
need to call the "metrics" command for that here as well, e.g. via 
loadcmd().

Regards,
Michael


Am 25.01.21 um 09:07 schrieb sharkcow:
> Hello all,
>
> probably this is a stupid question, but can I set/read individual
> elements of an array on the command line? More importantly, is there a
> way to access individual elements in WebPlugins (I know I could write a
> script, but that seems to be overkill and I'd first have to find out
> exactly how to do it :-/)
>
> Thanks!
>
> sharkcow
>
>
> Am 23.01.21 um 18:22 schrieb Michael Balzer:
>> It seems the list server still has issues:
>>
>>
>> -------- Weitergeleitete Nachricht --------
>> Betreff:     Re: [Ovmsdev] How does TPMS work now?
>> Datum:     Mon, 18 Jan 2021 07:54:31 +0100
>> Von:     Michael Balzer <dexter at expeedo.de>
>> An:     ovmsdev at lists.openvehicles.com
>>
>>
>>
>> Craig,
>>
>> vector metrics can (as all metrics btw) be set by their string
>> representation, i.e.
>>
>> metrics set v.t.pressure 210.29,210.29,210.29,210.29
>>
>> …and all TPMS metrics (also the new ones) are persistent now, see my
>> post "extended metrics persistence".
>>
>> Regarding the sensor sets, I haven't used them yet, and documentation is
>> lacking, so you need to check the source.
>>
>> Regards,
>> Michael
>>
>>
>> Am 18.01.21 um 04:11 schrieb Craig Leres:
>>> It used to be possible to manually set tire pressure with:
>>>
>>>     metrics set v.tp.fl.p 210.29
>>>     metrics set v.tp.fr.p 210.29
>>>     metrics set v.tp.rl.p 210.29
>>>     metrics set v.tp.rr.p 210.29
>>>
>>> but after upgrading to the latest persistent metrics code I see these
>>> are all gone.
>>>
>>> I looked at the tpms command but it seems to be designed to track
>>> different sets of tpms sensor id numbers.
>>>
>>> Is it possible to set these from the command line? Are tpms tire
>>> pressures (and temperatures) still persistent across warm reboots? Is
>>> my problem that these are stored in vectors now and there is not yet a
>>> way to manipulate them from the command line?
>>>
>>>         Craig
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.openvehicles.com
>>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>
>> -- 
>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>>
>>
>>
>>
>> -- 
>> 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

-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26


-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20210125/023d39d3/attachment-0001.sig>


More information about the OvmsDev mailing list