That's very cool, thanks.
Btw: truly scary is the car system that doesn't provide even the
most simple protection against brute force attacks.
I’ve enabled the javascript support in the ovms_scripts module.
You can now write script files using the javascript language, and
they will be run by the duktape engine. Any script file ending
with “.js” extension will be treated as javascript.
I’ve also added OvmsCommand and OvmsPrint extension
commands.
Two examples:
OVMS# vfs cat
/store/scripts/helloworld.js
OvmsPrint("Hello
world!\n”);
OVMS# . helloworld.js
Hello world!
OVMS# vfs cat
/store/scripts/ota.js
OvmsPrint(OvmsCommand("ota status"));
OVMS# . ota.js
Running partition: factory
Boot partition: factory
Firmware: 3.1.008-40-g9254170-dirty/factory/edge
(build idf v3.1-dev-1583-g0fb2019f Jul 9 2018 08:49:48)
Server Available: 3.1.008-37-g939416c (no update
required)
Sat Jul 7 16:00:45 UTC 2018 Automated build (markhk8)
...
A useful example would be to have a script that
runs on location.leave, and checks the v.e.gear metric for
vehicle in Drive, before firing off the homelink to close the
garage door.
Like all good things, the opportunity for evil is
forever prevalent (and truly scary):
OVMS# vfs cat
/store/scripts/bruteforce.js
for (var pin = 1000; pin
< 10000; pin++)
{
OvmsCommand("unlock " + pin);
}
OVMS# . bruteforce.js
V (1421374) canlog:
TX can1 id 102 len 8: 0b 03 00 00 e8 03 00 40 | .......@
V (1421374) canlog:
TX can1 id 102 len 8: 0b 03 00 00 e9 03 00 40 | .......@
V (1421374) canlog:
TX can1 id 102 len 8: 0b 03 00 00 ea 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 eb 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 ec 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 ed 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 ee 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 ef 03 00 40 | .......@
V (1421384) canlog:
TX can1 id 102 len 8: 0b 03 00 00 f0 03 00 40 | .......@
V (1421394) canlog:
TX can1 id 102 len 8: 0b 03 00 00 f1 03 00 40 | .......@
...
I’ll leave it up to an exercise to the reader to
change that script to use DukOvmsMetricValue() to monitor
the v.e.locked metric to record success.
Note that this is very hacky and experimental at
the moment. A better approach seems to be to have a javascript
task running, initialised at boot with a user’s javascript
program. That can have timers, and whatever else it needs, to
do it’s stuff. Then, scripts executed are run in the context
of that task. The current implementation is really just a
proof of concept. The OvmsPrint is particularly kludgy (a
better implementation would be to hook to the duktape I/O
system). Duktape is also currently running in internal RAM,
although changing it to use SPI RAM should not be hard.
Regards, Mark.
Begin forwarded message:
From: GitHub
_______________________________________________
OvmsDev mailing list
OvmsDev@lists.openvehicles.com
http://lists.openvehicles.com/mailman/listinfo/ovmsdev