[ASN.1] REAL-type problem!?

Kim A. Brandt kimabrandt@REDACTED
Wed Jan 12 13:43:43 CET 2011


Hello list, (first-time mailer here)


Erlang is awesome!

I am looking at ASN.1 and got a problem with the REAL-type.

A sample (MyTest.asn) ASN.1-specification:

     MyTest DEFINITIONS AUTOMATIC TAGS ::=

     BEGIN

     MyComponent ::= SEQUENCE
     {
         enum  ENUMERATED { a, b },
         real  REAL
     }

     END


And this is what I get:

     ~$ erl
     Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

     Eshell V5.7.4  (abort with ^G)
     1> asn1ct:compile("MyTest",[uper_bin]).
     Erlang ASN.1 version "1.6.12" compiling "MyTest.asn"
     Compiler Options: [uper_bin,{i,"."}]
     --{generated,"MyTest.asn1db"}--
     --{generated,"MyTest.hrl"}--
     --{generated,"MyTest.erl"}--
     ok
     2> rr("MyTest.hrl").
     ['MyComponent']
     3> {ok,Bytes}=asn1rt:encode('MyTest','MyComponent',#'MyComponent'{enum=a,real="123.456"}).
     {ok,<<5,129,152,153,25,154,26,155,23,34,150,153,128>>}
     4> asn1rt:decode('MyTest','MyComponent',Bytes).
     {error,{asn1,{{badmatch,{"123456.E-3",<<>>,11}},
                   [{asn1rt_uper_bin,decode_real,1},
                    {'MyTest',dec_MyComponent,2},
                    {'MyTest',decode,2},
                    {asn1rt,decode,3},
                    {erl_eval,do_apply,5},
                    {shell,exprs,6},
                    {shell,eval_exprs,6},
                    {shell,eval_loop,3}]}}}

I tried with the latest OTP-release (R14B01), which gives the same error!?

My instinct tells me there is a problem with the REAL-type in conjunction with the ENUMERATED-type, D'oh! But, what can I do? And could this be a bug or did I forget or do something wrong?


Kind regards,

Kim


More information about the erlang-questions mailing list