PFC Shared Memory Communication (IPC)

Some information about Shared Memory Communication (also called IPC-Inter Process Communication) between e!Cockpit and a C-application on Wago PFC.

Look here for examples: GitHub - Wago-Norge/SharedMemCom: How to use WagoAppMem with C-application.

Running e!Cockpit and C-application with same priority:
image
image

HTOP shows thread with priority -54:
image

Linux RT priorities → PR = -1-realtimepri (0-99) → realtimepri = 53.

Check priority and policies:
image

Shows that e!Cockpit application runs ‘SCHED_FIFO’. This should mean preemptive multitasking. A thread that have been “preempted” by higher priority thread will resume as soon as the higher priority thread are blocked again.

C-Application library:
image
image

Set same real time interrupt policy as e!Cockpit:
image

HTOP shows they are running with same priority:
image

POSIX shared memory is mounted to tmpfs (temporary file storage for virtual memory/RAM) at /dev/shm:

Some remaining questions to solve is:

‘xRequiresSystemMemory’ and ‘xAssumeExisting’ does not seem to work with C-Application (POSIX). I will only get “ENOENT” (No such file or directory) or “ENOSYS” (Function not implemented).

In the case e!Cockpit creates the shared memory (is master) and a C-application should connect to this (slave process) this bit should be set because it communication with non IEC process (?).

But it works when ‘xRequiresSystemMemory’ is FALSE. Strange when documentation says:

Note (2): When this flag is set, the call may fail with ENOSYS when the actual target does not support sharing memory between IEC and other different processes.

With this library there is also no specific documented flags like in the POSIX calls (‘O_CREAT’, ‘O_EXCL’, ‘PROT_READ’, ‘PROT_WRITE’, MAP_SHARED’ etc.). Unclear how it works in the background.

5 Likes