P1sec / pycrate

A Python library to ease the development of encoders and decoders for various protocols and file formats; contains ASN.1 and CSN.1 compilers.
GNU Lesser General Public License v2.1
381 stars 132 forks source link

Encoding asn1 format string #124

Closed mamkarim closed 3 years ago

mamkarim commented 3 years ago

Hi, I am trying to encode asn1 format string to dict object, but getting empty value. I tried to find a solution in the wiki and issues, but no luck. Any help will be very much appreciated. Below is my code -

from pycrate_asn1rt.utils import * from binascii import unhexlify, hexlify from pycrate_asn1dir import RRC3G

pcch = RRC3G.Class_definitions.PCCH_Message pcch.from_uper(unhexlify('4455c803999055c601b95855aa06b09e'))

test = pcch.from_asn1(pcch.to_asn1()) print('test',test)

print(pcch.set_val(test))

p1-bmu commented 3 years ago

Maybe you should exercise as proposed in the wiki first: https://github.com/P1sec/pycrate/wiki/Using-the-pycrate-asn1-runtime. As you can see from here, and the source code and the doc strings, neither methods from_asn1() nor set_val() returns ; therefore you will only get None printed...

mamkarim commented 3 years ago

Thanks for the hint. understood. Much appreciated.

from pycrate_asn1rt.utils import * from binascii import unhexlify, hexlify from pycrate_asn1dir import RRC3G

pcch = RRC3G.Class_definitions.PCCH_Message pcch.from_uper(unhexlify('4455c803999055c601b95855aa06b09e'))

pcch.from_asn1(pcch.to_asn1()) test = pcch() print('test',test)