TOC PREV NEXT INDEX


Procedure for Using the C++ Control Class Encode Method



The following are the steps are involved in decoding a PER message using the generated C++ class:







A program fragment that could be used to decode an employee record is as follows:

    #include employee.h         // include file generated by ASN1CPP
 

 
    main ()
 
    {
 
        ASN1OCTET msgbuf[1024];
 
        int       msglen, stat;
 
        ASN1BOOL  aligned = TRUE;
 

 
        .. logic to read message into msgbuf ..
 

 
        // step 1: instantiate a PER decode buffer object
 

 
        ASN1PERDecodeBuffer decodeBuffer (msgbuf, msglen, aligned);
 

 
        // step 2: instantiate an ASN1T_<ProdName> object
 

 
        ASN1T_PersonnelRecord msgData;
 

 
        // step 3: instantiate an ASN1C_<ProdName> object
 

 
        ASN1C_PersonnelRecord employee (decodeBuffer, msgData);
 

 
        // step 4: decode the record
 

 
        stat = employee.Decode ();
 

 
        // step 5: check the return status
 

 
        if (stat == ASN_OK)
 
        {
 
            process received data..
 
        }
 
        else {
 
            // error processing..
 
            decodeBuffer.PrintErrorInfo ();
 
        }
 

 
        // step 6: free dynamic memory (will be done automatically 
 
        // when both the decodeBuffer and employee objects go out 
 
        // of scope)..
 

 
    }
 



Objective Systems, Inc.

102 Pickering Way, Suite #506
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com
TOC PREV NEXT INDEX