tutorial_server_firstSteps.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. Building a simple server
  2. ------------------------
  3. This series of tutorial guide you through your first steps with open62541. For
  4. compiling the examples, you need a compiler (MS Visual Studio 2015 or newer,
  5. GCC, Clang and MinGW32 are all known to be working). The compilation
  6. instructions are given for GCC but should be straightforward to adapt.
  7. It will also be very helpful to install an OPC UA Client with a graphical
  8. frontend, such as UAExpert by Unified Automation. That will enable you to
  9. examine the information model of any OPC UA server.
  10. To get started, downdload the open62541 single-file release from
  11. http://open62541.org or generate it according to the :ref:`build instructions
  12. <building>` with the "amalgamation" option enabled. From now on, we assume you
  13. have the ``open62541.c/.h`` files in the current folder.
  14. Now create a new C source-file called ``myServer.c`` with the following content:
  15. .. literalinclude:: server_firstSteps.c
  16. :language: c
  17. :linenos:
  18. :lines: 4,12,14-
  19. This is all that is needed for a simple OPC UA server. Compile the the server
  20. with GCC using the following command:
  21. .. code-block:: bash
  22. $ gcc -std=c99 open62541.c myServer.c -o myServer
  23. Now start the server (and stop with ctrl-c):
  24. .. code-block:: bash
  25. $ ./myServer
  26. You have now compiled and run your first OPC UA server. You can go ahead and
  27. browse the information model with UA Expert. The server will be listening on
  28. ``opc.tcp://localhost:16664`` - go ahead and give it a try.
  29. In the following tutorials, you will be shown how to populate the server's
  30. information model and how to create a client application.