Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Shared Memory Access Issues

rpostwvu
2024-01-29
2024-01-30
  • rpostwvu - 2024-01-29

    I got the shared memory example. I'm pretty sure I'm successfully created a memory space, CreateResult returns 18.

    szName:='CodesysDataShare';
    
    hShm := SysSharedMemoryCreate(szName, 0, ADR(uxiSize), ADR(CreateResult));
    

    I'm trying to access this memory with a C# application, but I get "Unable to Find Specified File". I suspect that Codesys and/or Visual Studio code alters the name I choose? Being in Windows, I cant find a way to see the mapped memory list.
    ~~~
    using (var mmfRead = MemoryMappedFile.OpenExisting("CodesysDataShare",MemoryMappedFileRights.ReadWrite))
    ~~~

     
  • mondinmr

    mondinmr - 2024-01-30

    In Windows I need create shared memory in PC software and connect from CODESYS.
    If shm is not GLOBAL doesn't work due different users between runtime and PC software.
    PC software need admin privileges. Name need "Global\\" before key.
    Very unsafe!!!
    If CODESYS create shared I cannot find key PC side.

    In Linux I can create shared memory as standard user, bind in the runtime docker, use keys without any "Global\\".
    Much more safe!!!
    If CODESYS create shared you need play with permissions to use app as standard user. I prefer create form PC software as standard user.

     

    Last edit: mondinmr 2024-01-30

Log in to post a comment.