简体   繁体   中英

python asn1tools - failing compilation of asn.1

I'm trying to compile the 3GPP 38.331 ASN.1 specification here - which was extracted from the spec document

import asn1tools
rrc = asn1tools.compile_files('./data/asn/38331-f80.docx.asn', 'uper')

However this throws the error asn1tools.errors.CompileError: Type 'SetupRelease' not found in module 'NR-RRC-Definitions'.

I could see the SetupRelease definition in the .asn file

SetupRelease { ElementTypeParam } ::= CHOICE {
    release         NULL,
    setup           ElementTypeParam
}

It is very likely your compiler does not support parameterized types.

You can write the specification a different way (keeping it compatible)

Consider removing this from your spec ...

SetupRelease { ElementTypeParam } ::= CHOICE {
    release         NULL,
    setup           ElementTypeParam
}

Every time this type is referenced in the specification, replace ElementTypeParam with the actual type.

For example ...

LocationMeasurementIndication-IEs ::=       SEQUENCE {
    measurementIndication                       SetupRelease {LocationMeasurementInfo},
    lateNonCriticalExtension                    OCTET STRING                                                            OPTIONAL,
    nonCriticalExtension                        SEQUENCE{}                                                              OPTIONAL
}

Should become

LocationMeasurementIndication-IEs ::=       SEQUENCE {
    measurementIndication  CHOICE {
        release         NULL,
        setup           LocationMeasurementInfo
    },
    lateNonCriticalExtension   OCTET STRING   OPTIONAL,
    nonCriticalExtension    SEQUENCE{}        OPTIONAL
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM