Moderator: RevPiModIO

Topic Author
Posts: 6
Joined: 31 May 2019, 18:47

How to disconnect a process from RevPiModIO?

09 Jun 2019, 15:47

This question is related to the following post for which I have not received a reply: ... 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 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!
Posts: 4
Joined: 28 Mar 2019, 15:33

Re: How to disconnect a process from RevPiModIO?

21 Jun 2019, 15:56


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.

User avatar
Posts: 194
Joined: 20 Jan 2017, 08:44

Re: How to disconnect a process from RevPiModIO?

02 Sep 2019, 21:20

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
# For example
rpi = revpimodio2.RevPiModIO(autorefresh=True, direct_output=True)
Regards, Sven
python3-RevPiModIO - || Der RevPi ist das Beste, was passieren konnte!

Who is online

Users browsing this forum: No registered users and 1 guest