Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semaphore timeouts before read or write #12

Open
spasoye opened this issue Jun 15, 2021 · 1 comment
Open

semaphore timeouts before read or write #12

spasoye opened this issue Jun 15, 2021 · 1 comment

Comments

@spasoye
Copy link

spasoye commented Jun 15, 2021

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 ?

@spasoye
Copy link
Author

spasoye commented Jun 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant