nescc-mig(1)
π NAME π
okay so bestie, welcome to nescc-mig β the message interface generator for nesC πΈ. That's the section 1 of the manual, General Commands Manual, and it's about to be your new obsession, fr fr.
π¦ SYNOPSIS π¦
nescc-mig [any nescc option] [tool-specific options]
[-o output-file] [-nescc=driver]
tool msg-format-file message-type
β¨ DESCRIPTION β¨
so nescc-mig is the tool that generates code to process nesC messages (and those messages are specified by C types, periodt). Here's the vibe check on the arguments:
toolβ tells it what tool should be generated. it's giving "pick your fighter" πmessage-typeβ the C type of the message you wish to processmsg-format-fileβ a nesC file that uses that type
and listen, your message type has to be defined as one of these, exactly:
struct message-type, nx_struct message-type, union message-type, nx_union message-type.
π¨ IMPORTANT CAVEAT π¨ β when you're working with types whose layout is platform-dependent (aka not defined withnx_structornx_union), it is important that you specify the correct nescc target architecture option:-fnesc-target=.... no cap. and if you're invokingnescc-migindirectly viamig, you can use thencc -target=...option instead. slay π«Ά
Also, cute little easter egg: if an enum constant named AM_message_type is found (that's with message_type capitalized, iykyk), then the value of that constant is assumed to be the active message type for message-type. π« And if you need access to other constants from your nesC application, please consult the nescc-ncg man page β she's got the lore.
The current tools are java, csharp, python and C, which generate java, C#, python and C code to encode and decode messages. iconic lineup honestly π
π OPTIONS π
You can pass any nescc option, as well as:
-o output-fileβ specify the file in which to output the generated code. π-nescc=driverβ usedriverinstead ofnesccto extract type layout information. for example, if you specify-nescc=ncc, you can usenescc-migto extract type information from TinyOS applications (which are normally compiled withncc). πtool-specific optionsβ see below, bestie. β¬οΈ
β JAVA TOOL π
This tool generates a java class to encode or decode a nesC message, basing itself on the net.tinyos.message infrastructure. She accepts the following options:
-java-classname=full-class-nameβ this option is required and specifies the package and name of the generated class. and heads up: if thefull-class-namehas no.in it, then no package directive is included in the output. π-java-extends=class-nameβ specify the class the generated class will extend. the default isnet.tinyos.message.Message.
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):
get_fnameβ get field's valueset_fnameβ set field's valueoffsetBits_fnameβ return bit offset of field inmessage-typeoffset_fnameβ return byte offset of field inmessage-typesizeBits_fnameβ return size in bits of field (not for arrays)size_fnameβ return size in bytes of field (not for arrays) (absent iffnameis a bitfield)isSigned_fnameβ returntrueiffnameis of a signed typeisArray_fnameβ returntrueiffnameis an array
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:
getElement_fnameβ get an element of the arraysetElement_fnameβ set an element of the arrayelementSize_fnameβ return size in bytes of array elementselementSizeBits_fnameβ return size in bits of array elementsnumDimensions_fnameβ return number of dimensions of the arraynumElements_fnameβ return number of elements of the array for a given dimension (left-most dimension is numbered0) β the dimension is optional for 1-dimensional arraystotalSize_fnameβ return size in bytes of the array (absent if the array is variable-size)totalSizeBits_fnameβ return size in bits of the array (absent if the array is variable-size)
If the array is 1-dimensional and the elements are one byte, then these extra little cuties exist:
getString_fnameβ build a Java string from the array assuming it contains a C-style null-terminated stringsetString_fnameβ set the array to a C-style null-terminated string given a java string
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. π¨ And 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. noted. π
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 it 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. π«
π C# TOOL π
This tool generates a C# class to encode or decode a nesC message. She accepts the following options:
-csharp-classname=full-class-nameβ this option is required and specifies the namespace and name of the generated class. If thefull-class-namehas no., then no namespace directive is included in the output. π-csharp-extends=class-nameβ specify the class the generated class will extend. the default istinyos.message.Message.
The methods in the generated class are the same as for the Java tool. β¨
π PYTHON TOOL π
This tool generates a Python class to encode or decode a nesC message. She accepts the following options:
-python-classname=full-class-nameβ this option is required and specifies the name of the generated class.-python-extends=class-nameβ specify the class the generated class will extend. the default istinyos.message.Message.Message.
The methods in the generated class are the same as for the Java tool. β¨
π₯ C 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. don't forget, bestie, it's not optional π«
The C tool accepts the following option:
-c-prefix=prefixβ this option specifies the prefix to attach to the generated constants and functions. If omitted,message-typeis used.
For each non-array field fname of structure message-type, the following functions and constants are generated:
prefix_fname_get()β get field's valueprefix_fname_set()β get field's valueprefix_fname_OFFSETBITSβ bit offset of fieldprefix_fname_OFFSETβ byte offset of fieldprefix_fname_SIZEBITSβ size in bits of fieldprefix_fname_SIZEβ size in bytes of field
For each array field fname of structure message-type, the following functions and constants are generated:
prefix_fname_get()β get field's valueprefix_fname_set()β get field's valueprefix_fname_offsetbits()β bit offset of array elementprefix_fname_offset()β byte offset of array elementprefix_fname_ELEMENTSIZEBITSβ size in bits of array elementprefix_fname_ELEMENTSIZEβ size in bytes of array elementprefix_fname_NUMELEMENTSβ number of elements in array (absent for variable-sized arrays)prefix_fname_NUMELEMENTS_iβ size ofith array dimension
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. π§©
π ERRORS π
nescc-mig reports an error if:
nescccannot compilemsg-format-fileπmessage-typeisn't found- it contains pointers
β οΈ yeah, pointers? instant no. she said nope. π ββοΈ
π«Ά SEE ALSO π«Ά
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. π
and that's the whole page, bestie β this one's from April 27, 2004, straight out of the General Commands Manual, and it lives in section 1 as nescc-mig(1). go generate some message interfaces, you main character π
β¨π¦
π¦ where this page comes from
- debian bookworm: nescc 1.3.5-1.1 Β· GPL-2.0-only
- ubuntu jammy: nescc 1.3.5-1.1build1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms