<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Steve,<div class=""><br class=""></div><div class="">I get this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">OVMS# vfs cat /sd/helloworld.js</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">OvmsPrint("Hello world\n");</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class=""><br class=""></span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">OVMS# . /sd/helloworld.js</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">Hello world</span></font></div></blockquote><div class=""><div><br class=""></div><div>Maybe your SDKCONFIG different than mine? I am using the sdkconfig.default.hw31.</div><div><br class=""></div><div>Regards, Mark.</div><div><br class=""><blockquote type="cite" class=""><div class="">On 21 Dec 2018, at 9:56 AM, Stephen Casner <<a href="mailto:casner@acm.org" class="">casner@acm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Mark has asserted that the ACC functions could be implemented with<br class="">events and scripting. I'm trying to investigate how to do this, so<br class="">I'm reaching back a few months to this message about javascript<br class="">support. When I try Mark's helloworld.js example I get an immediate<br class="">crash, as shown below. Any idea why?<br class=""><br class=""> -- Steve<br class=""><br class="">OVMS# vfs cat /store/scripts/helloworld.js<br class="">OvmsPrint("Hello world!\n”);<br class="">OVMS# . helloworld.js<br class="">abort() was called at PC 0x401b8892 on core 1<br class="">0x401b8892: duk_default_fatal_handler at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class=""><br class="">Backtrace: 0x40097f6b:0x3ffe15b0 0x400980c3:0x3ffe15d0 0x401b8892:0x3ffe15f0 0x402481dd:0x3ffe1610 0x401ba5c7:0x3ffe1630 0x401c1ae9:0x3ffe1650 0x401c89da:0x3ffe1670 0x401c9e6b:0x3ffe1860 0x401c9ed1:0x3ffe1880 0x401ce2cf:0x3ffe18b0 0x400f0488:0x3ffe18d0 0x400f05b9:0x3ffe18f0 0x400e5766:0x3ffe1940 0x400e5849:0x3ffe1980 0x400e589a:0x3ffe19c0 0x400f06bf:0x3ffe19e0 0x400f3a8b:0x3ffe1a00 0x400f3c2e:0x3ffe1a60 0x400f06f3:0x3ffe1ad0 0x4024388e:0x3ffe1af0 0x400e3295:0x3ffe1b10 0x400e8635:0x3ffe1b40 0x400e87fd:0x3ffe1b70 0x400e3151:0x3ffe1b90 0x400e3160:0x3ffe1bb0 0x400f27b9:0x3ffe1bd0<br class="">0x40097f6b: invoke_abort at /Users/casner/src/github/esp-idf/components/esp32/panic.c:670<br class=""><br class="">0x400980c3: abort at /Users/casner/src/github/esp-idf/components/esp32/panic.c:670<br class=""><br class="">0x401b8892: duk_default_fatal_handler at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x402481dd: duk_fatal_raw at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27715<br class=""><br class="">0x401ba5c7: duk__uncaught_minimal at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""> (inlined by) duk_err_longjmp at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:49682<br class=""><br class="">0x401c1ae9: duk_throw_raw at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x401c89da: duk_js_compile at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x401c9e6b: duk__do_compile at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x401c9ed1: duk_compile_raw at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x401ce2cf: duk_eval_raw at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27339<br class=""><br class="">0x400f0488: script_ovms(bool, int, OvmsWriter*, char const*, __sFILE*, bool) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_script.cpp:77<br class=""><br class="">0x400f05b9: script_run(int, OvmsWriter*, OvmsCommand*, int, char const* const*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_script.cpp:133<br class=""><br class="">0x400e5766: OvmsCommand::Execute(int, OvmsWriter*, int, char const* const*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_command.cpp:162<br class=""><br class="">0x400e5849: OvmsCommand::Execute(int, OvmsWriter*, int, char const* const*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_command.cpp:162<br class=""><br class="">0x400e589a: OvmsCommandApp::Execute(int, OvmsWriter*, int, char const* const*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_command.cpp:162<br class=""><br class="">0x400f06bf: Execute(microrl*, int, char const* const*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_shell.cpp:48<br class=""><br class="">0x400f3a8b: new_line_handler at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/microrl/microrl.c:620<br class=""><br class="">0x400f3c2e: microrl_insert_char at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/microrl/microrl.c:668<br class=""><br class="">0x400f06f3: OvmsShell::ProcessChar(char) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_shell.cpp:73<br class=""><br class="">0x4024388e: OvmsShell::ProcessChars(char const*, int) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_shell.cpp:80 (discriminator 2)<br class=""><br class="">0x400e3295: ConsoleAsync::HandleDeviceEvent(void*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/console_async.cpp:170<br class=""><br class="">0x400e8635: OvmsConsole::Poll(unsigned int, void*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_console.cpp:151<br class=""><br class="">0x400e87fd: OvmsConsole::Service() at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/ovms_console.cpp:131 (discriminator 1)<br class=""><br class="">0x400e3151: ConsoleAsync::Service() at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/console_async.cpp:81<br class=""><br class="">0x400e3160: non-virtual thunk to ConsoleAsync::Service() at ??:?<br class=""><br class="">0x400f27b9: TaskBase::Task(void*) at /Users/casner/src/github/ovms/vehicle/OVMS.V3/main/task_base.cpp:156<br class=""><br class=""><br class="">Entering gdb stub now.<br class="">$T0b#e6GNU gdb (crosstool-NG) 7.10<br class="">Copyright (C) 2015 Free Software Foundation, Inc.<br class="">Reading symbols from /Users/casner/src/github/ovms/vehicle/OVMS.V3/build/ovms3.elf...done.<br class="">Remote debugging using /dev/cu.SLAB_USBtoUART<br class="">0x40097f6b in invoke_abort () at /Users/casner/src/github/esp-idf/components/esp32/panic.c:140<br class="">140<span class="Apple-tab-span" style="white-space:pre"> </span> *((int *) 0) = 0;<br class="">(gdb) bt<br class="">#0 0x40097f6b in invoke_abort () at /Users/casner/src/github/esp-idf/components/esp32/panic.c:140<br class="">#1 0x400980c6 in abort () at /Users/casner/src/github/esp-idf/components/esp32/panic.c:149<br class="">#2 0x401b8895 in duk_default_fatal_handler (udata=0x0, msg=0x3f4730b8 "uncaught error")<br class=""> at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:16634<br class="">#3 0x402481e0 in duk_fatal_raw (ctx=0x3ffd4478, err_msg=0x3f4730b8 "uncaught error")<br class=""> at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27715<br class="">#4 0x401ba5ca in duk__uncaught_minimal (thr=0x3ffd4478)<br class=""> at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:49604<br class="">#5 duk_err_longjmp (thr=0x3ffd4478)<br class=""> at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:49682<br class="">#6 0x401c1aec in duk_throw_raw (ctx=0x3ffd4478)<br class=""> at /Users/casner/src/github/ovms/vehicle/OVMS.V3/components/duktape/src/duktape.c:27697<br class="">Backtrace stopped: previous frame identical to this frame (corrupt stack?)<br class="">(gdb)<br class=""><br class=""><br class="">On Mon, 9 Jul 2018, Mark Webb-Johnson wrote:<br class=""><br class=""><blockquote type="cite" class=""><br class="">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.<br class=""><br class="">I’ve also added OvmsCommand and OvmsPrint extension commands.<br class=""><br class="">Two examples:<br class=""><br class="">OVMS# vfs cat /store/scripts/helloworld.js<br class="">OvmsPrint("Hello world!\n”);<br class=""><br class="">OVMS# . helloworld.js<br class="">Hello world!<br class=""><br class="">OVMS# vfs cat /store/scripts/ota.js<br class="">OvmsPrint(OvmsCommand("ota status"));<br class=""><br class="">OVMS# . ota.js<br class="">Running partition: factory<br class="">Boot partition: factory<br class="">Firmware: 3.1.008-40-g9254170-dirty/factory/edge (build idf v3.1-dev-1583-g0fb2019f Jul 9 2018 08:49:48)<br class="">Server Available: 3.1.008-37-g939416c (no update required)<br class=""><br class="">Sat Jul 7 16:00:45 UTC 2018 Automated build (markhk8)<br class="">...<br class=""><br class="">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.<br class=""><br class="">Like all good things, the opportunity for evil is forever prevalent (and truly scary):<br class=""><br class="">OVMS# vfs cat /store/scripts/bruteforce.js<br class="">for (var pin = 1000; pin < 10000; pin++)<br class=""> {<br class=""> OvmsCommand("unlock " + pin);<br class=""> }<br class=""><br class="">OVMS# . bruteforce.js<br class="">V (1421374) canlog: TX can1 id 102 len 8: 0b 03 00 00 e8 03 00 40 | .......@<br class="">V (1421374) canlog: TX can1 id 102 len 8: 0b 03 00 00 e9 03 00 40 | .......@<br class="">V (1421374) canlog: TX can1 id 102 len 8: 0b 03 00 00 ea 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 eb 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 ec 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 ed 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 ee 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 ef 03 00 40 | .......@<br class="">V (1421384) canlog: TX can1 id 102 len 8: 0b 03 00 00 f0 03 00 40 | .......@<br class="">V (1421394) canlog: TX can1 id 102 len 8: 0b 03 00 00 f1 03 00 40 | .......@<br class="">...<br class=""><br class="">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.<br class=""><br class="">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.<br class=""><br class="">Regards, Mark.<br class=""><br class=""><blockquote type="cite" class="">Begin forwarded message:<br class=""><br class="">From: GitHub<br class=""><br class=""> Branch: refs/heads/master<br class=""> Home: <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3" class="">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3</a><br class=""> Commit: f1736f927df582c5ff374ef5d8c3a565e8f67295<br class=""> <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/f1736f927df582c5ff374ef5d8c3a565e8f67295" class="">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/f1736f927df582c5ff374ef5d8c3a565e8f67295</a><br class=""> Author: Mark Webb-Johnson <<a href="mailto:mark@webb-johnson.net" class="">mark@webb-johnson.net</a>><br class=""> Date: 2018-07-09 (Mon, 09 Jul 2018)<br class=""><br class=""> Changed paths:<br class=""> M vehicle/OVMS.V3/main/ovms_command.cpp<br class=""><br class=""> Log Message:<br class=""> -----------<br class=""> Javascript: Add a OvmsCommand function to execute an OVMS command<br class=""><br class=""><br class=""> Commit: 69427f4ac0cf68dc462b05752936befe4be22256<br class=""> <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/69427f4ac0cf68dc462b05752936befe4be22256" class="">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/commit/69427f4ac0cf68dc462b05752936befe4be22256</a><br class=""> Author: Mark Webb-Johnson <<a href="mailto:mark@webb-johnson.net" class="">mark@webb-johnson.net</a>><br class=""> Date: 2018-07-09 (Mon, 09 Jul 2018)<br class=""><br class=""> Changed paths:<br class=""> M vehicle/OVMS.V3/main/ovms_script.cpp<br class=""><br class=""> Log Message:<br class=""> -----------<br class=""> Javascript: Add a OvmsPrint function to be able to print a string<br class="">JavaScript: Support .js script files (executed with javascript engine)<br class=""><br class=""><br class="">Compare: <a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/925417081d8e...69427f4ac0cf" class="">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/compare/925417081d8e...69427f4ac0cf</a><br class=""> **NOTE:** This service been marked for deprecation: <a href="https://developer.github.com/changes/2018-04-25-github-services-deprecation/" class="">https://developer.github.com/changes/2018-04-25-github-services-deprecation/</a><br class=""><br class=""> Functionality will be removed from <a href="http://GitHub.com" class="">GitHub.com</a> on January 31st, 2019.</blockquote></blockquote>_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.openvehicles.com" class="">OvmsDev@lists.openvehicles.com</a><br class="">http://lists.openvehicles.com/mailman/listinfo/ovmsdev<br class=""></div></div></blockquote></div><br class=""></div></body></html>