ASN1C has the capability to generate sample application programs that make use of generated code within a project. The types of sample programs that can be created include writer, reader, client, and server.
A writer program is generated by selecting the -writer command-line option or the 'Generate writer sample program' option within the GUI. This causes a program named 'writer' to be generated which will populate a structure of the given PDU type and then encode and write it to an output file. If test code generation is being done as part of the project, a call will be made to the generated test function to populate the variable to be encoded; otherwise, the user will need to manually edit the program to add logic to to this part.
A reader program is generated by selecting the -reader command-line option or the 'Generate reader sample program' option within the GUI. This causes a program named 'reader' to be generated which will read a binary message from a file and decode it and print the results. The message file cna be that created by a writer program or can originate from some other source as long as it contains a message in raw binary format.
A client program is generated by selecting the -client command-line option or the 'Generate client sample program' option within the GUI. This causes a program named 'client' to be generated which will populate a structure of the given PDU type and then encode and write it over a TCP/IP connection to a server interface. It will then wait for a response from the server. Once received, the response will be decoded and printed and the client program will terminate. Note that in this release, only C++ client programs are supported.
A server program is generated by selecting the -server command-line option or the 'Generate server sample program' option within the GUI. This causes a program named 'server' to be generated which will will listen for an incoming TCP/IP socket connection request. Once received, it will read an encoded message from the client, decode it, and then send a response and terminate. Note that in this release, only C++ client programs are supported.