You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I remove the optional for the object 'Id2', the prettyPrint() works.
If I remove the object 'thirdList' the prettyPrint() works also.
Is there something wrong in my grammar?
Thank you very much for your help.
The text was updated successfully, but these errors were encountered:
Hello,
when I try to prettyPrint some data with this grammar, i've got an error :
pyasn1.error.PyAsn1Error: Constructed tag format expected.
from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
from binascii import hexlify, unhexlify
from pyasn1.codec.der import decoder
class Octet16(univ.OctetString):
pass
Octet16.subtypeSpec = constraint.ValueSizeConstraint(16, 16)
class OctetTo16(univ.OctetString):
pass
OctetTo16.subtypeSpec = constraint.ValueSizeConstraint(1, 16)
class MyListObject(univ.Choice):
pass
MyListObject.componentType = namedtype.NamedTypes(
namedtype.NamedType('firstList', univ.SequenceOf(componentType=univ.Integer()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
namedtype.NamedType('secondList', univ.SequenceOf(componentType=univ.Integer()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
namedtype.NamedType('thirdList', univ.SequenceOf(componentType=univ.Integer()).subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2)))
)
class MyObject(univ.Sequence):
pass
MyObject.componentType = namedtype.NamedTypes(
namedtype.NamedType('Id', char.UTF8String().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 0))),
namedtype.NamedType('Value', Octet16().subtype(implicitTag=tag.Tag(tag.tagClassApplication, tag.tagFormatSimple, 26))),
namedtype.NamedType('counter', univ.Integer().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 1))),
namedtype.OptionalNamedType('Id2', OctetTo16().subtype(implicitTag=tag.Tag(tag.tagClassContext, tag.tagFormatSimple, 2))),
namedtype.NamedType('objectList', MyListObject())
)
message = '30368009312E322E332E3434345A1089001012012341234012345678901224810102820F5FAFBBC335368BD6D6CA093745D32BA003020101'
code, substrate = decoder.decode(unhexlify(message), asn1Spec=MyObject())
print(code.prettyPrint())
If I remove the optional for the object 'Id2', the prettyPrint() works.
If I remove the object 'thirdList' the prettyPrint() works also.
Is there something wrong in my grammar?
Thank you very much for your help.
The text was updated successfully, but these errors were encountered: