How do I open a digital output with a Python script and leave it open?

Supporting 2.7 and 3.2+
Post Reply
Mastiff
Phidgetly
Posts: 21
Joined: Fri Sep 11, 2020 9:20 am
Contact:

How do I open a digital output with a Python script and leave it open?

Post by Mastiff »

I have tried modyfying the example script, but whatever I do, a python script will close the open port again when I exit it. Can somebody please tell me the code for opening and closing a port and leave it open? Either on a local script or adressing the server, which is running.
User avatar
mparadis
Site Admin
Posts: 660
Joined: Fri Oct 28, 2011 12:17 pm
Contact:

Re: How do I open a digital output with a Python script and leave it open?

Post by mparadis »

I'm not sure what you're asking- a program needs to call open so it knows what channel it's controlling.

Do you mean leave the channel available to be opened by the next program? Because that should be the case once the first program has finished.

If you're asking why the state of the output goes back to false when the channel closes, see this thread.
Mastiff
Phidgetly
Posts: 21
Joined: Fri Sep 11, 2020 9:20 am
Contact:

Re: How do I open a digital output with a Python script and leave it open?

Post by Mastiff »

I mean sending a command that has for instance output 2 sending 12V- through until I turn it off again. I thought that was what the Phidgets server should enable? So that keeps current flowing until a restart of the server or until the port is actively turned off by something else? If there's a Python code that tells the server to keep open a port, then that's what I am looking for.
Mastiff
Phidgetly
Posts: 21
Joined: Fri Sep 11, 2020 9:20 am
Contact:

Re: How do I open a digital output with a Python script and leave it open?

Post by Mastiff »

Fixed. I got help to make a persistent Phyton script that's called from Node-RED and opens and closes the nodes. OK, somebody made it for me, I didn't do much myself... :mrgreen:
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests