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

decoded function decode only first line of CDR #127

Open
Benjalill opened this issue Sep 16, 2021 · 1 comment
Open

decoded function decode only first line of CDR #127

Benjalill opened this issue Sep 16, 2021 · 1 comment

Comments

@Benjalill
Copy link

Hello Eriq and Arsalan,

Hope you doing well. I'm trying to decode CDR from telecom. When i decode the CDR file (Which contains a lot of CDR), only the first CDR is decoded
CDR.zip
Do you have a tips for me please?

I would really appreciate your help guys.
Thanks

@Finndersen
Copy link
Collaborator

Hi @Benjalill ,
The .decode() method of the compiled schema will only decode the first record from the start of the byte data provided.
In order to decode multiple records you need to determine the length of each record decoded and then provide the data for the next record.
Something like:

schema = asn1tools.compile_files("CDR/cfx.asn")

with open("CDR/cdr", 'rb') as f:
    file_data = f.read()

records = []
index = 0
file_len = len(file_data)
while index < file_len:
    decoded_record, record_length = schema.decode_with_length('IMSRecord', file_data[index:])
    index += record_length
    records.append(decoded_record)

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