Recent Changes - Search:

edit SideBar

DuktapeCodeGeneration

The idea here is to use the Ptolemy II code generator to generate C code for the Duktape Host.

Accessor Duktape Code Generation Slide from Edward A. Lee, "Accessors Tutorial: Bringing Sanity to IoT's use of Callbacks", February 24, 2016.

DE C Code Generator

  • Make adapter for JS actor.
  • Impl. get and send parts of API.
  • Impl as C macros.
  • Define JS fn that can be called from DukTape, then invoke fire().
  • Generate the code once as a standalone program.

Status: 3/11/16: template code set up, example compiles and evaluates the contents of the script PortParameters, but the duktape host environment is not present.

Example

  1. See Ptolemy II for how to build from the svn repository
  2. Invoke the code generator with:
    $PTII/bin/ptcg \
         -generatorPackageList generic.program.procedural.c.duktape \
         $PTII/ptolemy/cg/adapter/generic/program/procedural/c/duktape/adapters/ptolemy/actor/lib/gui/test/auto/TestComposite.xml
  3. The code will be generated in ~/cg, make will run and ~/cg/TestComposite will be run

Note that this example is not yet complete

Files to modify

The Ptolemy II Code Generator has many files, but fortunately, we only need to modify a few.

  • $PTII/ptolemy/cg/adapter/generic/program/procedural/c/duktape/adapters/org/terraswarm/accessor/JSAccessor.c This is where the C code is located that is used when generating code for the Ptolemy II JSAccess actors

See Also

Edit - History - Print - Recent Changes - Search
Page last modified on March 11, 2016, at 03:56 PM