NAME

ncg - extract constants from nesC files

SYNOPSIS

ncg [any ncc option] [-o output-file] [-java-classname=full-class-name] [-java-extends=class-name] tool nesC-file filenames-or-constant-names...

DESCRIPTION

ncg is a tool to extract constants from nesC files for use with other applications. It is typically used in conjunction with mig (which generates code to process TinyOS messages) to extract constants that are used in particular TinyOS messages (e.g., constants representing various commands).

The tool argument specifies what tool should be generated, the nesC-file specifies your application's top-level nesC file. If your constants are all in a single .h file that does not depend on any other files, then you can specify the .h file directly as the msg-format-file. Each filenames-or-constant-names is either a constant name (if it consists only of letters, numbers and _) or a filename. In the former case, the specified constant will be extracted, in the latter case all constants from the specified C file will be extracted. Only constants declared in C files will be found by ncg.

Currently there is only one tool, java, which generates a java class that contains the values of the requested constants. The -java-* options are specific to this tool. It is described below.

-o output-file

specify the file in which to output the generated code.
ncg works by invoking ncc. It will generally be necessary to pass some options through to ncc so that your file can be compiled. Some commonly necessary options are:

-target=known-tinyos-platform

specify the target architecture of your TinyOS application which is generating or receiving messages. So, e.g., if compiling your application for tossim specify -target=pc. The default target is ncc's default target.
-I dir
specify an additional search directory for nesC components.
-board=known-tinyos-sensorboard
specify one (or more) sensor boards. This effects the search path and preprocessor symbols (and may therefore be necessary when feeding a file to ncg).

JAVA TOOL

This tool generates a java class with the values of the requested constants. These constant will be public final static and have a type chosen from byte, short, char, int, long (the chosen type will be the first one in this list that can hold the constants value - this reduces the need for casts).

The java tool accepts the following options:

-java-classname=full-class-name

this option is required and specifies the package and name of the generated class. If the full-class-name has no '.', then no package directive is included in the output.
-java-extends=class-name:
specify the class the generated class will extend. The default is net.tinyos.message.Message.

EXAMPLE

APPDIR=`ncc -print-tosdir`/lib/FS
ncg -I%T/lib/FS -java-classname=net.tinyos.matchbox.FS java $APPDIR/Remote.nc Matchbox.h Remote.h -oFS.java

ERRORS

ncg reports an error if ncc cannot compile nesC-file.

SEE ALSO

ncc mig