Example: Shared Memory
Product: CODESYS Control
You can use the shared memory for data exchange within a target system when direct communication is not possible. One use case, for example, would be the data exchange with an external visualization. This example shows how to create this shared memory and how to read and write to it.
Description
Two applications are used for the demonstration. Each one of the applications has to run on a separate runtime system on the same target device. Then both of these runtime system processes communicate by means of shared memory. The first application creates a shared memory and writes some values to the memory, and the second application reads the memory.
Additional information
Write_App
: The application creates a shared memory object and writes some strings to memory.
Read_App
: The application tries to open the shared memory and read the data in two different ways. In the first case, a data string of a specific size is read. In the second case, the pointer to the first element is fetched and incremented until the "End of Text" character is reached. After that, the memory is deleted.
You need to download both applications to the target device, either by Multiple Download or a separate download of each application.
To start a second CODESYS runtime system, open the Windows Start menu. Go to CODESYS Control Win and open the CODESYS Control Win. Now this is now running next to "CODESYS Control Win Sys Tray".
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
DOWNLOAD Project