Home

mlamp

Download SharedMemoryExample.zip

Shared Memory Communication

This example shows how data can be exchanged between a CODESYS controller and
other processes by means of shared memory.

Product description

In the sample project, data from a CODESYS controller is shared with other processes
by means of shared memory. The CODESYS package includes additional implementation examples
in C (Linux), C# (Windows), and C++ (Windows).

More information

The CODESYS package includes the following examples:

SharedMemoryExampleExt.project

The project uses shared memory to read and write data with the SysShm library.
The DataExchange structure is used for data exchange. Values from shared memory
is read to the variable deInstRead. The variable deInstWrite is used for
writing values to shared memory. The values of deInstWrite are changed in each cycle.
The values of both variables are displayed in the visualization.

The following examples read the value of deInstWrite and write to the variable deInstRead:

SharedMemoryCLinux

C program for Linux to read and write data be means of shared memory

SharedMemoryWinCpp

C++ program for Windows to read and write data be means of shared memory

SharedMemoryWinCSharp

C# program for Windows to read and write data be means of shared memory

SharedMemoryExampleExt.project/SyncExample:

The application SyncExample shows how data can be read and written synchronously via shared memory.

SynchronizationExample:

C++ program for Windows for synchronized reading and writing of data via shared memory.
In this example the data exchange is done by the application SyncExample.

System requirements and restrictions

System requirements and restrictions Info
Programming System CODESYS Development System V3.5.16.1 or higher
Runtime System CODESYS Control V3.5.16.1
Required Accessories -

Screenshot thumbnail
Screenshot of Visualization