Accessing ASN1 choice values
Dear developers. I am trying to access values from a choice in ASN1 and in my humble opinion there might be a bug there, for example:
from pycrate_asn1dir.RRCLTE import EUTRA_RRC_Definitions
a = EUTRA_RRC_Definitions.UL_DCCH_Message
a.set_val({'message': ('messageClassExtension', ('c2', ('ueAssistanceInformation-r11', {'criticalExtensions': ('c1', ('ueAssistanceInformation-r11', {}))})))})
print(a.get_at(['message', 'messageClassExtension', 'c2']).get_val())
I might misunderstood the API, but I would expect something to be printed and the get_val to return a non None value - but it returns None.
I would really appreciate your help, thanks!
set_val(), set_val_at(), get_val() and get_val_at() are the methods to work on the values.
Here, get_at() returns the sub-object, which has however no value, as an object's value always lives at its root, not in sub-objects.
So assuming I want to check which of the choices exists in the object, the only two way are to catch the exception get_val_at() raises each time it is given a path or to implement a hierarchy-to-list function?
You can select the parent value, and check which choice is taken as the 1st component of the value.