User Tools

Site Tools


projects:cometos:createmain

Creating hardware code from a Simulation

The python script /src/python/createMain.py helps you creating code for the hardware by parsing the ned file of your node in the simulation. You call the script by

python createMain.py <NED-FILE> [-el <FILE>] [-ll <FILE>] [-sled] [<CC-FILE>]

Arguments:

  • <NED-FILE> NED file to be parsed
  • -el <FILE> File with list of modules to be exchanged with others
  • -ll <FILE> File with list of modules to be left out
  • -sled Lets one of the LEDs of the board blink while running
  • <CC-FILE> Name of the output C++ file. Default is “main-created.cc”

To get good results by this script, you should follow some rules. The package name of the project should be the same as the name space. Header files should have the same name as the Modules. If a module can have several gates, it should be a template class with the first parameter being the number of gates.

The exchange file can be used to define modules in the simulation that need to be exchanged in the hardware implementation. Every line contains the name of the module, which needs to be exchanged, and the new module name, separated with comma. Empty lines and lines beginning with “#” are ignored.

The leave-out file can be used to define modules in the simulation that are not needed in the hardware implementation. Every line contains the name of one module. Empty lines and lines beginning with “#” are ignored.

It is also possible to set parameters in the NED File itself using comments.

// -leaveOut: ModuleName
// -exchange: ModuleName with OtherModuleName
// -setNamespace: NamespaceOf::ModuleName
// -setParameter: ModuleName: Param1, Param2, ..., ParamN
// -statusLED

The script also gives a suggestion about the content of the Makefile using the imported modules in the NED file. If the module namespaces resemble the folder structure of your source code, this should work just fine. By adding comments in the same line afterwards you can leave the modules out or exchange them with other ones. For eg.:

import cometos.auxiliary.TcpComm;	// changeTo cometos.platform.modules.SerialComm
import org.mixim.modules.phy.PhyLayer;	// onlySim
projects/cometos/createmain.txt · Last modified: 2014/09/18 10:20 by ti5mr