Skip to main content

Example: RPC

Product: CODESYS Development System

The sample project shows an application for RPC ("Remote Procedure Calls"). Two applications show the implementation of server and client RPC applications.

_example_img_rpc.png

Description

The example is based on the RPC library, which is part of the CODESYS Development System. The library contains all required components for creating RPC applications. The RPCExample.project sample project shows how to use this library based on a simple client and server application.

Additional information

The RPCExample.project project includes the RPClient and RPCServer applications. Both applications have to run on separate controllers.

RPC Client

The PROG program executes four RPCs (remote procedure calls) on the server:

  • HelloServerRequest

  • GetTargetId

  • GetTargetNodeName

  • GetTargetVersion

Each call is handled by the RPCRequest function block, which uses the RPC.CLClient function block to send an RPC request to the server. The results of the request are copied to the corresponding variables in the InvokeCallback method of the PCClientCallback function block. The status of the request and the result of the request are displayed in the visualization.

Visualization

At first, the IP address of the server has to be entered in the Server IP field. After that, the RPC request can be started by clicking the RPC Request button.

RPC Server

The PLC_PRG program initializes the RPC.CLServer function block and registers the IRPCProvider interface. A procedure is described by objectId, interfaceId, and operationnumber. The request and the callback function are handled by operationnumber in the Request method. The callback function can also be executed asynchronously in the next cycle. By default, the server component of the RPC library includes three procedures with device information (Target Name, Target ID, and Target Version).

System requirements and restrictions

Programming system

CODESYS Development System (version 3.5.14.0 or higher)

Runtime system

CODESYS Control Win (version 3.5.14.0)

Add-on components

-

Note

_example_icon.png DOWNLOAD Project