How to disconnect a process from RevPiModIO?

Moderator: RevPiModIO

Post Reply
akash.sharma
Posts: 6
Joined: 31 May 2019, 18:47

How to disconnect a process from RevPiModIO?

Post 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!
pmdevigne
Posts: 5
Joined: 28 Mar 2019, 15:33

Re: How to disconnect a process from RevPiModIO?

Post 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
User avatar
RevPiModIO
KUNBUS
Posts: 335
Joined: 20 Jan 2017, 08:44
Contact:

Re: How to disconnect a process from RevPiModIO?

Post 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
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
Post Reply