Questions about opening (and closing) a connection
Posted: Thu Apr 15, 2021 6:31 am
Hi!
Phidget beginner here, hopefully someone can help me with a few questions that I have not yet found an answer to:
First of all, what does the "5000" in “ch.open(5000)” mean? I assume that's a timeout? This is never explained in the tutorial.
Another thing that has puzzled me: why is it important to close the connection? We will use phidgets to control some simple servos and LEDs, but as long as the session is running I don't see a reason to ever close a connection... Does that have any disadvantages I am not aware of?
Is it possible to check if a connection is already open? The examples I used always do this:
But I can imagine something like this would also be possible if we can keep all connections open:
And finally, is it possible to close any open connections or overtake those connections after a complete refresh of the code? Our app runs on node and to make sure all of the data is properly reset we simply reset the server. But that does mean we will lose all connection variables as well. If this is not possible that's ok; I will simply close all open connections before I reboot the server.
Phidget beginner here, hopefully someone can help me with a few questions that I have not yet found an answer to:
First of all, what does the "5000" in “ch.open(5000)” mean? I assume that's a timeout? This is never explained in the tutorial.
Another thing that has puzzled me: why is it important to close the connection? We will use phidgets to control some simple servos and LEDs, but as long as the session is running I don't see a reason to ever close a connection... Does that have any disadvantages I am not aware of?
Is it possible to check if a connection is already open? The examples I used always do this:
Code: Select all
ch.open(5000).then(function() { ch.setDutyCycle(1); });
Code: Select all
if (ch.isOpen) { ch.setDutyCycle(1); });