-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
asn1tools.codecs.ber.DecodeTagError: #146
Comments
I have a similar problem. 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:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The text was updated successfully, but these errors were encountered: