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
}
user3206440
  • 4,749
  • 15
  • 75
  • 132
  • 1
    https://github.com/eerimoq/asn1tools (if this is the one) 'Parametrization (X.683) is not yet supported' (see my answer for a work around) – YaFred Jan 20 '20 at 09:24
  • The library referenced is correct. Is there any alternative library that would support `Parametrization (X.683)` ? – user3206440 Jan 20 '20 at 09:30
  • At first glance, the tool you are using is well and alive (so my work around is worth a try). Another python tool is https://github.com/etingof/pyasn1 (I don't know if it supports parameterization) – YaFred Jan 20 '20 at 09:50
  • @user320644 Try pycrate project - https://github.com/P1sec/pycrate. – Vasil Velichkov Jan 20 '20 at 11:16

1 Answers1

4

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
}
YaFred
  • 9,698
  • 3
  • 28
  • 40