[Ovmsdev] Scripting

Mark Webb-Johnson mark at webb-johnson.net
Mon Sep 11 13:11:20 HKT 2017


Short story:

Welcome to the Open Vehicle Monitoring System (OVMS) - Async Console
OVMS > test javascript
Javascript 1+2=3

Long story:

The overall design of OVMS v3 is to use the command system for _everything_. That makes it extensible, flexible, and very very powerful. Then we have ‘events’ that trigger whenever important things happen (such as entering a geolocation, leaving a geolocation, starting a charge, completing a charge, etc).

Users of OVMS v2 have done incredible things with external server-based scripting (such as reacting to a charge start to control home automation), and things like ACC brought rudimentary scripting to v2. But, I’m interested in what could be done with a robust scripting language running _on_ the module itself. Not as a server-based function, but running on the actual device in the car (even in cases of no cellular connectivity).

We have a few use cases for this:

Startup configuration scripts. Things like enabling option modules, configuring wifi, etc.

General event reaction scripts. Doing things in response to events (like homelink when you enter a certain geolocation).

Mathematical evaluation. Things like the OBD ECU simulator reading values from metrics and outputting them as OBDII PID values (but highly customisable).

Custom scripts. Things we haven’t thought of.

I’ve looked at a bunch of scripting engines, and the most complete, standards compliant, flexibly licensed, seems to be ‘duktape’. A javascript library. Code side wise it is pretty big (to be standards compliant), but RAM usage is pretty optimal and highly configurable. C/C++ integration is simple and we can what we need to be callable from javascript. Overall, it is big and complex, but the clear winner in what is out there. The other advantage is that it doesn’t use exceptions, or other nasty C++ stuff, that causes problems with ESP32 use of other libraries.

So, with the commit I just made, Duktape is in OVMS v3. I’m now integrating it as the scripting library of choice. This takes our based framework firmware to about 1MB of flash. Say another 1/2MB for all the fancy stuff we want to add for networking and CAN bus tracing. That leaves 2.5MB for vehicle support. Should be fine.

I’m looking forward to seeing what people do with this.

Regards, Mark.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.teslaclub.hk/pipermail/ovmsdev/attachments/20170911/c88f041b/attachment.html>


More information about the OvmsDev mailing list