Page 1 of 1

How to disconnect a process from RevPiModIO?

Posted: 09 Jun 2019, 15:47
by akash.sharma
This question is related to the following post for which I have not received a reply: https://revolution.kunbus.de/forum/view ... sing#p5180

Briefly I have two processes that need to access DIFFERENT outputs on the RevpiDIO. In the post above I explained that I had unexpected behavior when I tried to have each process connect to the DIO module using its own revpmodio2.RevPiModIO object. I was wondering if I could have each process CONNECT to the DIO right before it needs to use it (using conn = revpmodio2.RevPiModIO(autorefresh=True)) and then DISCONNECT right after it uses it? That would be inefficient (connecting every time the process needs to output a DO and then disconnecting) but the inefficiency might be acceptable, and it might solve the problem of one process stepping on the other that I described in the other post).

However I don't see how to explicitly DISCONNECT from the DIO. I looked in https://revpimodio.org/en/doc2/io/ for any method called "close" or "disconnect" or "release" but I did not find anything. I also looked for attributes of revpimodio2 (using print(dir(revpimodio2))) and again didn't see any attribute that intuitively seemed like a DISCONNECT. Any suggestions.

Thanks in advance!

Re: How to disconnect a process from RevPiModIO?

Posted: 21 Jun 2019, 15:56
by pmdevigne
Hello

Maybe, you can create a communication channel between the two processes.
Thus, the first process can tell the second to write outputs. The second process can also write its own outputs.
With that, only one process really writes the outputs.
You can use sockets for this.

Regards

Re: How to disconnect a process from RevPiModIO?

Posted: 02 Sep 2019, 21:20
by RevPiModIO
Hi akash.sharma!

About the multi processing things, I wrote an answer here: viewtopic.php?f=41&t=1314&p=5180&hilit= ... sing#p5791

You can "disconnect" you local RevPiModIO object with the call of .cleanup(). This will write close and disconnect all loops and release the process image. This is a function of the base module not the .io :D

Code: Select all

# For example
rpi = revpimodio2.RevPiModIO(autorefresh=True, direct_output=True)
rpi.cleanup()
Regards, Sven