Open HalaHelmi opened 2 years ago
I have a similar problem. asn1tools.codecs.ber.DecodeTagError when using two "SEQUENCE OF" in "CHOICE" My ASN.1 file:
A DEFINITIONS::=BEGIN
B::=CHOICE{
c SEQUENCE OF INTEGER,
d SEQUENCE OF IA5String
}
END
My python code:
import asn1tools
asn_file = asn1tools.compile_files('./test.asn',codec='ber')
encoded = asn_file.encode('B', ('c', [1]))
print(hex(int.from_bytes(encoded, byteorder='big')))
decoded = asn_file.decode('B', encoded)
print(decoded)
Output:
C:\Users\xxx\Desktop\code\esl_file\venv\Scripts\python.exe C:/Users/xxx/Desktop/code/esl_file/test.py
0x3003020101
Traceback (most recent call last):
File "C:\Users\xxx\Desktop\code\esl_file\test.py", line 5, in <module>
decoded = asn_file.decode('B', encoded)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\compiler.py", line 163, in decode
decoded = type_.decode(data)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 1475, in decode
return self.decode_with_length(data)[0]
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 1483, in decode_with_length
decoded, offset = self._type.decode(bytearray(data), 0)
File "C:\Usersxxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\__init__.py", line 158, in new_method
raise e
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\__init__.py", line 153, in new_method
return method(self, *args, **kwargs)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 1122, in decode
decoded, offset = member.decode(data, offset)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\__init__.py", line 158, in new_method
raise e
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\__init__.py", line 153, in new_method
return method(self, *args, **kwargs)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 436, in decode
return self._decode(data, tag_end_offset)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 749, in _decode
check_decode_error(self.element_type, decoded_element, data, offset)
File "C:\Users\xxx\Desktop\code\esl_file\venv\lib\site-packages\asn1tools\codecs\ber.py", line 110, in check_decode_error
raise DecodeTagError(asn_type, data, offset, location=asn_type.name)
asn1tools.codecs.ber.DecodeTagError: B.d: Expected IA5String with tag '16', but got '02'. (At offset: 2)
The OSS Nokalva playground gives a compile error: line 4 (A): A0100E: Duplicate tag in type B: element 'c' (line 3) and element 'd' (line 4).
asn1tools
should probably give an compile error as well, but I guess there is a bug.
Hi,,
I'm facing a problem while I'm trying to decode multiple cdrs in .ber files. it decode the only the first bunch of cdrs and then gave me this error.
while it works for some other files correctly. asn1tools.codecs.ber.DecodeTagError: ChargingDataOutputRecord: Expected CHOICE(ChargingDataOutputRecord) with tags ['a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6'], but got '00'. (At offset: 0)
Thanks in advance.