Merging ASN.1 files
MartijnHarmenzon opened this issue · 1 comments
MartijnHarmenzon commented
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 commented
You should post to https://github.com/pyasn1/pyasn1/issues For more details, you can read etingof/pysnmp/issues/429