From e3db20e7a0a9855dbf45e017db2f23eb91b914bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 25 Mar 2014 08:37:48 +0100 Subject: Correct and modernize the "A First Example" section Replace "IMPLICIT TAGS" with "AUTOMATIC TAGS" since AUTOMATIC TAGS is recommended for all new ASN.1 specifications. --- lib/asn1/doc/src/asn1_ug.xml | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'lib/asn1') diff --git a/lib/asn1/doc/src/asn1_ug.xml b/lib/asn1/doc/src/asn1_ug.xml index e39b47ff20..dfa8db32dd 100644 --- a/lib/asn1/doc/src/asn1_ug.xml +++ b/lib/asn1/doc/src/asn1_ug.xml @@ -134,19 +134,17 @@ A First Example

The following example demonstrates the basic functionality used to run the Erlang ASN.1 compiler.

-

First, create a file called People.asn containing the following:

+

Create a file called People.asn containing the following:

-People DEFINITIONS IMPLICIT TAGS ::=
-
+People DEFINITIONS AUTOMATIC TAGS ::=
 BEGIN
-EXPORTS Person;
-
-Person ::= [PRIVATE 19] SEQUENCE {
-        name PrintableString,
-        location INTEGER {home(0),field(1),roving(2)},
-        age INTEGER OPTIONAL }
+  Person ::= SEQUENCE {
+    name PrintableString,
+    location INTEGER {home(0),field(1),roving(2)},
+    age INTEGER OPTIONAL
+  }
 END      
-

This file (people.asn) must be compiled before it can be +

This file (People.asn) must be compiled before it can be used. The ASN.1 compiler checks that the syntax is correct and that the text represents proper ASN.1 code before generating an abstract @@ -158,14 +156,14 @@ END The following shows how the compiler can be called from the Erlang shell:

-1>asn1ct:compile("People", [ber]).
+1> asn1ct:compile("People", [ber]).
 ok
 2>      

The verbose option can be given to have information about the generated files printed:

-2>asn1ct:compile("People", [ber,verbose]).
+2> asn1ct:compile("People", [ber,verbose]).
 Erlang ASN.1 compiling "People.asn" 
 --{generated,"People.asn1db"}--
 --{generated,"People.hrl"}--
@@ -173,17 +171,17 @@ Erlang ASN.1 compiling "People.asn"
 ok
 3>      
-

The ASN.1 module People is now accepted and the abstract syntax tree - is saved in the People.asn1db file, the - generated Erlang code is compiled using the Erlang compiler and - loaded into the Erlang runtime system. Now there is a user interface - for encode/2 and decode/2 in the module People, - which is invoked by: -

-,),]]>

- +

The ASN.1 module People is now accepted and the + abstract syntax tree is saved in the People.asn1db file; + the generated Erlang code is compiled using the Erlang compiler + and loaded into the Erlang runtime system. Now there is an API + for encode/2 and decode/2 in the module + People, which is invoked by:

+ , )]]> +

or

-,),]]>

+, )]]>

+

Assume there is a network application which receives instances of the ASN.1 defined type Person, modifies and sends them back again:

@@ -206,8 +204,7 @@ receive constructed and encoded using 'People':encode('Person',Answer) which takes an instance of a defined ASN.1 type and transforms it to a - binary according to the BER or PER - encoding-rules. + binary according to the BER or PER encoding rules.

The encoder and the decoder can also be run from the shell.

-- cgit v1.2.3