Using setDeviceSerialNumber()
Posted: Mon Jul 11, 2022 7:42 pm
This is some pared down code that basically turns on the Power Plug Phidget (Python).
def main():
#Create your Phidget channels
digitalOutput3 = DigitalOutput() # Power Plug Phidget, ID: PSU1000_0
<< other code re other Vints is omitted for clarity >>
digitalOutput3.setIsHubPortDevice(True)
digitalOutput3.setHubPort(3)
digitalOutput3.openWaitForAttachment(5000)
digitalOutput3.setDutyCycle(1)
time.sleep(1.0)
digitalOutput3.setDutyCycle(0)
digitalOutput3.close()
main()
======================= END OF CODE ===================
I had a long period where this code worked, until the following:
a. three months where I didn't use the phidgets,
b. numerous system updates,
c. some updates to the Phidget drivers.
Then the code did not seem to turn the relay driver on and off.
I now find that if I add this line:
digitalOutput3.setDeviceSerialNumber(538442)
things work as I expect.
I'll accept that I should have added setDeviceSerialNumber all along (I was using it for AnalogOutput on the same Vint, but for some reason I didn't have it on the digitalOutput. What was the reason this actually worked once?
I notice the web site example for Phidget PSU1000_0 does not have setDeviceSerialNumber as part of the sample code. How would it know *which* Vint you want?
Does the order that I connect a 2nd Vint to my laptop matter? Does the code find the right Vint sometimes but not others if you don't specify the SerialNumber?
thanks,
John
def main():
#Create your Phidget channels
digitalOutput3 = DigitalOutput() # Power Plug Phidget, ID: PSU1000_0
<< other code re other Vints is omitted for clarity >>
digitalOutput3.setIsHubPortDevice(True)
digitalOutput3.setHubPort(3)
digitalOutput3.openWaitForAttachment(5000)
digitalOutput3.setDutyCycle(1)
time.sleep(1.0)
digitalOutput3.setDutyCycle(0)
digitalOutput3.close()
main()
======================= END OF CODE ===================
I had a long period where this code worked, until the following:
a. three months where I didn't use the phidgets,
b. numerous system updates,
c. some updates to the Phidget drivers.
Then the code did not seem to turn the relay driver on and off.
I now find that if I add this line:
digitalOutput3.setDeviceSerialNumber(538442)
things work as I expect.
I'll accept that I should have added setDeviceSerialNumber all along (I was using it for AnalogOutput on the same Vint, but for some reason I didn't have it on the digitalOutput. What was the reason this actually worked once?
I notice the web site example for Phidget PSU1000_0 does not have setDeviceSerialNumber as part of the sample code. How would it know *which* Vint you want?
Does the order that I connect a 2nd Vint to my laptop matter? Does the code find the right Vint sometimes but not others if you don't specify the SerialNumber?
thanks,
John