pycrate icon indicating copy to clipboard operation
pycrate copied to clipboard

Dynamic compilation of an ASN.1 object

Open H21lab opened this issue 6 years ago • 4 comments

Is there a way of doing Dynamic ASN.1 compilation in pycrate in similar way as in libmich (in libmich it was by using inline)? Some example would be very useful. Thank you

H21lab avatar Nov 16 '17 09:11 H21lab

No, this is not supported (yet). Things on the ASN.1 side changed quite a lot, compared to libmich. In particular, all objects compiled are kept in their module (e.g. in GLOBAL.MOD['SomeModule']).

I may be able to make a specific part / function in the ASN.1 runtime (that import the whole ASN.1 compiler) and compile some object defined within a Python string into an object into the GLOBAL.MOD['_USER_'] special module. Would that help ?

mitshell avatar Nov 16 '17 21:11 mitshell

Yes, I think this would help. To me this is useful for importing only selected objects from ASN.1 files instead of compiling the whole ASN.1 files. By this the light scripts could be created without too much dependencies.

H21lab avatar Nov 17 '17 07:11 H21lab

As a workaround, you can also strip an ASN.1 definition with only the definitions you need, and compile it into a Python file. You will then just need to load this Python file to get the objects you want.

I have not much time yet to work on the ASN.1 compiler side, unfortunately. Hence, this issue may stay open for few months.

mitshell avatar Nov 17 '17 12:11 mitshell

Thank you for the feedback. I made workaround in this way.

H21lab avatar Nov 17 '17 16:11 H21lab