nescc-mig(1) | General Commands Manual | nescc-mig(1) |
nescc-mig - message interface generator for nesC
nescc-mig [any nescc option] [tool-specific options]
[-o output-file] [-nescc=driver]
tool msg-format-file message-type
nescc-mig is a tool to generate code to process nesC messages (which are specified by C types). The tool argument specifies what tool should be generated, the message-type specifies the C type of the message you wish to process and msg-format-file specifies a nesC file which uses that type. The message type must be defined with struct message-type, nx_struct message-type, union message-type, nx_union message-type.
When used with types whose layout is platform-dependent (i.e., not defined with nx_struct or nx_union), it is important to specify the correct nescc target architecture option (-fnesc-target=...). If you are invoking nescc-mig indirectly via mig, you can use the ncc -target=... option instead.
If an enum constant named AM_message_type (with message_type capitalized) is found, then the value of that constant is assumed to be the active message type for message-type. If you need access to other constants from your nesC application, please consult the nescc-ncg man page.
The current tools are java, csharp, python and C, which generate java, C#, python and C code to encode and decode messages.
You can pass any nescc option, as well as
This tool generates a java class to encode or decode a nesC message, basing itself on the net.tinyos.message infrastructure. It accepts the following options:
For each field fname of structure message-type, there are the following methods (the bit offset and size methods are useful for structures containing bitfields):
Embedded structures in message-type are expanded, using _ to separate the structure name and its fields.
A number of extra methods are present for fields that are arrays:
If the array is 1-dimensional and the elements are one byte, then the following methods exist:
The getElement_..., setElement_..., offset_... and offsetBits_... methods take one argument per array dimension. These methods report errors if the array index is out of bounds. If an array has a maximum size of 0, mig assumes it represents a variable-size array and does not check the corresponding array index.
The data for a message is stored in an array, with explicit base and length information. The constructors can either allocate this array, receive it as an explicit argument or extract if from another message. The base and length can also be optionally passed to these constructors.
The optional length argument overrides the default size of sizeof(message-type); this is useful for variable-size messages. The use of an explicit base is helpful for messages embedded in other messages.
The generated class also has an amType() method which returns the message's active message type, or -1 if no AM_message_type constant was found.
This tool generates a C# class to encode or decode a nesC message. It accepts the following options:
The methods in the generated class are the same as for the Java tool.
This tool generates a Python class to encode or decode a nesC message. It accepts the following options:
The methods in the generated class are the same as for the Java tool.
This tool generates a C header file (.h) with constants describing the type's layout, and a C module (.c) with functions to get and set each field. You must pass the .h file's name to nescc-mig using -o.
The C tool accepts the following option:
For each non-array field fname of structure message-type, the following functions and constants are generated:
For each array field fname of structure message-type, the following functions and constants are generated:
Embedded structures in message-type are expanded, using _ to separate the structure name and its fields. A field of an array of embedded structures is considered to be an array.
nescc-mig reports an error if nescc cannot compile msg-format-file, if message-type isn't found or if it contains pointers.
The generated code for the various tools refer to libraries that are distributed with the TinyOS operating system. Please refer to that project's documentation for more information.
April 27, 2004 |