User's Guide
And used as:
JSON.print(this);
There are a number of internal modules already provided with the firmware, and by convention
these are provided under the int/<modulename> namespace. The above JSON module is, for
example, provided as int/JSON and automatically loaded into the global context. These internal
modules can be directly used (so JSON.print(this) work directly).
Internal Modules
The JSON module is provided with a single ‘print’ method, to print out a given javascript object
in JSON format.
The PubSub module is provided to provide access to a Publish-Subscribe framework. In
particular, this framework is used to deliver events to the persistent JavaScript framework in a
high performance flexible manner. An example script to print out the ticker.10 event is:
var myTicker=function(msg,data){ print("Event: "+msg+"\n"); };
PubSub.subscribe("ticker.10",myTicker);
The above example created a function MyTicker in global context, to print out the provided
event name. Then, the PubSub.subscribe module method is used to subscribe to the ticker.10
event and have it call myTicker every ten seconds. The result is ‘Event: ticker.10’ printed once
every ten seconds.
Internal Objects and Functions/Methods
A number of OVMS objects have been exposed to the JavaScript engine, and are available for
use by custom scripts. These include:
assert(condition,message)
Assert that the given condition is true. If not, raise a JavaScript exception error with the given
message.
print(string)
Print the given string on the current terminal. If no terminal (for example a background script)
then print to the system console as an informational message.
OVMS v3 User Guide Page 49 / 86