ASN1C Python Command Line Options

The following table shows a summary of the command line options that have meaning when Python code generation is selected:

Option Argument Description
-allow-ambig-tags   This option suppresses the check that is done for ambiguous tags within a SEQUENCE or SET type within a specification. Special code is generated for the decoder that assigns values to ambiguous elements within a SET in much the same way as would be done if the elements were declared to be in a SEQUENCE.
-asnstd

x680 
x208 
mixed

Parse ASN.1 syntax conforming to the specified standard. x680 (the default) refers to modern ASN.1 as specified in the ITU-T X.680-X.690 series of standards. x208 refers to the deprecated X.208 and X.209 standards. This syntax allowed the ANY construct as well as unnamed fields in SEQUENCE, SET, and CHOICE constructs. This option also allows for parsing and generation of code for ROSE OPERATION and ERROR macros and SNMP OBJECT-TYPE macros. The mixed option is used to specify a source file that contains modules with both X.208 and X.680 based syntax.
-ber None Generate functions that implement the Basic Encoding Rules (BER) as specified in the ASN.1 standards.
-compare None Generate a Python equality comparison method (__eq__) in each generated class.
-config <filename> This option is used to specify the name of a file containing configuration information for the source file being parsed. A full discussion of the contents of a configuration file is provided in the Compiler Configuration File section.
-copy None Generate copy_value methods in all non-trivial classes to produce cloned deep-copy of an object instance.
-depends None Generate Python source files that contain only the productions in the main file being compiled and items those productions depend on from IMPORT files.
-der None Generate functions that implement the Distinguished Encoding Rules (DER) as specified in the ASN.1 standards.
-genbuild [<filename>] This option is used to generate a build script for invoking the compiler with the set of command-line options given in the command. If no file name is specified, the file will be named build.bat on Windows or build.sh on Linux/Mac.

-genPrint 
            -print

None Generate print methods to print object contents. For Python, this includes an __str__ method to get a string representation of the object as well as a print_value to print the string representation to stdout.

-genTest 
            -test

None

Generate test to populate a PDU object with random test data. This code will be embedded in the body of a generated writer program; thus the option only results in code being generated if -writer is also specified.

-I <directory> This option is used to specify a directory that the compiler will search for ASN.1 source files for IMPORT items. Multiple –I qualifiers can be used to specify multiple directories to search.
-json or -jer None Generate encode/decode functions that implement the Javascript Object Notation (JSON) Encoding Rules (JER) as specified in the X.697 ASN.1 standard.
-jer+ None This option is used to generate encode/decode functions with ObjSys extensions to the Javascript Object Notation (JSON) Encoding Rules (JER) as specified in the X.697 ASN.1 standard. The chapter on JSON explains this option in detail.
-lax None Suppress generation of code to check constraints.
-list None Generate listing. This will dump the source code to the standard output device as it is parsed. This can be useful for finding parse errors.
-nodecode None Suppress generation of decode functions.
-noencode None Suppresses generation of encode functions.
-noIndefLen None Omit indefinite length tests in generated BER decode functions. These tests result in the generation of a fair amount of code. If you know that your application only uses definite length encoding, this option can result in a smaller code base size. Note that by definition it is enabled for DER code generations since these encoding rules do not use indefinite lengths.
-noOpenExt None Suppress the generation of open extension elements in constructs that contain extensibility markers. The purpose of the element is to collect any unknown items in a message. If an application does not care about these unknown items, it can use this option to reduce the size of the generated code and increase performance.
-noUniqueNames None

Turn off the capability to automatically generate unique names to resolve name collisions in the generated code. Name collisions can occur, for example, if two modules are being compiled that contain a production with the same name. A unique name is generated by prepending the module name to one of the productions to form a name of the form <module>_<name>.

Note that name collisions can also be manually resolved by using the typePrefix, enumPrefix, and valuePrefix configuration items (see the Compiler Configuration File section for more details)

-o <directory> Specify the name of a directory to which all of the generated files will be written.
-pdu <typeName>

Designate given type name to be a Protocol Definition Unit (PDU) type. By default, PDU types are determined to be types that are not referenced by any other types within a module. This option allows that behavior to be overridden. Note that for Python, the only effect this has is to cause this type to be used in generated reader/writer programs.

-reader None Generate a sample reader program to decode data.
-shortnames None Change the names generated by compiler for embedded types in constructed types.
-tables None Generate additional code for the handling of table constraints as defined in the X.682 standard.
-warnings None Output information on compiler generated warnings.
-writer None Generate a sample writer program to encode data.