semaphore timeouts before read or write
Hello, I successfully implemented robin in melodic ROS container on my Toradex Verdin board. I run Codesys runtime in other container and managed to import example project .xml in CODESYS V3.5 SP16 Patch 4 that is running on my Windows machine. After running start_update.py, building loging into Codesys I realized this.
Semaphore in the Codesys program timeouts on every read and write and nothing is written to shared memory. When I commented semaphore checking in robin library write and read function I was able to read and write data to shared memory and echo them in ROS container. When I uncommented the semaphore checks in read and write functions but this time SysSemProcessEnter returned ERR_OK and everything worked as it should. This happens after every reset.
Any idea what am I doing wrong ?
I've managed to workaround this problem. I realized that after SysSemProcessCreate() created semaphore is locked. I modified Robin.open Codesys function:
IF data[idx].shm = RTS_INVALID_HANDLE THEN
data[idx].shm := SysSharedMemoryOpen2(name, 0, ADR(size), ADR(data[idx].result));
IF data[idx].shm <> RTS_INVALID_HANDLE THEN
data[idx].sem := SysSemProcessCreate(name, ADR(data[idx].result));
IF data[idx].sem <> RTS_INVALID_HANDLE THEN
open := TRUE;
END_IF
SysSemProcessLeave(data[idx].sem); // ------> Added this
ELSE
open := FALSE;
END_IF
ELSE
open := TRUE;
END_IF
Correct me if I'm doing something wrong.