Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging ASN.1 files #219

Closed
MartijnHarmenzon opened this issue Feb 6, 2023 · 1 comment
Closed

Merging ASN.1 files #219

MartijnHarmenzon opened this issue Feb 6, 2023 · 1 comment

Comments

@MartijnHarmenzon
Copy link

MartijnHarmenzon commented Feb 6, 2023

I am trying to merge these files:
https://forge.etsi.org/rep/ITS/asn1/cdd_ts102894_2/-/blob/release2/ETSI-ITS-CDD.asn
https://standards.iso.org/iso/ts/19091/ed-2/en/ISO-TS-19091-addgrp-C-2018.asn
https://forge.etsi.org/rep/ITS/asn1/is_ts103301/-/blob/v1.3.1/SPATEM-PDU-Descriptions.asn

But getting the error:

yasn1.error.PyAsn1Error: <TagSet object, tags 64:0:9> not in asn1Spec: None

This is my code:

from pyasn1.codec.ber import decoder, encoder
from pyasn1.type import univ


if __name__ == "__main__":
    with open("ETSI/ITS-Container.asn", "r") as module1_file:
        module1 = module1_file.read()

    with open("ETSI/ISO-TS-19091-addgrp-C-2018.asn", "r") as module2_file:
        module2 = module2_file.read()

    with open("ETSI/SPATEM-PDU-Descriptions.asn", "r") as module3_file:
        module3 = module3_file.read()

    # Decode the contents of the files into ASN.1 objects
    module1_obj, _ = decoder.decode(module1.encode())
    module2_obj, _ = decoder.decode(module2.encode())
    module3_obj, _ = decoder.decode(module3.encode())

    # Concatenate the contents of the objects into a single sequence
    merged_module_obj = univ.Sequence(module1_obj + module2_obj + module3_obj)

    # Encode the merged object back into a BER-encoded string
    merged_module = bytes(encoder.encode(merged_module_obj))

    # Write the merged module to a file
    with open("merged_module.asn", "wb") as merged_module_file:
        merged_module_file.write(merged_module)

Help is much appreciated.

@lextm
Copy link

lextm commented Feb 6, 2023

You should post to https://github.com/pyasn1/pyasn1/issues For more details, you can read etingof/pysnmp/issues/429

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants