Closed
Description
Hello,
I'm trying get an object iterating an ASN.1 object.
I have a rrcReconfiguration
message. I can iterate through it and get objects from most of the hierarchy, but when looking into the reportConfigToAddModList
, it always return the last item of the sequence.
I can access the values of the different items reportConfigToAddModList
if I iterate the serialization of the object.
I guess I miss something about the usage of the get_obj_at
function in this particular case of SEQ OF SQUENCE
Here is the code snippet to show it:
import binascii
import re
from pycrate_asn1dir import RRCNR
from pycrate_asn1rt.utils import get_val_at, get_obj_at
payload = """
00 29 56 04 07 80 01 04 49 c1 00 40 00 1c 01 40
30 02 f0 00 20 67 28 20 08 00 03 80 28 06 00 80
20 06 a2 90 03 80 24 04 c0 02 00 70 08 81 12 00
80 0f c0 02 00 28 c6 51 01 80 50 28 05 c1 00 48
24 12 c0 01 00 47 40 01 00 80 89 01 b0 48 ca 82
80 31 00 00 00 e0 fc 04 c7 3e c3 50 04 fc 00 84
02 12 ee 00 17 e4 05 f0 21 00 02 03 47 50 72 80
a8 0e 00 05 f0 20 00 00 02 2a 2c 02 02 08 02 00
00 04 08 02 00 00 0c 08 02 00 00 0e 08 02 00 00
02 22 0a 82 02 00 00 14 62 36 02 02 08 02 00 00
14 08 02 00 00 02 08 02 00 00 04 08 02 00 00 0c
08 02 00 00 0e 42 04 06 00 bc 03 7c 68 10 06 3e
33 e2 06 3e 23 e4
"""
msg = binascii.a2b_hex(re.sub(r"\s+", "", payload))
dl_dcch = RRCNR.NR_RRC_Definitions.DL_DCCH_Message
dl_dcch.from_uper(msg)
meas = get_obj_at(dl_dcch, ["message", "c1", "rrcReconfiguration", "criticalExtensions", "rrcReconfiguration", "measConfig"])
# reports is ReportConfigToAddModList ::= SEQUENCE (SIZE (1..maxReportConfigId)) OF ReportConfigToAddMod
reports = get_obj_at(meas, ["reportConfigToAddModList"])
# will only return the last item of the Seq of Sequence
for i in range(len(reports())):
# report is expected to be ReportConfigToAddMod ::= SEQUENCE {
# at the given index
report = get_obj_at(reports, [i])
print(f"--- {i} ---")
# But only 3rd and last item presented
print(report.to_json())
# will present the 3 differents report to add
for i in range(len(reports())):
report = reports()[i]
print(f"--- {i} ---")
print(report)
Any hints on get_obj_at
usage would be welcome.
Thanks